html:页面加上<!DOCTYPE PhotoSphereViewer显示不出来?

原因竟是没有设置尺寸

以下是一个简单的demo,演示如何在Photo Sphere Viewer 5.1中按住鼠标移动Marker位置: ```html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Photo Sphere Viewer 5.1 Marker Demo</title> <style> #viewer { width: 100%; height: 500px; } </style> </head> <body> <div id="viewer"></div> <script src="https://cdn.jsdelivr.net/npm/three/build/three.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/photo-sphere-viewer/dist/photo-sphere-viewer.min.js"></script> <script> // 创建Photo Sphere Viewer对象 var viewer = new PhotoSphereViewer({ container: 'viewer', panorama: 'https://photo-sphere-viewer.js.org/assets/Bryce-Canyon-National-Park-Mark-Doliner.jpg', navbar: true, markers: [ { id: 'marker1', longitude: 0.5, latitude: 0.2, image: 'https://photo-sphere-viewer.js.org/assets/pin-red.png', width: 32, height: 32, anchor: 'bottom center', }, ], }); // 获取标记对象 var marker = viewer.getMarker('marker1'); // 在mousedown事件上更新标记位置 marker.on('mousedown', function(event) { // 阻止默认行为和事件传播 event.preventDefault(); event.stopPropagation(); // 获取场景坐标系中的鼠标位置 var mousePosition = viewer.mouseToCoords(event.clientX, event.clientY); // 更新标记位置 marker.setPosition(mousePosition); }); // 在mouseup事件上保存标记位置 marker.on('mouseup', function(event) { // 保存标记位置 marker.save(); }); </script> </body> </html> ``` 在这个demo中,我们在Photo Sphere Viewer中添加了一个标记,并使用上面提到的代码来实现按住鼠标移动Marker位置的功能。您可以在https://codepen.io/pen/GRvKyNL 上查看该demo的效果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

葩熊

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值