wangjuncheng
3 天以前 8adbf886a8062a0c96feadfe701a266601acd134
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
// class Streetscape {
//     constructor(sgworld, option = {}) {
//         this.sgworld = sgworld
//         this.streetscape_alpha = option.alpha || 1;
//
//         /**
//          *
//          *  街景服务参数
//          *
//          */
//         this.streetSphere_data = {
//             StreetUrl: option.StreetUrl,
//             getImageRootUrl: option.StreetUrl + "/Image3DResourceService/GetImageTile/?ImageID=",
//             getImageInfo: option.StreetUrl + '/Image3DResourceService/GetImageInfo/?ImageID=',
//             getFirstImageDir: "&zoom=0",
//             getSecondImageDir: "&zoom=4",
//             lon: option.lon,
//             lat: option.lat
//         }
//         this.setStreetScapeUrl()
//         this.init()
//
//     }
//
//     //设置街景接口响应回调
//     setStreetViewData(StreetViewData, datas) {
//         StreetViewData.getImageTileID = datas.Station.StationID;
//         StreetViewData.lon = datas.Station.X;
//         StreetViewData.lat = datas.Station.Y;
//         StreetViewData.height = datas.Station.H;
//         StreetViewData.HeadingPitchRoll = {
//             heading: datas.Station.Yaw,
//             pitch: datas.Station.Pitch,
//             roll: datas.Station.Roll,
//         };
//         this.getLinksData(StreetViewData)
//     }
//
//     // 立德街景前后数据
//     getLinksData(StreetViewData) {
//         this.sgworld.core.xhr({
//             url: this.StreetScapeOption.getInitImageSequenceById.replace('{id}', StreetViewData.getImageTileID) + '&Step=1',
//             type: 'get',
//             dataType: 'json',
//             success: data => {
//                 this.setLinksData(0, data, StreetViewData, () => {
//                     this.StreetView.createNavigation()
//                 })
//             }
//         })
//         this.sgworld.core.xhr({
//             url: this.StreetScapeOption.getInitImageSequenceById.replace('{id}', StreetViewData.getImageTileID) + '&Step=-1',
//             type: 'get',
//             dataType: 'json',
//             success: data => {
//                 this.setLinksData(-1, data, StreetViewData, () => {
//                     this.StreetView.createNavigation()
//                 })
//             }
//         })
//     }
//
//     setLinksData(step, data, StreetViewData, callback) {
//         let angle = StreetViewData.HeadingPitchRoll.heading + step * 180
//         let links = []
//         if (data.StationItems) {
//             links = data.StationItems.filter(item => {
//                 return item.Station.StationID !== StreetViewData.getImageTileID
//             })
//         }
//         let type = step === -1 ? 'prev' : 'next'
//         if (links.length) {
//             let link = links[0].Station
//             StreetViewData.linkImagesData.push({
//                 type: type,
//                 name: link.Address,
//                 ImageID: link.StationID,
//                 NavigationAngle: angle,
//                 Position: [link.X, link.Y, link.H]
//             });
//             // callback && callback()
//         } else {
//             StreetViewData.linkImagesData.push({
//                 type: type,
//                 name: data.StationItems[0].Station.Address,
//                 NavigationAngle: angle
//             });
//         }
//         callback && callback()
//     }
//
//     // 立德街景交叉口数据
//     getJoinsData(StreetViewData, callback) {
//         this.sgworld.core.xhr({
//             url: this.StreetScapeOption.getInitImageJointsById.replace('{id}', StreetViewData.getImageTileID),
//             type: 'get',
//             dataType: 'json',
//             success: data => {
//                 if (data.Junction) {
//                     this.pervJoinsID = StreetViewData.getImageTileID
//                     callback && callback(data.Junction || [])
//                 } else {
//                     this.sgworld.core.xhr({
//                         url: this.StreetScapeOption.getInitImageJointsById.replace('{id}', this.pervJoinsID),
//                         type: 'get',
//                         dataType: 'json',
//                         success: data => {
//                             if (data.Junction) {
//                                 callback && callback(data.Junction || [])
//                             } else {
//                                 layer.msg(data.Message);
//                             }
//                         }
//                     })
//                 }
//             }
//         })
//     }
//
//     selectJoinsCallBack() {
//         this.getJoinsData(this.StreetView.StreetViewData, join => {
//             let btn = []
//             let linkImagesData = []
//             let btnFun = {}
//             join.forEach((item, index) => {
//                 btn.push(item.RoadName)
//                 let data = {
//                     ImageID: item.StationID,
//                     NavigationAngle: item.Angle - 180,
//                     Position: [item.X, item.Y, item.H]
//                 }
//                 let btnFunEvent = (layerindex) => {
//                     layer.close(layerindex);
//                     this.getImageInfo(data.ImageID, () => {
//                         this.StreetView.MoveToLinkImage(data)
//                     })
//                 }
//
//                 if (!index) {
//                     btnFun['yes'] = btnFunEvent
//                 } else {
//                     btnFun['btn' + (index + 1)] = btnFunEvent
//                 }
//                 linkImagesData.push(data);
//             })
//
//             layer.msg('请选择道路', {
//                 time: 10000,
//                 btn: btn,
//                 ...btnFun
//             });
//         })
//     }
//
//     setImageDataCallback(StreetViewData, data) {
//         if (data && data.Sizes) {
//             let size = data.Sizes[0]
//             let width = size.Width
//             let height = size.Height
//             StreetViewData.row = Math.ceil(height / 512)
//             StreetViewData.col = Math.ceil(width / 512)
//             StreetViewData.maxWidth = width
//             StreetViewData.maxHeight = height
//         }
//     }
//
//     getImageInfo(id, callback) {
//         this.sgworld.core.xhr({
//             url: this.streetSphere_data.getImageInfo + id,
//             type: 'get',
//             dataType: 'json',
//             success: data => {
//                 this.setImageDataCallback(this.StreetView.StreetViewData, data)
//                 callback && callback()
//             }
//         })
//     }
//
//     getImageDataByPosition(position, callback) {
//         let url = this.StreetView.getInitImageByPositionURL(position)
//         this.sgworld.core.xhr({
//             url: url,
//             type: 'get',
//             dataType: 'json',
//             success: data => {
//                 callback && callback(data)
//             }
//         })
//     }
//
//
//
//     //设置街景接口
//     setStreetScapeUrl() {
//         this.StreetScapeOption = {
//             type: 'lide',
//             getInitImageByPosition: '/Image3DIndexService/GetStationByCoord/?x={lon}&tolerance=0%2E0005&type=4&y={lat}',
//             getInitImageJointsById: '/Image3DIndexService/GetStationJoints/?direction=1&StationID={id}',
//             getInitImageSequenceById: '/Image3DIndexService/GetStationSequence/?StationID={id}',
//             getInitImageById: '',
//             getSecondImageById: '',
//             getInitImageByPositionCallBack: this.setStreetViewData.bind(this),
//             getImageInfoByIdCallBack: this.setStreetViewData.bind(this),
//             selectJoinsCallBack: this.selectJoinsCallBack.bind(this),
//             setImageDataCallback: this.setImageDataCallback.bind(this)
//         }
//         this.StreetScapeOption.getInitImageByPosition = this.streetSphere_data.StreetUrl + this.StreetScapeOption.getInitImageByPosition;
//         this.StreetScapeOption.getInitImageJointsById = this.streetSphere_data.StreetUrl + this.StreetScapeOption.getInitImageJointsById;
//         this.StreetScapeOption.getInitImageSequenceById = this.streetSphere_data.StreetUrl + this.StreetScapeOption.getInitImageSequenceById;
//         this.StreetScapeOption.getInitImageById = this.streetSphere_data.getImageRootUrl + '{id}' + this.streetSphere_data.getFirstImageDir;
//         this.StreetScapeOption.getSecondImageById = this.streetSphere_data.getImageRootUrl + '{id}' + this.streetSphere_data.getSecondImageDir;
//         this.StreetScapeOption.getImageInfo = this.streetSphere_data.getImageInfo;
//     }
//
//     // 初始化街景
//     init() {
//         this.exit()
//         this.sgworld.camera.stop(); //取消飞行状态
//
//         this.StreetView = this.sgworld.analysis.StreetViewOpen({
//             lon: this.streetSphere_data.lon,
//             lat: this.streetSphere_data.lat
//         }, this.StreetScapeOption, () => {
//             //创建滑动按钮
//             this.createSlider();
//             ///创建退出按钮
//             this.createExitButton();
//         });
//         this.setOpacity(this.streetscape_alpha);
//     }
//
//     //退出街景
//     exit() {
//         if (this.StreetView) {
//             this.StreetView.exit();
//             this.StreetView = null;
//             this.sliderContainer && this.sliderContainer.remove();
//             //移除退出按钮
//             this.exitContainer && this.exitContainer.remove();
//             this.sliderContainer = this.exitContainer = undefined
//         }
//     }
//
//     // 跳转位置
//     changePosition(position) {
//         this.streetSphere_data.lon = position.lon;
//         this.streetSphere_data.lat = position.lat;
//         this.StreetView.StreetViewData.isTwoTextures = false;
//         this.StreetView.StreetViewData.isThreeTextures = false;
//         this.StreetScapeOption.flyTime = 1;
//         this.init();
//     }
//
//     // 更新服务
//     changeServer(StreetUrl) {
//         this.streetSphere_data.StreetUrl = StreetUrl;
//         this.streetSphere_data.getImageRootUrl = StreetUrl + "/Image3DResourceService/GetImageTile/?ImageID=";
//         this.streetSphere_data.getImageInfo = StreetUrl + '/Image3DResourceService/GetImageInfo/?ImageID=';
//         this.StreetView.StreetViewData.isTwoTextures = false;
//         this.StreetView.StreetViewData.isThreeTextures = false;
//         this.setStreetScapeUrl();
//         this.StreetScapeOption.flyTime = 1;
//         this.init();
//     }
//
//     // 下一步
//     nextStep() {
//         let linkImageData = this.StreetView.StreetViewData.linkImagesData.find(item => {
//             return item.type === "next"
//         })
//         linkImageData && this.StreetView.MoveToLinkImage(linkImageData);
//     }
//
//     // 上一步
//     prevStep() {
//         let linkImageData = this.StreetView.StreetViewData.linkImagesData.find(item => {
//             return item.type === "prev"
//         })
//         linkImageData && this.StreetView.MoveToLinkImage(linkImageData);
//     }
//
//     //设置街景球透明度
//     setOpacity(alpha) {
//         this.streetscape_alpha = alpha
//         if (this.StreetView) {
//             this.StreetView.setOpacity(alpha);
//         }
//     }
//
//     //创建透明度滑动条
//     createSlider() {
//         var div = '<div id="streetScapeSlider" style="position: absolute;top: 0;left: 0;z-index: 99;width:218px;margin: 45px 100px 10px;"><div id="opacity-streetScape"></div></div>';
//         $(document.body).append(div);
//         this.sliderContainer = $('#streetScapeSlider');
//         layui.use('slider', () => {
//             var slider = layui.slider;
//             slider.render({
//                 elem: '#opacity-streetScape',
//                 theme: '#1E9FFF',
//                 min: 0 //最小值
//                 ,
//                 max: 100 //最大值
//                 ,
//                 value: this.streetscape_alpha * 100,
//                 change: (value) => {
//                     this.setOpacity(value / 100);
//                 }
//             });
//         });
//     }
//
//     //创建退出按钮
//     createExitButton() {
//         let div = '<div id="streetScapeExitButton" style="position: absolute;top: 0;left: 0;z-index: 99;margin:20px;"><button type="button" class="layui-btn layui-btn-normal">退出</button></div>';
//         $(document.body).append(div);
//         this.exitContainer = $('#streetScapeExitButton');
//         this.exitContainer.click(() => {
//             this.exit()
//         })
//     }
// }