javascript - 我正在使用 Photo Sphere Viewer,现在我想将全景图像替换为新图像,而无需重新加载页面

标签 javascript jquery html json

谁能告诉我如何在不重新加载页面的情况下单击按钮将全景图像转换为新图像?

我使用的 Photo Sphere 照片查看器是 https://photo-sphere-viewer.js.org

var PSVUtils = PhotoSphereViewer.Utils,
      fov = 70,
      PSV = new PhotoSphereViewer({
        panorama: 'images/vr-min.jpg', //want to change this image
        container: 'photo360',
        navbar: 'autorotate zoom download fullscreen',
        caption: 'vr',
        mousewheel: false,
        size: 800,
        time_anim: false,
        gyroscope: true,
        // webgl: PSVUtils.isWebGLSupported(),
        move_speed: 3,
        default_fov: fov + .01,
        min_fov: fov,
        max_fov: fov + .01,
        markers: [
          {
            // html marker with custom style
            id: 'text',
            longitude: -1.4,
            latitude: 0.12,
            html: '<a href="#" style="color:#fff;" onclick="myFunction()"><img id="myimg" src="https://png.icons8.com/color/260/circled-play.png" width="30" height="30" /></a>',
            anchor: 'bottom right',
            style: {
              maxWidth: '20px',
              color: 'white',
              fontSize: '20px',
              fontFamily: 'Helvetica, sans-serif',
              textAlign: 'center'
            },
            tooltip: {
              content: 'Watch this video for more details',
              position: 'right',
    height: '500px'
            }
          }
        ]
      });

我不知道如何替换此图像。提前致谢。

最佳答案

PSV.setPanorama('new-pano.jpg', null, true);

将为您完成这项工作。

假设您有一个 ID 为“goto-pano”的标记,那么,

PSV.on('select-marker', (marker) => {
  if (marker.id === 'goto-pano') {
    PSV.setPanorama('new-pano.jpg', null, true);
  }
});

或者您可以在任何其他按钮单击事件中执行此操作。

关于javascript - 我正在使用 Photo Sphere Viewer,现在我想将全景图像替换为新图像,而无需重新加载页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52271424/

相关文章:

javascript - iframe 视频使用按钮打开并在关闭时停止播放

javascript - 由于目标被视为被动,因此无法阻止被动事件监听器内的默认设置 - Chrome

javascript - jQuery 尝试显示下一个元素

jquery - 如何在语义上将单个列表分成多列?

javascript - 在 Mobile Safari 上执行操作(经过一段时间后)

javascript - 从下/上向左/右滑动切换

javascript - 如何递归合并 2 个 javascript 对象?

HTML 将链接元素的高度设置为其背景

javascript - 如何更改 Chrome 扩展中的事件标签网址

javascript - 对具有相同类的所有元素应用函数