index.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. var { tpanorama } = require('../src/index.js');
  2. var opt, tp;
  3. window.onload = function () {
  4. opt = {
  5. container: 'panoramaConianer',//容器
  6. url: 'img/p3.png',
  7. lables: [
  8. { position: { lon: -72.00, lat: 9.00 }, logoUrl: 'img/logo.png', text: '蓝窗户' },
  9. { position: { lon: 114.12, lat: 69.48 }, logoUrl: 'img/logo.png', text: '一片云彩' },
  10. { position: { lon: 132.48, lat: -12.24 }, logoUrl: 'img/logo.png', text: '大海' }
  11. ],
  12. widthSegments: 60,//水平切段数
  13. heightSegments: 40,//垂直切段数(值小粗糙速度快,值大精细速度慢)
  14. pRadius: 1000,//全景球的半径,推荐使用默认值
  15. minFocalLength: 6,//镜头最a小拉近距离
  16. maxFocalLength: 100,//镜头最大拉近距离
  17. sprite: 'icon', // label,icon
  18. onClick: onClick,
  19. }
  20. tp = new tpanorama(opt);
  21. }
  22. function onClick(name) {
  23. console.log(name.object.name);
  24. if (name.object.name === '大海') {
  25. alert('进入下一张图')
  26. opt.url = 'img/p2.png';
  27. opt.lables = [];
  28. tp.render(opt);
  29. } else {
  30. alert('点击了:' + name.object.name)
  31. }
  32. }
  33. function changeImg(name) {
  34. opt.lables = [];
  35. if (name == "p1") {
  36. opt.lables = [{ position: { lon: 178.56, lat: -15.84 }, text: '神像' }]
  37. }
  38. if (name == "p2") {
  39. opt.lables = [{ position: { lon: -80.64, lat: -16.92 }, text: '蓝色' }, { position: { lon: 46.80, lat: 10.44 }, text: '绿色' }]
  40. }
  41. if (name == "p4") {
  42. opt.lables = [{ position: { lon: 48.96, lat: -20.16 }, text: '樱花' }]
  43. }
  44. opt.url = 'img/' + name + '.png';
  45. tp.render(opt);
  46. }