egovamap 0.17.18 → 0.17.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,462 +1,462 @@
1
- var scene = null;
2
-
3
- function checkServerURL(url,callback){
4
- var proxyList = url.split(";");
5
- if(proxyList.length<=1){
6
- eUrban.global.mmsServerURL = url;
7
- callback();
8
- return ;
9
- }
10
- var params = {isLoad:false};
11
- for(var i in proxyList){
12
- checkProxy(proxyList[i],params,callback);
13
- }
14
- }
15
-
16
- function checkProxy(proxyUrl,params,callback) {
17
- var img = new Image();
18
- if(proxyUrl.indexOf("http://")<0){
19
- proxyUrl = window.location.origin+"/"+proxyUrl;
20
- }
21
- img.src = proxyUrl + '/symbol/1_1_1.png';
22
- img.onload = function (e1) {
23
- if(!params.isLoad){
24
- params.isLoad = true;
25
- eUrban.global.mmsServerURL = proxyUrl;
26
- callback();
27
- }
28
- img = null;
29
- };
30
- }
31
-
32
- var EGovaMMSMap = function($container, pScene, prefix, mmsParams, mapConfig, mmsType) {
33
- var that = this;
34
- scene = pScene;
35
- var parentScene = "parentScene" || "MMSMap";
36
- var msgPrefix = prefix || "MMS";
37
- var proxyURL = eUrban.global.rootPath + "/home/gis/proxy.htm";
38
-
39
- that.mmsVisible = false;
40
- that.mmsLoaded = false;
41
- that.isLoading = false;
42
- that.mapConfig = mapConfig;
43
- that.mmsType = mmsType;
44
- that.$mmsMapFrame = null;
45
- that.mmsMapContainer = null;
46
- that.mapContainer = null;
47
- that.curPointX = null;
48
- that.curPointY = null;
49
- that.mmsMapContainer = $container.getElementsByClassName(".mmsmap-container")[0];
50
-
51
- if (that.mmsMapContainer) {
52
- var mmsMapHTML = '<iframe class="mmsmap-iframe" webkitAllowFullScreen="true" mozallowfullscreen="true" allowFullScreen="true"></iframe>';
53
- var element = document.createElement("div");
54
- element.classList.add("mmsmap-container");
55
- element.innerHTML = mmsMapHTML;
56
- $container.appendChild(element);
57
- that.mmsMapContainer = element;
58
- }
59
- that.$mmsMapFrame = that.mmsMapContainer.getElementsByClassName("mmsmap-iframe")[0];
60
- that.mapContainer = $container.getElementsByClassName("emap-container")[0];
61
-
62
- that.init = function() {
63
- if (!that.isLoading) {
64
- that.isLoading = true;
65
- if(that.mmsType == 1) {
66
- checkServerURL(mmsParams.mmsServerURL, function () {
67
- var mmsAPIURL = eUrban.global.mmsServerURL + '/library/mms/api/MMSAPI.js';
68
- var mmsCCDPicURL = eUrban.global.mmsServerURL + '/mmspic/Image';
69
- var mmsSymbolURL = eUrban.global.mmsServerURL + '/symbol';
70
- var mmsWsdlURL = eUrban.global.mmsServerURL + '/ws/MMSInspector?wsdl';
71
-
72
- var mmsConfig = { panoID : "eGovaMMS",
73
- mmsApiUrl: mmsAPIURL, mmsServerUrl : eUrban.global.mmsServerURL,
74
- mmsPicUrl : mmsCCDPicURL, mmsSymbolUrl : mmsSymbolURL,
75
- mediaRootUrl : mmsParams.mmsMediaURL,
76
- mmsWsdlUrl: mmsWsdlURL,
77
- proxyUrl : proxyURL };
78
- var prefix = 'msgPrefix=' + msgPrefix + '&parentScene=' + parentScene + '&proxyUrl=' + proxyURL;
79
- for (var item in mmsConfig) {
80
- prefix += "&" + item + "=" + mmsConfig[item];
81
- }
82
- if(typeof mmsParams.simpleMode !== 'undefined') {
83
- prefix = prefix + '&simpleMode=true';
84
- }
85
-
86
- //违建系统无底部工具栏
87
- var pageUrl = window.document.URL;
88
- var bottom = 20;
89
- if(pageUrl.indexOf('ibmain')>0) {
90
- bottom = -10;
91
- }
92
-
93
- var mmsMapUrl = eUrban.global.rootPath + "/library/urban/egovamap/mms.jsp?" + prefix;
94
- if(msgPrefix == 'mappage0' || msgPrefix == 'egovamappage0_gis'){
95
- //仅主页上的实景设置控件样式
96
- mmsMapUrl += '&navi={visible:true,left:20,top:60}&toolbar={visible:true,top:60}&footer={visible:true,bottom:' + bottom + '}&toolBarDefine=104,105';
97
- }else{
98
- mmsMapUrl += '&navi={visible:true,left:10,top:20}&toolbar={visible:true,top:20}&toolBarDefine=104,105';
99
- }
100
- var encodeUrl = encodeURI(mmsMapUrl);
101
- that.$mmsMapFrame.src = encodeUrl;
102
- });
103
- }
104
- else if(that.mmsType == 2) {
105
- //立得实景
106
- var mapHTML = '<div id="desktop-closemms"><div class="desktop-closemms-img"></div><div class="desktop-closemms-tips">关闭实景</div></div>';
107
- $container.appendChild(mapHTML);
108
-
109
- that.desktopclosemms = $container.find("#desktop-closemms");
110
- if(that.desktopclosemms !== 'undefined'){
111
- that.desktopclosemms.click(function(e){
112
- that.desktopclosemms[0].style.display = 'none';
113
- that.closeMMS();
114
- });
115
- }
116
- }
117
- }
118
-
119
- if(that.mapContainer) {
120
- that.mapContainer.onmouseover = function(evt) {
121
- if (that.mmsVisible) {
122
- that.mapContainer.style.height = '300px';
123
- }
124
- };
125
- that.mapContainer.onmouseout = function(evt) {
126
- if (that.mmsVisible) {
127
- that.mapContainer.style.height = '140px';
128
- }
129
- };
130
- }
131
-
132
- //绑定地图事件
133
- that.bindEvent("setMMSEyePreviewCallback", that.setMMSEyePreview); //地图眼睛拖动预览回调
134
- that.bindEvent("setMMSEyePositionCallback", that.setMMSEyePosition); //地图眼睛点击回调
135
- that.bindEvent("setMMSEyePositionAngleCallback", that.setMMSAngle); //地图眼睛转动回调
136
- //that.bindEvent("identifyPartCallback", that.identifyPart); //地图点击部件回调
137
- // 实景加载完毕后
138
- that.bindEvent("mmsLoadedCallback", that.onMmsLoaded);
139
- that.bindEvent("mmsAirPanoLocateCallback", that.mmsAirPanoLocateByID);
140
- that.bindEvent("mmsAirPanoCompareCallback", that.setAirPanoCompare);
141
- }
142
- /* 绑定事件 */
143
- that.bindEvent = function(msgId, msgHandler, stopOnTop) {
144
- if (scene == null)
145
- return;
146
- scene.on(msgPrefix + ":" + msgId, msgHandler, parentScene, stopOnTop);
147
- }
148
- /* 触发事件 */
149
- that.fireEvent = function(msgId, msgData, stopOnTop) {
150
- if (scene == null)
151
- return;
152
- scene.fire(msgPrefix + ":" + msgId, msgData, parentScene, stopOnTop);
153
- }
154
-
155
- that.dispatchSceneEvent = function(msgId, msgData) {
156
- if (scene == null)
157
- return;
158
- scene.fire(msgPrefix + ":" + msgId, { args : msgData }, parentScene, false);
159
- }
160
-
161
- that.onMmsLoaded = function() {
162
- that.mmsLoaded = true;
163
- console.info("----------mmsLoadedCallback");
164
- //绑定实景事件
165
- that.bindEvent('setPanoEyePreviewCallback', that.setGISEyePreview); // 实景预览回调
166
- that.bindEvent('getlocateroutemmspointsCallback', that.drawTrackLine); // 实景定位回调
167
- that.bindEvent('getlocatemmspointsCallback', that.setGISEyePosition); // 实景位置更新回调
168
- that.bindEvent('panorotateCallback', that.setGISEyeAngle); // 实景转动回调
169
- that.bindEvent('partClickCallback', that.panoPartClick); //地图点击部件回调
170
-
171
- // that.bindEvent('eventClickCallback', eventClick);
172
- that.bindEvent('mmsClosePanoCallback', that.closeMMS);
173
- that.bindEvent('mmsFullScreenCallback', that.fullScreenMMS);
174
- // flex
175
- that.bindEvent('mmsInitCompleteCallback', that.mmsFlexInitComplete);
176
- }
177
-
178
- /**
179
- * 实景窗口关闭
180
- */
181
- that.closeMMS = function(evt) {
182
- that.mmsVisible = false;
183
- that.mmsMapContainer.style.height = '0';
184
-
185
- if(that.mapContainer) {
186
- that.mapContainer.style.height = '100%';
187
- that.mapContainer.style.width = '100%';
188
- that.mapContainer.style.bottom = '0px';
189
- that.mapContainer.style.right = '0px';
190
- that.mapContainer.style.backgroundColor = '#ffffff';
191
-
192
- that.dispatchSceneEvent('clearGraphic', [ "MMSFeature" ]);
193
- that.dispatchSceneEvent('clearGraphic', [ "", "mms" ]);
194
-
195
- //恢复地图工具条
196
- var param = {visible:true};
197
- that.fireEvent("changeControlParam", {args:["toolbar", param]});
198
- if (that.mapConfig && that.mapConfig.params) {
199
- var params = that.mapConfig.params;
200
- if (params["geocode"]) {
201
- var type ="geocode";
202
- that.fireEvent("changeControlParam", {args:[type, param]});
203
- }
204
- }
205
-
206
- //触发实景弹框关闭事件
207
- that.fireEvent("closeMMSPanel", {args:[]});
208
-
209
- //地图重新缩放定位到原来的中心点
210
- setTimeout(center, 800);
211
- function center() {
212
- if(that.curPointX != null && that.curPointY != null){
213
- that.dispatchSceneEvent('centerAndZoom', [that.curPointX, that.curPointY]);
214
- }
215
- }
216
- }
217
- }
218
-
219
- /**
220
- * 实景窗口最大化
221
- */
222
- that.fullScreenMMS = function() {
223
- if(that.mapContainer) {
224
- that.mapContainer.style.width = '333px';
225
- that.mapContainer.style.height = '140px';
226
- }
227
- }
228
-
229
- that.showMMSView = function() {
230
- if(that.mmsMapContainer) {
231
- that.mmsVisible = true;
232
- that.mmsMapContainer.style.height = '100%';
233
- that.mmsMapContainer.style.display = 'block';
234
- }
235
- }
236
-
237
- /** *****************************GIS地图调用MMS地图************************ */
238
- /**
239
- * 实景预览
240
- *
241
- * @param res
242
- */
243
- that.setMMSEyePreview = function(evt) {
244
- var res = evt.args;
245
- var pos = res[0];
246
- var x = pos.x;
247
- var y = pos.y;
248
- // EGovaMMSAPI.setMMSEyePreview(x, y);
249
- if(that.mmsType == 1){
250
- that.dispatchSceneEvent('setPanoEyePreview', [ x, y ]);
251
- }else if(that.mmsType == 2){
252
- that.$mmsMapFrame.contentWindow.trueVision.showVisionByLngLat(x, y);
253
- }
254
- }
255
-
256
- /**
257
- * 响应地图点击,触发实景定位
258
- *
259
- * @param res
260
- */
261
- that.setMMSEyePosition = function(evt) {
262
- if(that.mmsType == 1){
263
- if(!that.mmsLoaded) {
264
- console.error("----------mmsLoaded:failed!");
265
- return;
266
- }
267
- }
268
- var res = evt.args;
269
- if (!that.mmsVisible) {// 初次定位时调整布局
270
- that.mmsVisible = true;
271
- that.mmsMapContainer.style.height = '100%';
272
- // that.mmsMapContainer.style.top = "0px";
273
- // that.mmsMapContainer.style.bottom = "0px";
274
- that.mmsMapContainer.style.display = 'block';
275
-
276
- if(that.mapContainer) {
277
- that.mapContainer.style.height = '140px';
278
- that.mapContainer.style.width = '333px';
279
- that.mapContainer.style.backgroundColor = '#F2EFE9';
280
- that.mapContainer.style.bottom = '30px'; //msgPrefix == 'mappage0' ? '57px' : '25px';
281
- that.mapContainer.style.right = '1px';
282
- //隐藏地图工具条
283
- that.fireEvent("changeControlParam", {args:["toolbar", {visible:true,items:'zoomin,zoomout,pan,fullextent,mmseye'}]});
284
- that.fireEvent("changeControlParam", {args:["geocode", {visible:false}]});
285
- //触发实景弹框已打开事件
286
- that.fireEvent("openedMMSPanel", {args:[]});
287
- }
288
- }
289
- var pos = res[0];
290
- var x = pos.x;
291
- var y = pos.y;
292
- // EGovaMMSAPI.mmsPanoLocateByXY(x, y);
293
- if(that.mmsType == 1){
294
- that.dispatchSceneEvent('mmsPanoLocateByXY', [ x, y ]); //mmsAirPanoLocate
295
- }else if(that.mmsType == 2){
296
- that.desktopclosemms[0].style.display = 'block';
297
- if(!that.mmsLoaded){
298
- that.$mmsMapFrame.src = eUrban.global.rootPath +"/other/mms/truemap/TrueVisionDMI/trueVision/index.htm?x=" + x + "&y=" + y;
299
- that.mmsLoaded = true;
300
- }else{
301
- that.$mmsMapFrame.contentWindow.truevision.showVisionByLngLat(x, y);
302
- }
303
- }
304
- }
305
-
306
- /**
307
- * 响应地图眼睛拖动事件,触发实景旋转
308
- *
309
- * @param res
310
- */
311
- that.setMMSAngle = function(evt) {
312
- if(!that.mmsLoaded) {
313
- return;
314
- }
315
- var res = evt.args;
316
- var angle = res[0].angle;
317
- // EGovaMMSAPI.rotationView(angle);
318
- that.dispatchSceneEvent('rotatePanoView', [ angle ]);
319
- }
320
-
321
- /**
322
- * i查询
323
- *
324
- * @param res
325
- */
326
- that.identifyPart = function(evt) {
327
- if(!that.mmsLoaded) {
328
- return;
329
- }
330
- var res = evt.args;
331
- // EGovaMMSAPI.mmsPartLocateByObjectCode(res[0], res[1].x,
332
- // res[1].y);
333
- that.dispatchSceneEvent('mmsPartLocateByObjectCode', [ res[0], res[1].x, res[1].y ]);
334
- }
335
-
336
- /** *******************************MMS地图调用GIS地图********************************** */
337
- /**
338
- * 响应实景组件预览事件,触发地图事件显示实景缩略图
339
- *
340
- * @param res
341
- */
342
- that.setGISEyePreview = function(evt) {
343
- that.dispatchSceneEvent('setMMSEyePreview', evt.args);
344
- }
345
-
346
- /**
347
- * 响应实景组件定位后,在地图绘制实景轨迹线
348
- *
349
- * @param res
350
- */
351
- that.drawTrackLine = function(evt) {
352
- var points = evt.args;
353
- var length = points.length;
354
- var feature = [], trackPoint;
355
- for ( var i = 0; i < length; i++) {
356
- trackPoint = {};
357
- trackPoint.x = Number(points[i].x);
358
- trackPoint.y = Number(points[i].y);
359
- feature.push(trackPoint);
360
- }
361
- var style = { "type" : "esriSMS", "style" : "esriSMSCircle", "color" : [ 255, 0, 0, 255 ], "size" : 8 };
362
- that.dispatchSceneEvent('clearAllGraphics', []);
363
- // that.dispatchSceneEvent('centerAndZoom', [matchPoint.x,
364
- // matchPoint.y, 5]);
365
- that.dispatchSceneEvent('locateFeatureByCoords', [ feature, 'polygon', 'MMSFeature', style, style, false ]);
366
- }
367
-
368
- /**
369
- * 响应实景点变换后,更新地图
370
- *
371
- * @param res
372
- */
373
- that.setGISEyePosition = function(evt) {
374
- var data = evt.args;
375
- that.curPointX = data[0].x;
376
- that.curPointY = data[0].y;
377
- that.dispatchSceneEvent('clearGraphic', [ 'labelFeature' ]);
378
- that.dispatchSceneEvent('setMMSEyePosition', [ data[0].x, data[0].y, data[1] ]);
379
- // dispatchSceneEvent('centerAndZoom', [data[0].x, data[0].y], 5);
380
- setTimeout(center, 800);
381
- function center() {
382
- that.dispatchSceneEvent('centerAndZoom', [ data[0].x, data[0].y ], 5);
383
- }
384
- }
385
-
386
- /**
387
- * 响应实景旋转,触发地图眼睛转动
388
- *
389
- * @param res
390
- */
391
- that.setGISEyeAngle = function(evt) {
392
- var data = evt.args;
393
- if (!data.length) {
394
- data = [ data ];
395
- }
396
- that.dispatchSceneEvent('setMMSEyePosition', data);
397
- }
398
-
399
- /**
400
- * 实景中点击部件标注,触发地图高亮显示
401
- *
402
- * @param res
403
- */
404
- that.panoPartClick = function(evt) {
405
- var data = evt.args;
406
- var layerID = data[0];
407
- var x = data[1];
408
- var y = data[2];
409
- var uniqueCode = data[3];
410
- var label = [ { x : x, y : y } ];
411
- var style = { "type" : "esriSMS", "style" : "esriSMSCircle", "color" : [ 0, 0, 255, 255 ], "size" : 12 };
412
- that.dispatchSceneEvent('clearGraphic', [ 'labelFeature' ]);
413
- that.dispatchSceneEvent('locateFeatureByCoords', [ label, 'polygon', 'labelFeature', style, style, true ]);
414
- that.dispatchSceneEvent('showMapLayers', [ 10634, 5, 0 ]);// 需与GIS统一layerid
415
- }
416
-
417
- /**
418
- * 实景flex客户端初始化后回调函数
419
- *
420
- * @param res
421
- */
422
- that.mmsFlexInitComplete = function(returnStr) {
423
- // alert("mmsInitCompleteCallback");
424
- }
425
-
426
- that.locateEvent = function(eventID, x, y, z) {
427
- that.dispatchSceneEvent('locateEvent',[eventID, x, y, z]);
428
- }
429
-
430
- that.mmsAirPanoLocateByID = function(evt) {
431
- var res = evt.args;
432
- if (!that.mmsVisible) {// 初次定位时调整布局
433
- that.mmsVisible = true;
434
- that.mmsMapContainer.style.height = '100%';
435
- // that.mmsMapContainer.style.top = "0px";
436
- // that.mmsMapContainer.style.bottom = "0px";
437
- that.mmsMapContainer.style.display = 'block';
438
-
439
- if(that.mapContainer) {
440
- that.mapContainer.style.height = '140px';
441
- that.mapContainer.style.width = '333px';
442
- that.mapContainer.style.backgroundColor = '#F2EFE9';
443
- that.mapContainer.style.bottom = '30px'; //msgPrefix == 'mappage0' ? '57px' :
444
- that.mapContainer.style.right = '1px';
445
- //隐藏地图工具条
446
- that.fireEvent("changeControlParam", {args:["toolbar", {visible:true,items:'zoomin,zoomout,pan,fullextent,mmseye'}]});
447
- that.fireEvent("changeControlParam", {args:["geocode", {visible:false}]});
448
- }
449
- }
450
- var pointID = res[0];
451
- // EGovaMMSAPI.mmsAirPanoLocateByID(pointID);
452
- that.dispatchSceneEvent('mmsAirPanoLocateByID', [pointID]);
453
- }
454
-
455
- that.setAirPanoCompare = function(evt) {
456
- var callback = evt.args[0];
457
- that.dispatchSceneEvent('setAirPanoCompareCallback', [callback]);
458
- }
459
-
460
- that.init();
461
- }
1
+ var scene = null;
2
+
3
+ function checkServerURL(url,callback){
4
+ var proxyList = url.split(";");
5
+ if(proxyList.length<=1){
6
+ eUrban.global.mmsServerURL = url;
7
+ callback();
8
+ return ;
9
+ }
10
+ var params = {isLoad:false};
11
+ for(var i in proxyList){
12
+ checkProxy(proxyList[i],params,callback);
13
+ }
14
+ }
15
+
16
+ function checkProxy(proxyUrl,params,callback) {
17
+ var img = new Image();
18
+ if(proxyUrl.indexOf("http://")<0){
19
+ proxyUrl = window.location.origin+"/"+proxyUrl;
20
+ }
21
+ img.src = proxyUrl + '/symbol/1_1_1.png';
22
+ img.onload = function (e1) {
23
+ if(!params.isLoad){
24
+ params.isLoad = true;
25
+ eUrban.global.mmsServerURL = proxyUrl;
26
+ callback();
27
+ }
28
+ img = null;
29
+ };
30
+ }
31
+
32
+ var EGovaMMSMap = function($container, pScene, prefix, mmsParams, mapConfig, mmsType) {
33
+ var that = this;
34
+ scene = pScene;
35
+ var parentScene = "parentScene" || "MMSMap";
36
+ var msgPrefix = prefix || "MMS";
37
+ var proxyURL = eUrban.global.rootPath + "/home/gis/proxy.htm";
38
+
39
+ that.mmsVisible = false;
40
+ that.mmsLoaded = false;
41
+ that.isLoading = false;
42
+ that.mapConfig = mapConfig;
43
+ that.mmsType = mmsType;
44
+ that.$mmsMapFrame = null;
45
+ that.mmsMapContainer = null;
46
+ that.mapContainer = null;
47
+ that.curPointX = null;
48
+ that.curPointY = null;
49
+ that.mmsMapContainer = $container.getElementsByClassName(".mmsmap-container")[0];
50
+
51
+ if (that.mmsMapContainer) {
52
+ var mmsMapHTML = '<iframe class="mmsmap-iframe" webkitAllowFullScreen="true" mozallowfullscreen="true" allowFullScreen="true"></iframe>';
53
+ var element = document.createElement("div");
54
+ element.classList.add("mmsmap-container");
55
+ element.innerHTML = mmsMapHTML;
56
+ $container.appendChild(element);
57
+ that.mmsMapContainer = element;
58
+ }
59
+ that.$mmsMapFrame = that.mmsMapContainer.getElementsByClassName("mmsmap-iframe")[0];
60
+ that.mapContainer = $container.getElementsByClassName("emap-container")[0];
61
+
62
+ that.init = function() {
63
+ if (!that.isLoading) {
64
+ that.isLoading = true;
65
+ if(that.mmsType == 1) {
66
+ checkServerURL(mmsParams.mmsServerURL, function () {
67
+ var mmsAPIURL = eUrban.global.mmsServerURL + '/library/mms/api/MMSAPI.js';
68
+ var mmsCCDPicURL = eUrban.global.mmsServerURL + '/mmspic/Image';
69
+ var mmsSymbolURL = eUrban.global.mmsServerURL + '/symbol';
70
+ var mmsWsdlURL = eUrban.global.mmsServerURL + '/ws/MMSInspector?wsdl';
71
+
72
+ var mmsConfig = { panoID : "eGovaMMS",
73
+ mmsApiUrl: mmsAPIURL, mmsServerUrl : eUrban.global.mmsServerURL,
74
+ mmsPicUrl : mmsCCDPicURL, mmsSymbolUrl : mmsSymbolURL,
75
+ mediaRootUrl : mmsParams.mmsMediaURL,
76
+ mmsWsdlUrl: mmsWsdlURL,
77
+ proxyUrl : proxyURL };
78
+ var prefix = 'msgPrefix=' + msgPrefix + '&parentScene=' + parentScene + '&proxyUrl=' + proxyURL;
79
+ for (var item in mmsConfig) {
80
+ prefix += "&" + item + "=" + mmsConfig[item];
81
+ }
82
+ if(typeof mmsParams.simpleMode !== 'undefined') {
83
+ prefix = prefix + '&simpleMode=true';
84
+ }
85
+
86
+ //违建系统无底部工具栏
87
+ var pageUrl = window.document.URL;
88
+ var bottom = 20;
89
+ if(pageUrl.indexOf('ibmain')>0) {
90
+ bottom = -10;
91
+ }
92
+
93
+ var mmsMapUrl = eUrban.global.rootPath + "/library/urban/egovamap/mms.jsp?" + prefix;
94
+ if(msgPrefix == 'mappage0' || msgPrefix == 'egovamappage0_gis'){
95
+ //仅主页上的实景设置控件样式
96
+ mmsMapUrl += '&navi={visible:true,left:20,top:60}&toolbar={visible:true,top:60}&footer={visible:true,bottom:' + bottom + '}&toolBarDefine=104,105';
97
+ }else{
98
+ mmsMapUrl += '&navi={visible:true,left:10,top:20}&toolbar={visible:true,top:20}&toolBarDefine=104,105';
99
+ }
100
+ var encodeUrl = encodeURI(mmsMapUrl);
101
+ that.$mmsMapFrame.src = encodeUrl;
102
+ });
103
+ }
104
+ else if(that.mmsType == 2) {
105
+ //立得实景
106
+ var mapHTML = '<div id="desktop-closemms"><div class="desktop-closemms-img"></div><div class="desktop-closemms-tips">关闭实景</div></div>';
107
+ $container.appendChild(mapHTML);
108
+
109
+ that.desktopclosemms = $container.find("#desktop-closemms");
110
+ if(that.desktopclosemms !== 'undefined'){
111
+ that.desktopclosemms.click(function(e){
112
+ that.desktopclosemms[0].style.display = 'none';
113
+ that.closeMMS();
114
+ });
115
+ }
116
+ }
117
+ }
118
+
119
+ if(that.mapContainer) {
120
+ that.mapContainer.onmouseover = function(evt) {
121
+ if (that.mmsVisible) {
122
+ that.mapContainer.style.height = '300px';
123
+ }
124
+ };
125
+ that.mapContainer.onmouseout = function(evt) {
126
+ if (that.mmsVisible) {
127
+ that.mapContainer.style.height = '140px';
128
+ }
129
+ };
130
+ }
131
+
132
+ //绑定地图事件
133
+ that.bindEvent("setMMSEyePreviewCallback", that.setMMSEyePreview); //地图眼睛拖动预览回调
134
+ that.bindEvent("setMMSEyePositionCallback", that.setMMSEyePosition); //地图眼睛点击回调
135
+ that.bindEvent("setMMSEyePositionAngleCallback", that.setMMSAngle); //地图眼睛转动回调
136
+ //that.bindEvent("identifyPartCallback", that.identifyPart); //地图点击部件回调
137
+ // 实景加载完毕后
138
+ that.bindEvent("mmsLoadedCallback", that.onMmsLoaded);
139
+ that.bindEvent("mmsAirPanoLocateCallback", that.mmsAirPanoLocateByID);
140
+ that.bindEvent("mmsAirPanoCompareCallback", that.setAirPanoCompare);
141
+ }
142
+ /* 绑定事件 */
143
+ that.bindEvent = function(msgId, msgHandler, stopOnTop) {
144
+ if (scene == null)
145
+ return;
146
+ scene.on(msgPrefix + ":" + msgId, msgHandler, parentScene, stopOnTop);
147
+ }
148
+ /* 触发事件 */
149
+ that.fireEvent = function(msgId, msgData, stopOnTop) {
150
+ if (scene == null)
151
+ return;
152
+ scene.fire(msgPrefix + ":" + msgId, msgData, parentScene, stopOnTop);
153
+ }
154
+
155
+ that.dispatchSceneEvent = function(msgId, msgData) {
156
+ if (scene == null)
157
+ return;
158
+ scene.fire(msgPrefix + ":" + msgId, { args : msgData }, parentScene, false);
159
+ }
160
+
161
+ that.onMmsLoaded = function() {
162
+ that.mmsLoaded = true;
163
+ console.info("----------mmsLoadedCallback");
164
+ //绑定实景事件
165
+ that.bindEvent('setPanoEyePreviewCallback', that.setGISEyePreview); // 实景预览回调
166
+ that.bindEvent('getlocateroutemmspointsCallback', that.drawTrackLine); // 实景定位回调
167
+ that.bindEvent('getlocatemmspointsCallback', that.setGISEyePosition); // 实景位置更新回调
168
+ that.bindEvent('panorotateCallback', that.setGISEyeAngle); // 实景转动回调
169
+ that.bindEvent('partClickCallback', that.panoPartClick); //地图点击部件回调
170
+
171
+ // that.bindEvent('eventClickCallback', eventClick);
172
+ that.bindEvent('mmsClosePanoCallback', that.closeMMS);
173
+ that.bindEvent('mmsFullScreenCallback', that.fullScreenMMS);
174
+ // flex
175
+ that.bindEvent('mmsInitCompleteCallback', that.mmsFlexInitComplete);
176
+ }
177
+
178
+ /**
179
+ * 实景窗口关闭
180
+ */
181
+ that.closeMMS = function(evt) {
182
+ that.mmsVisible = false;
183
+ that.mmsMapContainer.style.height = '0';
184
+
185
+ if(that.mapContainer) {
186
+ that.mapContainer.style.height = '100%';
187
+ that.mapContainer.style.width = '100%';
188
+ that.mapContainer.style.bottom = '0px';
189
+ that.mapContainer.style.right = '0px';
190
+ that.mapContainer.style.backgroundColor = '#ffffff';
191
+
192
+ that.dispatchSceneEvent('clearGraphic', [ "MMSFeature" ]);
193
+ that.dispatchSceneEvent('clearGraphic', [ "", "mms" ]);
194
+
195
+ //恢复地图工具条
196
+ var param = {visible:true};
197
+ that.fireEvent("changeControlParam", {args:["toolbar", param]});
198
+ if (that.mapConfig && that.mapConfig.params) {
199
+ var params = that.mapConfig.params;
200
+ if (params["geocode"]) {
201
+ var type ="geocode";
202
+ that.fireEvent("changeControlParam", {args:[type, param]});
203
+ }
204
+ }
205
+
206
+ //触发实景弹框关闭事件
207
+ that.fireEvent("closeMMSPanel", {args:[]});
208
+
209
+ //地图重新缩放定位到原来的中心点
210
+ setTimeout(center, 800);
211
+ function center() {
212
+ if(that.curPointX != null && that.curPointY != null){
213
+ that.dispatchSceneEvent('centerAndZoom', [that.curPointX, that.curPointY]);
214
+ }
215
+ }
216
+ }
217
+ }
218
+
219
+ /**
220
+ * 实景窗口最大化
221
+ */
222
+ that.fullScreenMMS = function() {
223
+ if(that.mapContainer) {
224
+ that.mapContainer.style.width = '333px';
225
+ that.mapContainer.style.height = '140px';
226
+ }
227
+ }
228
+
229
+ that.showMMSView = function() {
230
+ if(that.mmsMapContainer) {
231
+ that.mmsVisible = true;
232
+ that.mmsMapContainer.style.height = '100%';
233
+ that.mmsMapContainer.style.display = 'block';
234
+ }
235
+ }
236
+
237
+ /** *****************************GIS地图调用MMS地图************************ */
238
+ /**
239
+ * 实景预览
240
+ *
241
+ * @param res
242
+ */
243
+ that.setMMSEyePreview = function(evt) {
244
+ var res = evt.args;
245
+ var pos = res[0];
246
+ var x = pos.x;
247
+ var y = pos.y;
248
+ // EGovaMMSAPI.setMMSEyePreview(x, y);
249
+ if(that.mmsType == 1){
250
+ that.dispatchSceneEvent('setPanoEyePreview', [ x, y ]);
251
+ }else if(that.mmsType == 2){
252
+ that.$mmsMapFrame.contentWindow.trueVision.showVisionByLngLat(x, y);
253
+ }
254
+ }
255
+
256
+ /**
257
+ * 响应地图点击,触发实景定位
258
+ *
259
+ * @param res
260
+ */
261
+ that.setMMSEyePosition = function(evt) {
262
+ if(that.mmsType == 1){
263
+ if(!that.mmsLoaded) {
264
+ console.error("----------mmsLoaded:failed!");
265
+ return;
266
+ }
267
+ }
268
+ var res = evt.args;
269
+ if (!that.mmsVisible) {// 初次定位时调整布局
270
+ that.mmsVisible = true;
271
+ that.mmsMapContainer.style.height = '100%';
272
+ // that.mmsMapContainer.style.top = "0px";
273
+ // that.mmsMapContainer.style.bottom = "0px";
274
+ that.mmsMapContainer.style.display = 'block';
275
+
276
+ if(that.mapContainer) {
277
+ that.mapContainer.style.height = '140px';
278
+ that.mapContainer.style.width = '333px';
279
+ that.mapContainer.style.backgroundColor = '#F2EFE9';
280
+ that.mapContainer.style.bottom = '30px'; //msgPrefix == 'mappage0' ? '57px' : '25px';
281
+ that.mapContainer.style.right = '1px';
282
+ //隐藏地图工具条
283
+ that.fireEvent("changeControlParam", {args:["toolbar", {visible:true,items:'zoomin,zoomout,pan,fullextent,mmseye'}]});
284
+ that.fireEvent("changeControlParam", {args:["geocode", {visible:false}]});
285
+ //触发实景弹框已打开事件
286
+ that.fireEvent("openedMMSPanel", {args:[]});
287
+ }
288
+ }
289
+ var pos = res[0];
290
+ var x = pos.x;
291
+ var y = pos.y;
292
+ // EGovaMMSAPI.mmsPanoLocateByXY(x, y);
293
+ if(that.mmsType == 1){
294
+ that.dispatchSceneEvent('mmsPanoLocateByXY', [ x, y ]); //mmsAirPanoLocate
295
+ }else if(that.mmsType == 2){
296
+ that.desktopclosemms[0].style.display = 'block';
297
+ if(!that.mmsLoaded){
298
+ that.$mmsMapFrame.src = eUrban.global.rootPath +"/other/mms/truemap/TrueVisionDMI/trueVision/index.htm?x=" + x + "&y=" + y;
299
+ that.mmsLoaded = true;
300
+ }else{
301
+ that.$mmsMapFrame.contentWindow.truevision.showVisionByLngLat(x, y);
302
+ }
303
+ }
304
+ }
305
+
306
+ /**
307
+ * 响应地图眼睛拖动事件,触发实景旋转
308
+ *
309
+ * @param res
310
+ */
311
+ that.setMMSAngle = function(evt) {
312
+ if(!that.mmsLoaded) {
313
+ return;
314
+ }
315
+ var res = evt.args;
316
+ var angle = res[0].angle;
317
+ // EGovaMMSAPI.rotationView(angle);
318
+ that.dispatchSceneEvent('rotatePanoView', [ angle ]);
319
+ }
320
+
321
+ /**
322
+ * i查询
323
+ *
324
+ * @param res
325
+ */
326
+ that.identifyPart = function(evt) {
327
+ if(!that.mmsLoaded) {
328
+ return;
329
+ }
330
+ var res = evt.args;
331
+ // EGovaMMSAPI.mmsPartLocateByObjectCode(res[0], res[1].x,
332
+ // res[1].y);
333
+ that.dispatchSceneEvent('mmsPartLocateByObjectCode', [ res[0], res[1].x, res[1].y ]);
334
+ }
335
+
336
+ /** *******************************MMS地图调用GIS地图********************************** */
337
+ /**
338
+ * 响应实景组件预览事件,触发地图事件显示实景缩略图
339
+ *
340
+ * @param res
341
+ */
342
+ that.setGISEyePreview = function(evt) {
343
+ that.dispatchSceneEvent('setMMSEyePreview', evt.args);
344
+ }
345
+
346
+ /**
347
+ * 响应实景组件定位后,在地图绘制实景轨迹线
348
+ *
349
+ * @param res
350
+ */
351
+ that.drawTrackLine = function(evt) {
352
+ var points = evt.args;
353
+ var length = points.length;
354
+ var feature = [], trackPoint;
355
+ for ( var i = 0; i < length; i++) {
356
+ trackPoint = {};
357
+ trackPoint.x = Number(points[i].x);
358
+ trackPoint.y = Number(points[i].y);
359
+ feature.push(trackPoint);
360
+ }
361
+ var style = { "type" : "esriSMS", "style" : "esriSMSCircle", "color" : [ 255, 0, 0, 255 ], "size" : 8 };
362
+ that.dispatchSceneEvent('clearAllGraphics', []);
363
+ // that.dispatchSceneEvent('centerAndZoom', [matchPoint.x,
364
+ // matchPoint.y, 5]);
365
+ that.dispatchSceneEvent('locateFeatureByCoords', [ feature, 'polygon', 'MMSFeature', style, style, false ]);
366
+ }
367
+
368
+ /**
369
+ * 响应实景点变换后,更新地图
370
+ *
371
+ * @param res
372
+ */
373
+ that.setGISEyePosition = function(evt) {
374
+ var data = evt.args;
375
+ that.curPointX = data[0].x;
376
+ that.curPointY = data[0].y;
377
+ that.dispatchSceneEvent('clearGraphic', [ 'labelFeature' ]);
378
+ that.dispatchSceneEvent('setMMSEyePosition', [ data[0].x, data[0].y, data[1] ]);
379
+ // dispatchSceneEvent('centerAndZoom', [data[0].x, data[0].y], 5);
380
+ setTimeout(center, 800);
381
+ function center() {
382
+ that.dispatchSceneEvent('centerAndZoom', [ data[0].x, data[0].y ], 5);
383
+ }
384
+ }
385
+
386
+ /**
387
+ * 响应实景旋转,触发地图眼睛转动
388
+ *
389
+ * @param res
390
+ */
391
+ that.setGISEyeAngle = function(evt) {
392
+ var data = evt.args;
393
+ if (!data.length) {
394
+ data = [ data ];
395
+ }
396
+ that.dispatchSceneEvent('setMMSEyePosition', data);
397
+ }
398
+
399
+ /**
400
+ * 实景中点击部件标注,触发地图高亮显示
401
+ *
402
+ * @param res
403
+ */
404
+ that.panoPartClick = function(evt) {
405
+ var data = evt.args;
406
+ var layerID = data[0];
407
+ var x = data[1];
408
+ var y = data[2];
409
+ var uniqueCode = data[3];
410
+ var label = [ { x : x, y : y } ];
411
+ var style = { "type" : "esriSMS", "style" : "esriSMSCircle", "color" : [ 0, 0, 255, 255 ], "size" : 12 };
412
+ that.dispatchSceneEvent('clearGraphic', [ 'labelFeature' ]);
413
+ that.dispatchSceneEvent('locateFeatureByCoords', [ label, 'polygon', 'labelFeature', style, style, true ]);
414
+ that.dispatchSceneEvent('showMapLayers', [ 10634, 5, 0 ]);// 需与GIS统一layerid
415
+ }
416
+
417
+ /**
418
+ * 实景flex客户端初始化后回调函数
419
+ *
420
+ * @param res
421
+ */
422
+ that.mmsFlexInitComplete = function(returnStr) {
423
+ // alert("mmsInitCompleteCallback");
424
+ }
425
+
426
+ that.locateEvent = function(eventID, x, y, z) {
427
+ that.dispatchSceneEvent('locateEvent',[eventID, x, y, z]);
428
+ }
429
+
430
+ that.mmsAirPanoLocateByID = function(evt) {
431
+ var res = evt.args;
432
+ if (!that.mmsVisible) {// 初次定位时调整布局
433
+ that.mmsVisible = true;
434
+ that.mmsMapContainer.style.height = '100%';
435
+ // that.mmsMapContainer.style.top = "0px";
436
+ // that.mmsMapContainer.style.bottom = "0px";
437
+ that.mmsMapContainer.style.display = 'block';
438
+
439
+ if(that.mapContainer) {
440
+ that.mapContainer.style.height = '140px';
441
+ that.mapContainer.style.width = '333px';
442
+ that.mapContainer.style.backgroundColor = '#F2EFE9';
443
+ that.mapContainer.style.bottom = '30px'; //msgPrefix == 'mappage0' ? '57px' :
444
+ that.mapContainer.style.right = '1px';
445
+ //隐藏地图工具条
446
+ that.fireEvent("changeControlParam", {args:["toolbar", {visible:true,items:'zoomin,zoomout,pan,fullextent,mmseye'}]});
447
+ that.fireEvent("changeControlParam", {args:["geocode", {visible:false}]});
448
+ }
449
+ }
450
+ var pointID = res[0];
451
+ // EGovaMMSAPI.mmsAirPanoLocateByID(pointID);
452
+ that.dispatchSceneEvent('mmsAirPanoLocateByID', [pointID]);
453
+ }
454
+
455
+ that.setAirPanoCompare = function(evt) {
456
+ var callback = evt.args[0];
457
+ that.dispatchSceneEvent('setAirPanoCompareCallback', [callback]);
458
+ }
459
+
460
+ that.init();
461
+ }
462
462
  export default EGovaMMSMap;