13693261870
2023-06-21 cdf12fc9e88b1af69f5c85165eb9fef4e23bf57a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
var UE = {
  billboards: [],
 
  id: "map",
 
  url: "http://127.0.0.1:96",
 
  mainUrl: location.href.substring(0, location.href.lastIndexOf("/") + 1),
 
  view: {
    x: 116.5139265, //116.51411,
    y: 39.7725406 //39.799614
  },
 
  map: null,
 
  init: function () {
    var that = this;
    this.map = new TUMap({
      id: this.id,
      url: this.url,
      onInit: function () {
        that.inited();
      }
    });
  },
 
  inited: function () {
    // x, y, z, roll, pitch, yaw, distance, callBack, time
    //this.map.flyToGIS(this.view.x, this.view.y, 0, 0, -45, 0, 30000, null, 5);
    this.map.flyTo(-554198.375, -964085.9375, 0, 0, -27, -120, 60000, null, 3);
 
    Videos.length = 10;
    // this.addVideos(Videos);
 
    var that = this;
    this.map.EnableBillboardCallBack(true, function (data) {
      console.log(data)
    });
  },
 
  // 添加视频点
  addVideos: function (data) {
    this.removeVideos();
 
    for (var i = 0, c = data.length; i < c; i++) {
      var x = parseFloat(data[i].longitude), y = parseFloat(data[i].latitude);
      if (x == 0 || y == 0) continue;
 
      var p = this.map.transformWGS84ToLocal(x, y);
      var bb = this.map.createBillboard({
        x: p.x,
        y: p.y,
        z: 500,
        //vectorType: "WGS84",
        image: this.mainUrl + "UE/Video.png",
        scale: 0.25,
        clickedScale: 0.3,
        visibility: true,
        flash: false,
        canClick: true
        // ,
        // alertWindow: {//可选,点击弹窗
        //   url: this.mainUrl + "UE/video?channelId=" + data[i].channelId,//弹窗地址
        //   size: new TUVector2(300, 200),//弹窗大小
        //   offset: new TUVector2(0, -200)//弹窗位置,右:x正,下:y正
        // }
      });
    }
    this.billboards.push(bb);
  },
 
  // 添加视频点
  removeVideos: function () {
    this.billboards.forEach(function (b) {
      b.removeFromMap();
    });
    this.billboards.length = 0;
  },
 
  flyTo: function (x, y, pitch, distance, time) {
    this.map.flyToGIS(x, y, 0, 0, pitch || -45, 0, distance || 15000, null, time || 5);
  },
 
  test: function () {
    this.map.flyToGIS(this.view.x, this.view.y, 0, 0, 0, 90, 750, null, 3);
  }
}
 
window.onload = function () {
  UE.init();
}