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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
| <template>
| <div class="box">
| <div id="map"></div>
| </div>
| </template>
|
| <script>
| export default {
| components: {},
| data () {
| return {
| id: 'map',
|
| isFirst: true,
|
| billboards: [],
|
| points: [
| { Id: 1, name: '荣华路', X: 116.513388391, Y: 39.7800359429 },
| { Id: 2, name: '博大公园', X: 116.49748923, Y: 39.7953239798 },
| { Id: 3, name: '博大大厦', X: 116.500542554, Y: 39.7936635919 },
| { Id: 4, name: '大族广场', X: 116.503978496, Y: 39.793901538 },
| { Id: 5, name: '荣京东街', X: 116.517618076, Y: 39.7997408656 },
| { Id: 6, name: '同仁医院', X: 116.5138099, Y: 39.7742515003 }
| ]
| }
| },
| methods: {
| init () {
| var that = this
| window.map = new TUMap({
| id: that.id,
|
| url: UE_URL,
|
| onInit: function () {
| that.inited();
| }
| });
| window.onunload = function () {
| map.execute('grapi', 'RoamingEnd', { time: 0 }, function () { }); // 停止漫游
| };
| },
| inited () {
| var that = this;
| map.setTime(1200);
| //map.setTime('noon');
| //this.setTime();
| // setTimeout(() => {
| // that.setTime();
| // }, 15 * 60 * 1000);
| map.setWeather('sun'); // 晴天
| map.execute('grapi', 'RoamingEnd', { time: 0 }, function (e) { console.log("grapi.RoamingEnd ->", e); }); // 停止漫游
| this.getPath();
|
| // 3DPOI回调
| map.Enable3DBillboardCallBack(true, function (e) {
| if (e && e.BillboardMouseType == 'Pressed' && e.JsonNews) {
| that.$store.commit('changeVideo', e.JsonNews.index);
| that.$bus.$emit('manYouVideo', e);
| }
| });
|
| // POI回调
| map.pickPosition(function (e) {
| if (e && e.category == 'billboard' && e.clickType == 1) {
| that.$store.commit('changeVideo', e.index);
| that.$bus.$emit('manPoiVideo', e);
| }
| });
|
| window.setTimeout(function () {
| that.startTime();
| that.setView(DEFAULT_VIEW);
| }, 3500);
| },
| setTime () {
| let d = new Date();
| let h = d.getHours();
| let m = d.getMinutes();
| let time = parseInt(h + "" + (m > 9 ? "" : "0") + m);
|
| console.log("map.setTime =>", time);
| map.setTime(time); // 1200
| },
| startTime () {
| var that = this;
| setInterval(function () {
| let status = that.$store.state.getVisibleStatus();
|
| if (status !== that.$store.state.poiStatus && that.$store.state._2ds.length) {
| console.log("变更POI显示状态:", that.$store.state.poiStatus, "=>", status, map.camera.distance);
| that.$store.commit("changePOIVisible", status);
| }
| }, 1000);
| },
| getPath () {
| //let wpath = window.location.protocol;
| //let host = window.location.host;
| //let url = wpath + '//' + host + '/';
| let url = window.location.href;
| if (url.indexOf('#') > -1) url = url.split('#', 2)[0];
| window.mainUrl = url.substring(0, url.lastIndexOf('/') + 1);
|
| this.$store.state.mainUrl = mainUrl;
| },
| flyTo (v, callback) {
| map.flyTo(v.x, v.y, v.z, v.roll, v.pitch, v.yaw, v.distance, callback, v.time || 3);
| },
| setView (v) {
| map.setView(v.x, v.y, v.z, v.roll, v.pitch, v.yaw, v.distance);
| },
| createtext () {
| var labels = [];
| for (var i in this.points) {
| var p = this.$store.state.transform(this.points[i].X, this.points[i].Y)
| labels.push(
| map.createLabel({
| x: p.x,
| y: p.y,
| z: 1000, //位置 z
| size: { width: 30, height: 10 },
| text: this.points[i].name,
| scale: 1,
| type: 'Default',
| backgroundColor: 0xffffffff,
| fillColor: '#ffffff'
| })
| );
| }
| labels.forEach(function (label) {
| label.show(true);
| })
| }
| },
| created () { },
| mounted () {
| this.init()
| }
| }
| </script>
| <style lang="less" scoped>
| //@import url(); 引入公共css类
| .box {
| // display: flex;
| width: 100%;
| height: 100%;
| position: relative;
| #mapContainer {
| width: 100%;
| height: 100%;
| position: absolute;
| }
| }
| </style>
|
|