javascript - 我正在使用 Photo Sphere Viewer,现在我想在不重新加载页面的情况下将全景图像替换为新图像
问题描述
谁能告诉我如何在不重新加载页面的情况下单击按钮将全景图像转换为新图像?
我正在使用的 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);
将为您完成工作。
假设您有一个标识为“goto-pano”的标记,那么,
PSV.on('select-marker', (marker) => {
if (marker.id === 'goto-pano') {
PSV.setPanorama('new-pano.jpg', null, true);
}
});
或者您可以在您拥有的任何其他按钮单击事件中执行此操作。
推荐阅读
- jquery - 更改父元素jquery中所有元素的类
- sql - 选择聚合函数的时间戳
- jenkins - Jenkins 如何确定流水线中的阶段是构建步骤还是测试步骤?
- react-native - 使用 react-navigation 从相机回调图像 uri
- python - 指定从 SQL Server 返回的数据框中列的数据类型
- c++ - 如何编写没有变量的for循环?
- android - 使用矩形和三角形创建 Android XML 形状,如图背景所示
- python - 安装和运行 PyTorch 的问题
- node.js - 在 Visual Studio 代码中使用 typescript 和 webpack 调试 nodejs 项目的正确方法
- python - 自定义聚合时间序列功能