egovamap 0.17.20 → 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,1289 +1,1289 @@
1
- import EGovaMMSMap from "./egovamms";
2
- import MapUtils from './mapUtils';
3
- var scene = null;
4
-
5
- function getCookie(name){
6
- var strCookie = window.document.cookie;
7
- var arrCookie = strCookie.split("; ");
8
- for(var i=0; i<arrCookie.length; i++){
9
- var arr = arrCookie[i].split("=");
10
- if(arr[0]==name) return arr[1];
11
- }
12
- return null;
13
- };
14
- function setCookie(name,value){
15
- window.document.cookie = name+"="+value;
16
- }
17
-
18
- function checkGisServerURL(url,callback){
19
- if(!url) return;
20
-
21
- var cookieUrl = getCookie("gisUrl");
22
- var gisProxyList = url.split(";");
23
- cookieUrl&&gisProxyList.push(cookieUrl);
24
- if(gisProxyList.length<=1){
25
- if(url.indexOf("http")!=0){
26
- url = window.location.origin + url;
27
- }
28
- callback(url);
29
- return ;
30
- }
31
- var params = {isLoad:false};
32
- for(var i in gisProxyList){
33
- if(gisProxyList.hasOwnProperty(i)){
34
- if(gisProxyList[i].indexOf("http")!=0){
35
- gisProxyList[i] = window.location.origin + url;
36
- }
37
- checkGISProxy(gisProxyList[i],params,callback);
38
- }
39
- }
40
- }
41
-
42
- function checkGISProxy(proxyUrl,params,callback) {
43
- var img = new Image();
44
- img.src = proxyUrl + '/symbol/default.png';
45
- img.onload = function (e1) {
46
- if(!params.isLoad){
47
- params.isLoad = true;
48
- setCookie("gisUrl",proxyUrl);
49
- callback(proxyUrl);
50
- }
51
- img = null;
52
- };
53
- }
54
-
55
- var EGovaGISMap = function ($container, pScene, prefix, gisParams, mapConfig,context) {
56
- var that = this;
57
- scene = pScene;
58
- var parentScene = pScene.pageId || "parentScene";
59
- var msgPrefix = prefix || "gismappage";
60
- var mmsMap = null;
61
- that.gisVisible = false;
62
- that.gisLoaded = false;
63
- that.isLoading = false;
64
-
65
- that.$gisMapFrame = null;
66
- that.gisMapContainer = null;
67
-
68
- that.gisMapContainer = $container.getElementsByClassName("emap-container")[0];
69
- if (!that.gisMapContainer) {
70
-
71
- var mapHTML = '<iframe class="emap-iframe"></iframe>';
72
- var element = document.createElement("div");
73
- element.classList.add("emap-container");
74
- element.innerHTML = mapHTML;
75
- $container.appendChild(element);
76
- that.gisMapContainer = element;
77
- }
78
-
79
- that.$gisMapFrame = that.gisMapContainer.getElementsByClassName("emap-iframe")[0];
80
- that.onMapLoadedHandlers = [];
81
-
82
- that.onMapLoaded = function () {
83
- that.isLoading = false;
84
- that.gisLoaded = true;
85
- if(context.mapCenterFlag){
86
- if(context.mapCenterFlag == '1'){
87
- if(context.coordinateX && context.coordinateY){
88
- that.centerAndZoom(context.coordinateX, context.coordinateY, 4);
89
- }
90
- } else if(context.mapCenterFlag == '2'){
91
- if(context.coordinateX && context.coordinateY){
92
- that.centerAndZoom(context.coordinateX, context.coordinateY, 1);
93
- }
94
- if(context.humanLayerUsageID && context.regionCode){
95
- var zoom = gisParams && gisParams.maskZoom == true;
96
- var style={"type":"esriSFS","style":"esriSFSSolid","color": [100,100,255,125],"outline":{"type":"esriSLS","style":"esriSLSSolid","color":[255,0,0,255],"width":1}};
97
- var pos = {visible:true,top:95,right:127};
98
- if(mapConfig && mapConfig.maskPos){
99
- pos = MapUtils.deepClones({}, pos, mapConfig.maskPos);
100
- }
101
- that.addMaskLayer(context.humanLayerUsageID, context.humanLayerKeyFieldName, context.regionCode, style, zoom, pos);
102
- }
103
- } else if(context.mapCenterFlag == '3'){
104
- if(context.coordinateX && context.coordinateY){
105
- that.centerAndZoom(context.coordinateX, context.coordinateY, 1);
106
- }
107
- if(context.humanLayerUsageID && context.regionCode){
108
- var zoom = gisParams && gisParams.maskZoom == false;
109
- var style={"type":"esriSFS","style":"esriSFSSolid","color": [100,100,255,0],"outline":{"type":"esriSLS","style":"esriSLSSolid","color":[255,0,0,255],"width":3}};
110
- var pos = {visible:true,top:95,right:127};
111
- if(mapConfig && mapConfig.maskPos){
112
- pos = MapUtils.deepClones({}, pos, mapConfig.maskPos);
113
- }
114
- that.addMaskLayer(context.humanLayerUsageID, context.humanLayerKeyFieldName, context.regionCode, style, zoom, pos);
115
- }
116
- }
117
- }
118
- for(var i=0,len=that.onMapLoadedHandlers.length; i<len; i++){
119
- that.onMapLoadedHandlers[i]();
120
- }
121
- }
122
-
123
- that.init = function () {
124
- if (!that.gisLoaded && !that.isLoading) {
125
- that.isLoading = true;
126
- checkGisServerURL(context.gisServerURL, function (gisurl) {
127
- var bust = (new Date()).getTime();
128
- var gisServerURL = context.gisServerURL = gisurl;
129
- var gisProxyURL = context.gisServerURL + '/home/gis/proxy.htm';
130
- var misServerURL = context.rootPath;
131
- var url = context.rootPath+context.assetsPath+"/map.html?parentScene=" + parentScene + "&msgPrefix=" + msgPrefix + "&bust="+bust
132
- + "&serverURL=" + gisServerURL + "&proxyURL=" + gisProxyURL + "&misURL="+misServerURL+"&humanID=" + context.humanID;
133
- if (mapConfig != undefined && mapConfig.params != undefined) {
134
- for (var item in mapConfig.params) {
135
- url += "&" + item + "=" +encodeURIComponent(mapConfig.params[item]);
136
- }
137
- }
138
- if(context.mapZoomRange){
139
- var mapZoomRanges = context.mapZoomRange.split(",");
140
- if(mapZoomRanges.length == 2 ){
141
- url += "&minlevel=" +mapZoomRanges[0]+"&maxlevel="+mapZoomRanges[1]
142
- }
143
- }
144
- that.$gisMapFrame.src = url;
145
- that.$gisMapFrame.onload = function(){
146
- if(!this.contentDocument.documentElement.getElementsByTagName("head").item(0).outerHTML.includes("/library/egovagis/map/map.js")) {
147
- var mainScript = this.contentDocument.createElement("script");
148
- mainScript.setAttribute("type", "text/javascript");
149
- mainScript.setAttribute("src", gisServerURL + "/library/egovagis/map/map.js");
150
- this.contentDocument.documentElement.getElementsByTagName("head").item(0).appendChild(mainScript);
151
- }
152
- }
153
- });
154
- try {
155
- //如果启用了实景功能需要注册实景监听
156
- if (context.mmsEnabled != undefined && that.gisMapContainer) {
157
- var mmsEnabled = Number(context.mmsEnabled);
158
- if(mmsEnabled > 0){
159
- mmsMap = new EGovaMMSMap($container, scene, msgPrefix, context.mmsParams, mapConfig, mmsEnabled);
160
- }
161
- }
162
- } catch (e) {
163
- console.error(e.message);
164
- }
165
- }
166
-
167
- //初始化时不显示地图
168
- that.closeMap();
169
- // 监听地图加载完成的事件
170
- scene.on(msgPrefix + ":mapLoadedCallback", that.onMapLoaded, parentScene, false);
171
- }
172
-
173
- /**
174
- * 二维地图显示
175
- *
176
- * @param res
177
- */
178
- that.openMap = function (evt) {
179
- if (!that.gisVisible) {// 初次定位时调整布局
180
- if (!that.gisLoaded && !that.isLoading) {
181
- that.isLoading = true;
182
- checkGisServerURL(context.gisServerURL, function () {
183
- var gisServerURL = context.gisServerURL;
184
- var gisProxyURL = context.gisServerURL + '/home/gis/proxy.htm';
185
- var misServerURL = context.rootPath;
186
- var url = context.rootPath +context.assetsPath + "/map.html?parentScene=" + parentScene + "&msgPrefix=" + msgPrefix
187
- + "&serverURL=" + gisServerURL + "&proxyURL=" + gisProxyURL +"&misURL="+misServerURL+ "&humanID=" + context.humanID;
188
- if (mapConfig != undefined && mapConfig.params != undefined) {
189
- for (var item in mapConfig.params) {
190
- url += "&" + item + "=" + mapConfig.params[item];
191
- }
192
- }
193
- that.$gisMapFrame.src = url;
194
- that.$gisMapFrame.onload = function(){
195
- if(!this.contentDocument.documentElement.getElementsByTagName("head").item(0).outerHTML.includes("/library/egovagis/map/map.js")) {
196
- var mainScript = this.contentDocument.createElement("script");
197
- mainScript.setAttribute("type", "text/javascript");
198
- mainScript.setAttribute("src", gisServerURL + "/library/egovagis/map/map.js");
199
- this.contentDocument.documentElement.getElementsByTagName("head").item(0).appendChild(mainScript);
200
- }
201
- }
202
- });
203
- try {
204
- //如果启用了实景功能需要注册实景监听,msgPrefix+'old',为了兼容以前的GIS实景结合
205
- if (context.mmsEnabled != undefined && context.mmsEnabled == "1" && that.gisMapContainer) {
206
- mmsMap = new EGovaMMSMap($container, scene, msgPrefix + 'old', context.mmsParams, mapConfig);
207
- }
208
- } catch (e) {
209
- alert(e.message);
210
- }
211
- }
212
-
213
- that.gisMapContainer.style.height = '100%';
214
- that.gisMapContainer.style.display = 'block';
215
- that.gisVisible = true;
216
- }
217
- }
218
-
219
- /**
220
- * 二维地图关闭
221
- */
222
- that.closeMap = function (evt) {
223
- that.gisMapContainer.style.display = 'block';
224
- that.gisMapContainer.style.height = '0';
225
- that.gisVisible = false;
226
- }
227
-
228
-
229
- /* 绑定事件 */
230
- that.bindEvent = function(msgId, msgHandler, stopOnTop) {
231
- if (scene == null)
232
- return;
233
- scene.on(msgPrefix + ":" + msgId, msgHandler, parentScene, stopOnTop);
234
- }
235
- /* 触发事件 */
236
- that.fireEvent = function(msgId, msgData, stopOnTop) {
237
- if (scene == null)
238
- return;
239
- scene.fire(msgPrefix + ":" + msgId, msgData, parentScene, stopOnTop);
240
- }
241
- /* 移除监听 */
242
- that.removeEventBind = function(msgId, stopOnTop) {
243
- if (scene == null)
244
- return;
245
- scene.remove(msgPrefix + ":" + msgId, parentScene, stopOnTop);
246
- }
247
-
248
- /* 切换到平移工具 */
249
- that.panMap = function() {
250
- if (scene == null)
251
- return;
252
- scene.fire(msgPrefix + ":panMap", parentScene);
253
- }
254
- /* 缩放到指定范围 */
255
- that.zoomToExtent = function(minX, minY, maxX, maxY) {
256
- if (scene == null)
257
- return;
258
- scene.fire((msgPrefix + ":zoomToExtent"), { args : [ Number(minX), Number(minY), Number(maxX), Number(maxY) ] }, parentScene,
259
- false);
260
- }
261
- /* 缩放到指定中心点和级别 */
262
- that.centerAndZoom = function(x, y, level) {
263
- if (scene == null)
264
- return;
265
- scene.fire((msgPrefix + ":centerAndZoom"), { args : [ x, y, level ] }, parentScene, false);
266
- }
267
- /* 缩放到全图范围 */
268
- that.zoomToFullExtent = function() {
269
- if (scene == null)
270
- return;
271
- scene.fire((msgPrefix + ":fullExtent"), { args : [] }, parentScene, false);
272
- }
273
- /* 绘制图形 */
274
- that.drawGraphic = function(graphic, zoom, clickCallback) {
275
- if (scene == null)
276
- return;
277
- if (graphic.geometry instanceof Array) {
278
- scene.fire(msgPrefix + ":locateFeatureByCoords", { args : [ graphic.geometry, graphic.type, graphic.id, graphic.style,
279
- graphic.hstyle, zoom, graphic.keyField, graphic.labelField, graphic.labelStyle, graphic.colorNumber, graphic.renderCanvas, graphic.singleSelected, graphic.options, graphic.layerTag] }, parentScene);
280
- } else {
281
- // scene.fire(msgPrefix+":locateFeatureByCoord",
282
- // {args:[{"geometry":graphic.geometry},graphic.type,graphic.id,graphic.style,graphic.hstyle,zoom]},parentScene);
283
- scene.fire(msgPrefix + ":locateFeatureByCoords", { args : [ [ graphic.geometry ], graphic.type, graphic.id, graphic.style,
284
- graphic.hstyle, zoom, graphic.keyField, graphic.labelField, graphic.labelStyle, graphic.colorNumber, graphic.renderCanvas, graphic.singleSelected, graphic.options, graphic.layerTag] }, parentScene);
285
- }
286
- that.removeEventBind("locateFeatureByIDsCallback");
287
- if (clickCallback != undefined) {
288
- that.bindEvent("locateFeatureByIDsCallback", function(evt) {
289
- clickCallback(evt.args);
290
- });
291
- }
292
- }
293
-
294
- /*添加WMS服务图层*/
295
- that.showWMSLayer = function(layerUsageID, IDs, keyField, geometry, where) {
296
- if (scene == null)
297
- return;
298
- scene.fire(msgPrefix + ":showWMSLayer", { args : [ layerUsageID, IDs, keyField, geometry, where ] }, parentScene, false);
299
- }
300
-
301
- /*清除WMS服务图层*/
302
- that.removeWMSLayer = function(serviceID) {
303
- if (scene == null)
304
- return;
305
- scene.fire(msgPrefix + ":removeWMSLayer", { args : [ serviceID ] }, parentScene, false);
306
- }
307
-
308
-
309
- /*根据要素坐标定位显示要素*/
310
- that.locateFeatureByCoords=function(geometries, type, ID, style, hStyle, zoom, keyFiled, labelField, labelStyle, randomColor, renderCanvas, singleSelected, options, layerTag){
311
- if (scene == null)
312
- return;
313
- scene.fire((msgPrefix + ":locateFeatureByCoords"), { args : [geometries, type, ID, style, hStyle, zoom, keyFiled, labelField, labelStyle, randomColor, renderCanvas, singleSelected, options, layerTag] }, parentScene, false);
314
- }
315
- /* 清除指定图形 */
316
- that.clearGraphic = function(id, tag) {
317
- if (scene == null)
318
- return;
319
- if (typeof id != "string") {
320
- id = id.join(",");
321
- }
322
- if (tag) {
323
- id = null;
324
- }
325
- scene.fire((msgPrefix + ":clearGraphic"), { args : [ id, tag ] }, parentScene, false);
326
- }
327
- /* 清除全部图形 */
328
- that.clearAllGraphics = function(id) {
329
- if (scene == null)
330
- return;
331
- scene.fire((msgPrefix + ":clearAllGraphics"), { args : [] }, parentScene, false);
332
- }
333
- /* 在地图上标注 */
334
- that.pointSelect = function(symbolType, zoomFalg, callback) {
335
- if (scene == null)
336
- return;
337
-
338
- // 移除监听
339
- scene.remove(msgPrefix + ":pointSelectCallback", parentScene, false);
340
-
341
- if (zoomFalg == undefined)
342
- zoomFalg = true;
343
- if (callback) {
344
- // 定义回调
345
- scene.on(msgPrefix + ":pointSelectCallback", function(evt) {
346
- // 移除监听
347
- scene.remove(msgPrefix + ":pointSelectCallback", parentScene, false);
348
- callback(evt.args);
349
- }, parentScene, false);
350
- }
351
- scene.fire(msgPrefix + ":pointSelect", { args : [ symbolType, zoomFalg ] }, parentScene, false);
352
- }
353
- /* 获取图形外部矩形 */
354
- that.getFeaturesExtent = function(features, callback) {
355
- if (scene == null)
356
- return;
357
-
358
- // 移除监听
359
- scene.remove(msgPrefix + ":getFeaturesExtentCallback", parentScene, false);
360
-
361
- scene.on(msgPrefix + ":getFeaturesExtentCallback", function(evt) {
362
- // 移除监听
363
- scene.remove(msgPrefix + ":getFeaturesExtentCallback", parentScene, false);
364
- callback(evt.args);
365
- }, parentScene, false);
366
- scene.fire((msgPrefix + ":getFeaturesExtent"), { args : features }, parentScene, false);
367
- }
368
-
369
- /* 获取可见图层 */
370
- that.getVisibleLayerIds = function (callback) {
371
- // 移除监听
372
- scene.remove(msgPrefix + ":getVisibleLayerIdsCallback", parentScene, false);
373
-
374
- scene.on(msgPrefix + ":getVisibleLayerIdsCallback", function(evt) {
375
- // 移除监听
376
- scene.remove(msgPrefix + ":getVisibleLayerIdsCallback", parentScene, false);
377
- callback(evt.args);
378
- }, parentScene, false);
379
- scene.fire((msgPrefix + ":getVisibleLayerIds"), {args: []}, parentScene, false);
380
- }
381
-
382
- that.identifyInfoWindow = function (usageID,keyValue,content,size) {
383
- if (scene == null)
384
- return;
385
- scene.fire((msgPrefix + ":identifyInfoWindow"), {args: [usageID,keyValue,content,size]}, parentScene, false);
386
-
387
- }
388
- /* 更改工具条参数 */
389
- that.changeControlParam = function (id,param) {
390
- if (scene == null)
391
- return;
392
- scene.fire((msgPrefix + ":changeControlParam"), {args: [id,param]}, parentScene, false);
393
-
394
- }
395
- /* 图层过滤显示 */
396
- that.setLayerDef = function (phyLayerID,layerDef) {
397
- if (scene == null)
398
- return;
399
- scene.fire((msgPrefix + ":setLayerDef"), {args: [phyLayerID,layerDef]}, parentScene, false);
400
-
401
- }
402
- that.setLayerColorDef=function(phyLayerIDs,colorDefs){
403
- if(scene == null)
404
- return;
405
- scene.fire((msgPrefix + ":setLayerColorDef"), {args: [phyLayerIDs,colorDefs]}, parentScene, false);
406
- }
407
-
408
- /* 显示图层树 */
409
- that.showLayerTree = function(/* humanID, mapID */openTree) {
410
- if (scene == null)
411
- return;
412
- /*
413
- * var data = null; scene.fire(msgPrefix + ":showLayerTree", {args :
414
- * [data, humanID, mapID]}, parentScene);
415
- */
416
- if (openTree == undefined || arguments.length > 1)
417
- openTree = true;
418
- scene.fire(msgPrefix + ":showLayerTree", { args : [ openTree ] }, parentScene);
419
- }
420
- /* I查询 */
421
- that.identify = function(type, humanID, mapID, options) {
422
- if (scene == null)
423
- return;
424
- scene.fire(msgPrefix + ":identify", { args : [ type, humanID, mapID ] }, parentScene);
425
-
426
- // By hth 2021/4/6: 如果传入了回调函数,则绑定执行回调函数的监听事件
427
- var cb = options && options.cb
428
- if (cb) {
429
- // 移除监听
430
- that.removeEventBind("identifySelectCallback");
431
- if (cb !== undefined && typeof cb === 'function') {
432
- that.bindEvent("identifySelectCallback", function(evt) {
433
- cb(evt.args);
434
- });
435
- }
436
- }
437
- }
438
- /* 地理编码查询 */
439
- that.geoCode = function(searchStr, callback) {
440
- if (scene == null)
441
- return;
442
- if (callback) {
443
- // 移除监听
444
- that.removeEventBind("geoCodeCallback");
445
- if (callback != undefined) {
446
- that.bindEvent("geoCodeCallback", function(evt) {
447
- callback(evt.args);
448
- });
449
- }
450
- }
451
- scene.fire(msgPrefix + ":geoCode", { args : [ searchStr ] }, parentScene);
452
- }
453
- /* 逆地理编码查询 */
454
- that.getAddressByXY = function(x, y, searchStr, radius, callback) {
455
- if (scene == null)
456
- return;
457
- if(callback) {
458
- that.removeEventBind("getAddressByXYCallback");
459
- that.bindEvent("getAddressByXYCallback", function (evt) {
460
- callback(evt.args);
461
- });
462
- }
463
- scene.fire(msgPrefix + ":getAddressByXY", { args : [ x, y, searchStr, radius ] }, parentScene);
464
- }
465
- /* 根据坐标获取单元网格 */
466
- that.getCellNameByPosXY = function(x, y, gridType) {
467
- if (scene == null)
468
- return;
469
- var args = [];
470
- var callback = null;
471
- for (var i = 0; i < arguments.length; i++) {
472
- var arg = arguments[i];
473
- if (i == arguments.length-1 && typeof(arg) == "function"){
474
- callback = arg;
475
- continue;
476
- }
477
- args.push(arg);
478
- }
479
- if (callback != null) {
480
- // 移除监听
481
- that.removeEventBind("getCellNameByPosXYCallback");
482
-
483
- function _getCellNameByPosXYCallback(evt) {
484
- that.removeEventBind("getCellNameByPosXYCallback");
485
- callback(evt.args);
486
- }
487
- that.bindEvent("getCellNameByPosXYCallback", _getCellNameByPosXYCallback);
488
- }
489
- that.fireEvent("getCellNameByPosXY", { args : args });
490
- }
491
- /* 根据图层字段定位显示 */
492
- that.locateFeatureByIDs = function (layerID, keyFiled, keyValue, clearMap, style, hStyle, bZoom, randomColor, labelfield, labelstyle, geometry, where, renderCanvas, singleSelected,options,extendProperty,layerTag,outFieldStr,animiteStep,index,clipGeom) {
493
- if (scene == null)
494
- return;
495
- if (bZoom == undefined)
496
- bZoom = false;
497
- scene.fire(msgPrefix + ":locateFeatureByIDs", { args: [layerID, keyValue, keyFiled, clearMap, style, hStyle, bZoom, randomColor, labelfield, labelstyle, geometry, where, renderCanvas, singleSelected ,options,extendProperty,layerTag,outFieldStr,animiteStep,index,clipGeom] },
498
- parentScene);
499
- }
500
- /* 显示案件分布 */
501
- that.showRecListDistribution = function(infoJson, zoom, clickCallback, labelInfo,isShowLegend, symbolUrl, options) {
502
- if (scene == null || infoJson.length == 0)
503
- return;
504
- //如果xy坐标没有值不处理
505
- for(var i=0,len=infoJson.length; i<len; i++){
506
- if(!infoJson[i].coordinateX || infoJson[i].coordinateX == "" || !infoJson[i].coordinateY || infoJson[i].coordinateY == ""){
507
- return;
508
- }
509
- }
510
-
511
- // 移除监听
512
- that.removeEventBind("showRecListDistributionCallback");
513
-
514
- if (clickCallback != undefined) {
515
- that.bindEvent("showRecListDistributionCallback", function(evt) {
516
- clickCallback(evt.args);
517
- });
518
- }
519
- scene.fire((msgPrefix + ":showRecListDistribution"), { args : [ infoJson, zoom, labelInfo,isShowLegend, symbolUrl, options] }, parentScene, false);
520
-
521
- //如果启用了实景功能,同时进行实景定位
522
- if(mmsMap && infoJson.length == 1) {
523
- var recInfo = infoJson[0];
524
- if (mmsMap.mmsLoaded){
525
- if (!mmsMap.mmsVisible) {
526
- // var pos = {x:recInfo.coordinateX, y:recInfo.coordinateY};
527
- // var evt = {args:[pos]};
528
- // mmsMap.setMMSEyePosition(evt);
529
- } else {
530
- mmsMap.locateEvent(recInfo.recID, recInfo.coordinateX, recInfo.coordinateY);
531
- }
532
- }
533
- }
534
- }
535
- /* 显示多个自定义图标 */
536
- that.showMultiObjectCurrentPosition = function (jsonInfo, zoom, bClear, hStyleID, infoStyle, bCanvas, tagName, clickCallback, mouseOverCallBack, clusterOption, hasHover, layerID, mouseOutCallback, options) {
537
- if (scene == null)
538
- return;
539
- // 移除监听
540
- var clickBackName = "showMultiObjectCurrentPositionClick";
541
- var mouseOverBackName = "showMultiObjectCurrentPositionMouseover";
542
- var mouseOutBackName = "showMultiObjectCurrentPositionMouseout";
543
- if (options&&options.callbacksuffix) {
544
- clickBackName += options.callbacksuffix;
545
- mouseOverBackName += options.callbacksuffix;
546
- mouseOutBackName += options.callbacksuffix;
547
- }
548
- that.removeEventBind(clickBackName);
549
- that.removeEventBind(mouseOverBackName);
550
- that.removeEventBind(mouseOutBackName);
551
- if (clickCallback instanceof Function) {
552
- that.bindEvent(clickBackName, function(evt) {
553
- clickCallback(evt.args);
554
- });
555
- }
556
- if (mouseOverCallBack instanceof Function) {
557
- that.bindEvent(mouseOverBackName, function(evt) {
558
- mouseOverCallBack(evt.args);
559
- });
560
- }
561
- if(mouseOutCallback instanceof Function){
562
- that.bindEvent(mouseOutBackName, function(evt) {
563
- mouseOutCallback(evt.args);
564
- });
565
- }
566
- scene.fire((msgPrefix + ":showMultiObjectCurrentPosition"), {args: [jsonInfo, zoom, bClear, hStyleID, infoStyle, bCanvas, tagName, clusterOption, hasHover, layerID, options]}, parentScene, false);
567
- }
568
- /* 显示监督员 */
569
- that.showPatrolCurrentPosition = function (jsonInfo, zoom, bClear, hStyleID, clickCallback) {
570
- if (scene == null)
571
- return;
572
-
573
- var args = Array.prototype.slice.call(arguments);
574
- if (arguments[arguments.length - 1] instanceof Function) {
575
- clickCallback = arguments[arguments.length - 1];
576
- args = args.slice(0, args.length - 1);
577
- }
578
-
579
- if (clickCallback) {
580
- that.removeEventBind("showPatrolCurrentPositionCallback");
581
- that.bindEvent("showPatrolCurrentPositionCallback", function (evt) {
582
- clickCallback(evt.args);
583
- });
584
- }
585
- scene.fire((msgPrefix + ":showPatrolCurrentPosition"), { args: args }, parentScene, false);
586
- }
587
- /* 获取缓冲区 */
588
- that.getBuffer = function (layerID, x, y, radius,getBufferCallback) {
589
- if (scene == null)
590
- return;
591
-
592
- var args = Array.prototype.slice.call(arguments);
593
- if (arguments[arguments.length - 1] instanceof Function) {
594
- getBufferCallback = arguments[arguments.length - 1];
595
- args = args.slice(0, args.length - 1);
596
- }
597
-
598
- if (getBufferCallback) {
599
- that.removeEventBind("getBufferCallback");
600
- that.bindEvent("getBufferCallback", function (evt) {
601
- getBufferCallback(evt.args);
602
- });
603
- }
604
- scene.fire((msgPrefix + ":getBuffer"), {args: args}, parentScene, true);
605
- }
606
- /* 获取多点的缓冲区 */
607
- that.getMultiPointBuffer = function(points, radius){
608
- if (scene == null)
609
- return;
610
- scene.fire((msgPrefix + ":getMultiPointBuffer"), {args: args}, parentScene, true);
611
-
612
- }
613
- /**
614
- * 设置指定图层的样式
615
- * @param id 元素的id
616
- * @param tag 图层的标签
617
- * @param style 图层样式
618
- * @returns
619
- */
620
- that.setGraphicStyle = function(id, tag, style){
621
- if (scene == null)
622
- return;
623
- scene.fire((msgPrefix + ":setGraphicStyle"), {args: args}, parentScene, true);
624
- }
625
- /* 显示监督员责任网格 */
626
- that.showPatrolDutygridCells = function(infoJson, zoom, clickCallback) {
627
- if (scene == null)
628
- return;
629
-
630
- var layerID = infoJson.layerID;
631
- var layerKeyFieldName = infoJson.keyFieldName;
632
- var cellID = infoJson.grids;
633
- var bClearMap = false;
634
- var gridCellStyle = {};
635
- gridCellStyle.style = { type : "esriSFS", style : "esriSFSSolid", color : [ 0, 0, 100, 76 ],
636
- outline : { type : "esriSLS", style : "esriSLSSolid", color : [ 255, 130, 47, 255 ], width : 2 } };
637
- gridCellStyle.hStyle = MapUtils.deepClones(true, {}, gridCellStyle.style);
638
- that.locateFeatureByIDs(layerID, layerKeyFieldName, cellID, bClearMap, gridCellStyle.style, gridCellStyle.hStyle, zoom);
639
- }
640
- /* 标识位置 */
641
- that.markMap = function(projectTypeID, eventTypeID, actPropertyID, displayStyleID, layerID, clickCallback, cellIndexName,point,symbolUrl) {
642
- if (scene == null)
643
- return;
644
-
645
- // 移除监听
646
- that.removeEventBind("markMapCallback");
647
-
648
- //新增了layerID,因此需要兼容原来的4个参数
649
- if (arguments.length == 5 && typeof layerID == "function"){
650
- clickCallback = layerID;
651
- layerID == null;
652
- }
653
-
654
- if (clickCallback != undefined) {
655
- that.bindEvent("markMapCallback", function(evt) {
656
- clickCallback(evt.args);
657
- });
658
- }
659
- scene.fire(msgPrefix + ":markMap", {
660
- args : [ projectTypeID, eventTypeID, actPropertyID, displayStyleID, layerID, cellIndexName,point, symbolUrl]
661
- }, parentScene, false);
662
- }
663
- /* 案件定位 */
664
- that.eventLocate = that.recLocate = function(eventID, defaultMapRange) {
665
- if (scene == null)
666
- return;
667
-
668
- if (defaultMapRange == undefined)
669
- defaultMapRange = 200;
670
- scene.fire(msgPrefix + ":eventLocate", { args : [ eventID, defaultMapRange ] }, parentScene, false);
671
- }
672
- /* 显示特定图层 */
673
- that.showMapLayers = function(layerTag, showLevel, mode, styles) {
674
- if (scene == null)
675
- return;
676
- scene.fire(msgPrefix + ":showMapLayers", { args : [ layerTag, showLevel, mode, styles] }, parentScene, false);
677
- }
678
- /* 显示车辆人员轨迹 */
679
- that.showObjectTrace = function (objectID, symbolType, dateTime, queryCondition, hideControlPanel, symbolPic, optimizeParams, infoCallback, updatePositionCallback, closeCallback, traceDigCallback) {
680
- if (scene == null)
681
- return;
682
-
683
- if (closeCallback) {
684
- that.removeEventBind("TraceManagerCloseCallback");
685
- that.bindEvent("TraceManagerCloseCallback", function () {
686
- closeCallback();
687
- });
688
- }
689
- if (infoCallback) {
690
- that.removeEventBind("showObjectTraceCallback");
691
- that.bindEvent("showObjectTraceCallback", function (evt) {
692
- infoCallback(evt && evt.args);
693
- });
694
- }
695
- if (updatePositionCallback) {
696
- that.removeEventBind("updatePositionCallback");
697
- that.bindEvent("updatePositionCallback", function (evt) {
698
- updatePositionCallback(evt && evt.args);
699
- });
700
- }
701
- if (traceDigCallback) {
702
- that.removeEventBind("getPatrolTraceDigCallback");
703
- that.bindEvent("getPatrolTraceDigCallback", function (evt) {
704
- traceDigCallback(evt && evt.args);
705
- });
706
- }
707
- /*if (context.sysConfig['PATROL_POS_WRITE_TO_FILE']) {
708
- if (queryCondition) {
709
- queryCondition = $.extend({}, queryCondition, { 'resourcetype': 2 });
710
- } else {
711
- queryCondition = { 'resourcetype': 2 };
712
- }
713
- }*/
714
- scene.fire(msgPrefix + ":showObjectTrace", { args: [objectID, symbolType, dateTime, queryCondition, hideControlPanel, symbolPic, optimizeParams] }, parentScene);
715
- }
716
-
717
- /*跳转轨迹位置*/
718
- that.updatePositionByTime =function(time){
719
- if (scene == null)
720
- return;
721
- scene.fire(msgPrefix + ":updatePositionByTime", { args: [time] }, parentScene);
722
- }
723
-
724
- /**
725
- *轨迹开始播放/暂停
726
- **/
727
- that.playObjectTrace = function (speed,doNotChangeState) {
728
- scene.fire(msgPrefix + ":playObjectTrace", { args: [speed,doNotChangeState] },
729
- parentScene);
730
- }
731
-
732
- /**
733
- *轨迹停止
734
- **/
735
- that.stopObjectTrace = function(){
736
- scene.fire(msgPrefix + ":stopObjectTrace", { args: [] },
737
- parentScene);
738
- }
739
-
740
- /**
741
- *更新轨迹播放速度
742
- **/
743
- that.updatePlaySpeed = function(value){
744
- scene.fire(msgPrefix + ":updatePlaySpeed", { args: [value] },
745
- parentScene);
746
- }
747
-
748
- /**
749
- *停止绘制要素
750
- **/
751
- that.stopDraw = function(){
752
- scene.fire(msgPrefix + ":stopDraw", { args: [] },
753
- parentScene);
754
- }
755
-
756
- /**
757
- *等值面生成
758
- **/
759
- that.isobands = function(attrarry,xarry,yarry,breaks,breakcolors,cellwidth,boundary,hascelllabel,labelcolor,callback, options){
760
- scene.fire(msgPrefix + ":isobands", { args: [attrarry,xarry,yarry,breaks,breakcolors,cellwidth,boundary,hascelllabel,labelcolor,callback, options] },
761
- parentScene);
762
- }
763
-
764
- //by ysj,2020-06-02
765
- that.checkObjectTraceItem = function (type,boolean) {
766
- scene.fire(msgPrefix + ":checkObjectTraceItem", { args: [type,boolean] },
767
- parentScene);
768
- }
769
-
770
- /* 显示车辆人员轨迹热力的接口*/
771
- that.showTraceHeatMap = function(objectID, symbolType,starttime,endtime,queryCondition,hidePanel) {
772
- if (scene == null)
773
- return;
774
- scene.fire(msgPrefix + ":showTraceHeatMap", { args: [objectID, symbolType,starttime,endtime,queryCondition,hidePanel] }, parentScene);
775
- };
776
-
777
- /*添加车辆或人员轨迹*/
778
- that.addObjectTrace = function(jsonInfo,symbolType,clear,showControlPanel){
779
- if (scene == null)
780
- return;
781
- scene.fire(msgPrefix + ":addObjectTrace", {args: [jsonInfo, symbolType, clear, showControlPanel]},parentScene);
782
- }
783
- /* 显示第三方上报人员轨迹 */
784
- that.showZzTaskTrace = function(objectID, symbolType, dataTime, queryCondition){
785
- if (scene == null)
786
- return;
787
- scene.fire(msgPrefix + ":showObjectTrace", { args : [ objectID, symbolType, dataTime, queryCondition ]}, parentScene);
788
- }
789
- /* 绘制巡更路线 */
790
- that.showPatrolRoute = function(routeList, type, bClear, editable) {
791
- if (scene == null)
792
- return;
793
- if (!(routeList instanceof Array))
794
- routeList = [ routeList ];
795
- if (bClear == undefined)
796
- bClear = false;
797
- if (editable == undefined)
798
- editable = false;
799
-
800
- var graphics = [];
801
- for ( var i = 0; i < routeList.length; i++) {
802
- var route = routeList[i];
803
- var line = [];
804
- var attributes = [];
805
- var graphic = { id : route.routeID + "", geometry : { paths : [ line ] }, attributes : attributes };
806
- for ( var j = 0; j < route.pointList.length; j++) {
807
- var point = route.pointList[j];
808
- line.push([ point.coordinateX, point.coordinateY ]);
809
- attributes.push(point.pointID);
810
- }
811
- graphics.push(graphic);
812
- }
813
- var style = { color : [ 255, 0, 0, 150 ], width : 2 };
814
- if (type == "dutyGridRoute") {
815
- style.color = [ 0, 0, 255, 150 ]
816
- }
817
- if (type == "patrolRoute") {
818
- style.color = [ 0, 255, 0, 150 ]
819
- }
820
- scene.fire(msgPrefix + ":showPatrolRoute", { args : [ graphics, bClear, style, editable ] }, parentScene);
821
- }
822
- /* 添加巡更路线 */
823
- that.addPatrolRoute = function(addCallback, editCallback) {
824
- if (scene == null)
825
- return;
826
-
827
- // 移除监听
828
- that.removeEventBind("drawPatrolRouteNewCallback");
829
- that.removeEventBind("drawPatrolRouteEditCallback");
830
-
831
- if (addCallback != undefined) {
832
- that.bindEvent("drawPatrolRouteNewCallback", function(evt) {
833
- addCallback(evt.args);
834
- });
835
- }
836
- if (editCallback != undefined) {
837
- that.bindEvent("drawPatrolRouteEditCallback", function(evt) {
838
- editCallback(evt.args);
839
- });
840
- }
841
- var style = { color : [ 255, 0, 0, 150 ], width : 2 };
842
- scene.fire(msgPrefix + ":drawPatrolRoute", { args : [ style ] }, parentScene);
843
- }
844
- /* 删除巡更路线 */
845
- that.deletePatrolRoute = function(callback, withConfirm) {
846
- if (scene == null)
847
- return;
848
-
849
- // 移除监听
850
- that.removeEventBind("deletePatrolRouteCallback");
851
-
852
- if (callback != undefined) {
853
- that.bindEvent("deletePatrolRouteCallback", function(evt) {
854
- callback(evt.args);
855
- });
856
- }
857
- if(withConfirm){
858
- scene.fire(msgPrefix + ":deletePatrolRoute", { args : [false] }, parentScene);
859
- } else {
860
- scene.fire(msgPrefix + ":deletePatrolRoute", { args : [] }, parentScene);
861
- }
862
-
863
- }
864
- /* 获取正在编辑的路线 */
865
- that.getPatrolRouteEdit = function(callback) {
866
- if (scene == null)
867
- return;
868
-
869
- // 移除监听
870
- that.removeEventBind("getPatrolRouteEditCallback");
871
-
872
- if (callback != undefined) {
873
- that.bindEvent("getPatrolRouteEditCallback", function(evt) {
874
- callback(evt.args);
875
- });
876
- }
877
- scene.fire(msgPrefix + ":getPatrolRouteEdit", { args : [] }, parentScene);
878
- }
879
-
880
- /* 添加图形 */
881
- var pointStyle = {};
882
- pointStyle.style = {"type":"esriSMS","style":"esriSMSCircle","color":[255, 0, 0, 150],"size":8,"angle":0,"xoffset":0,"yoffset":0,"outline":{"color":[255, 0, 0, 150],"width":1}}
883
- pointStyle.hStyle = MapUtils.deepClones(true, {}, pointStyle.style);
884
- var polylineStyle = {};
885
- polylineStyle.style ={"type":"esriSFS","style":"esriSFSSolid","color":[255, 0, 0, 150],"outline":{"type":"esriSLS","style":"esriSLSSolid","color":[0, 0, 255, 150],"width":1}};
886
- polylineStyle.hStyle = MapUtils.deepClones(true, {}, polylineStyle.style);
887
- var polygonStyle = {};
888
- polygonStyle.style ={"type":"esriSFS","style":"esriSFSSolid","color":[255, 0, 0, 150],"outline":{"type":"esriSLS","style":"esriSLSSolid","color":[0, 0, 255, 150],"width":1}};
889
- polygonStyle.hStyle = MapUtils.deepClones(true, {}, polygonStyle.style);
890
- var styles = {"point":pointStyle, "polyline":polylineStyle, "polygon":polygonStyle};
891
-
892
- that.getStyles = function(type, styleType) {
893
- var result = MapUtils.deepClones(true, {}, styles[type]);
894
- if (styleType == "esriSFSDiagonalCross") {
895
- result.style.type = "esriPFS";
896
- result.style.width = 10;
897
- result.style.height = 10;
898
- result.style.url = "images/diagonalcross_red.png";
899
- }else if(styleType == "esriPolygonHalfYellowTransparent"){
900
- result.style = {"type":"esriSFS","style":"esriSFSSolid","color":[215, 214, 111, 100],"outline":{"type":"esriSLS","style":"esriSLSSolid","color":[0, 0, 255, 150],"width":1}};;
901
- }else if(styleType == "esriPointHalfYellowTransparent"){
902
- result.style = {"type":"esriSMS","style":"esriSMSCircle","color":[215, 214, 111, 100],"size":8,"angle":0,"xoffset":0,"yoffset":0,"outline":{"color":[255, 0, 0, 150],"width":1}};
903
- result.hStyle =MapUtils.deepClones(true, {}, pointStyle.style);
904
- }else if(styleType == "esriLineHalfYellowTransparent"){
905
- result.style = {"type":"esriSFS","style":"esriSFSSolid","color":[215, 214, 111, 100],"outline":{"type":"esriSLS","style":"esriSLSSolid","color":[0, 0, 255, 150],"width":1}};
906
- result.hStyle = MapUtils.deepClones(true, {}, pointStyle.style);
907
- }
908
- return result;
909
- }
910
- that.addGraphic = function(params, addCallback, editCallback) {
911
- if (scene == null)
912
- return;
913
-
914
- // 移除监听
915
- that.removeEventBind("drawGeometryCallback");
916
- that.removeEventBind("drawGeometryEditCallback");
917
-
918
- if (addCallback != undefined) {
919
- that.bindEvent("drawGeometryCallback", function(evt) {
920
- addCallback(evt.args);
921
- });
922
- }
923
- if (editCallback != undefined) {
924
- that.bindEvent("drawGeometryEditCallback", function(evt) {
925
- editCallback(evt.args);
926
- });
927
- }
928
- if (params[1] == null && styles[params[0]]) {
929
- params[1] = styles[params[0]].style;
930
- }
931
- scene.fire(msgPrefix + ":drawGeometry", { args : params }, parentScene);
932
- }
933
-
934
- /* 编辑图形 */
935
- that.editGraphic = function(params, editCallback, deleteCallback) {
936
- if (scene == null)
937
- return;
938
-
939
- // 移除监听
940
- that.removeEventBind("editGeometryCallback");
941
- that.removeEventBind("deleteGeometryCallback");
942
-
943
- if (editCallback != undefined) {
944
- that.bindEvent("editGeometryCallback", function(evt) {
945
- editCallback(evt.args);
946
- });
947
- }
948
- if (deleteCallback != undefined) {
949
- that.bindEvent("deleteGeometryCallback", function(evt) {
950
- deleteCallback(evt.args);
951
- });
952
- }
953
- if (params[3] == null) {
954
- params[3] = styles.polygon.style;
955
- }
956
- scene.fire(msgPrefix + ":editGeometry", { args : params }, parentScene);
957
- }
958
-
959
- /* 圆饼图 */
960
- that.addCircleChart = function(name, data, color, param) {
961
- color = color || "#1B5771";
962
- param = param || {minRadius: 20, rangeRadius: 20};
963
- scene.fire(msgPrefix + ":addCircleChart", {args: [name, data, color, param]}, parentScene);
964
- }
965
-
966
- /* 饼图 */
967
- //by ysj,2020-06-03
968
- that.addChart = function (option, zoom, clickCallback, id, minZoom, maxZoom) {
969
- that.removeEventBind("chartsLayerClickCallback");
970
- if (clickCallback != undefined) {
971
- that.bindEvent("chartsLayerClickCallback", function(evt) {
972
- clickCallback(evt.args);
973
- });
974
- }
975
- scene.fire(msgPrefix + ":addChart", {args: [option, zoom,id,minZoom,maxZoom]}, parentScene);
976
- }
977
-
978
- that.drawGeometry = function(type, style, clear, callback, option) {
979
- type = type || "point";
980
- style = style || {"type":"esriSLS","style":"esriSLSSolid","color":[255,0,0,255],"width":2};
981
- //移除监听
982
- that.removeEventBind("drawGeometryCallback");
983
- if (callback != undefined) {
984
- that.bindEvent("drawGeometryCallback", function(evt) {
985
- callback(evt.args);
986
- });
987
- }
988
-
989
- scene.fire(msgPrefix + ":drawGeometry", {args: [type, style, clear, callback, option]}, parentScene);
990
- }
991
-
992
- /* 热力图*/
993
- that.addHeatMap = function(data, option){
994
- scene.fire(msgPrefix + ":addHeatMap", {args: [data, option]}, parentScene);
995
- }
996
- /* 聚类 */
997
- that.addClusterLayer = function(data, id){
998
- scene.fire(msgPrefix + ":addClusterLayer", {args: [data, id]}, parentScene);
999
- }
1000
- /* 添加热区图层 */
1001
- that.addHotLayer = function (layerUsageID, outFields, visiblelevel, clickCallback, style, hstyle) {
1002
- var usageID = layerUsageID || 3007;
1003
- var style = style || { "type": "esriSFS", "style": "esriSFSSolid", "color": [100, 100, 100, 125], "outline": { "type": "esriSLS", "style": "esriSLSSolid", "color": [255, 0, 0, 255], "width": 1 } };
1004
- var hstyle = hstyle || { "type": "esriSFS", "style": "esriSFSSolid", "color": [100, 100, 255, 125], "outline": { "type": "esriSLS", "style": "esriSLSSolid", "color": [255, 0, 0, 255], "width": 1 } };
1005
- var where = null;
1006
- scene.fire(msgPrefix + ":addCustomWMSLayer", { args: [usageID, style, hstyle, where, outFields, visiblelevel] }, parentScene);
1007
-
1008
- if (clickCallback) {
1009
- that.removeEventBind("CustomWMSLayerMouseClick");
1010
- that.bindEvent("CustomWMSLayerMouseClick", function (evt) {
1011
- clickCallback(evt.args);
1012
- });
1013
- }
1014
- }
1015
-
1016
- /* 添加等值线图 */
1017
- that.addKrigingMap = function (datalist, options) {
1018
- scene.fire(msgPrefix + ":addKrigingMap", { args: [datalist, options] }, parentScene);
1019
- }
1020
-
1021
- /* 删除热区图层 */
1022
- that.removeHotLayer = function(){
1023
- scene.fire(msgPrefix + ":removeLayer", { args: ['CustomWMSLayer'] }, parentScene);
1024
- }
1025
-
1026
-
1027
- /* 图层查询 */
1028
- that.queryPhylayerFeatures = function(params, callback) {
1029
- // 移除监听
1030
- that.removeEventBind("queryPhylayerFeaturesCallback");
1031
-
1032
- if (callback != undefined) {
1033
- that.bindEvent("queryPhylayerFeaturesCallback", function(evt) {
1034
- callback(evt.args);
1035
- });
1036
- }
1037
- scene.fire(msgPrefix + ":queryPhylayerFeatures", {args: [params.queryType, params.queryValue, params.phyLayerIDs, params.where, params.params, params.startIndex, params.maxFeatures]}, parentScene);
1038
- }
1039
- // /* 执行查询任务 */
1040
- // that.executeQueryTask = function(params, callback) {
1041
- // var queryTaskContext = {};
1042
- // queryTaskContext.callback = callback;
1043
- // queryTaskContext.gisSuccessFn = queryTaskContext.gisErrorFn = function(data, result) {
1044
- // this.callback(result);
1045
- // }
1046
- // var queryTaskService = http.getInstance("", {type : "post", async: false, "callback": callback }, queryTaskContext.gisSuccessFn, queryTaskContext.gisErrorFn, queryTaskContext);
1047
- // queryTaskService.settings.url = context.gisServerURL + "/home/gis/event/execquerytask.htm";
1048
- // queryTaskService.ajax(params);
1049
- // }
1050
- /* 显示消息框 */
1051
- that.showInfoWindow = function (params) {
1052
- var visible = params.visible;
1053
- var position = {};
1054
- position.x = params.x;
1055
- position.y = params.y;
1056
- var title = params.title;
1057
- var content = params.content;
1058
- scene.fire(msgPrefix + ":infoWindow", { args: [visible, position, title, content] }, parentScene);
1059
- }
1060
- /* 隐藏消息框 */
1061
- that.hideInfoWindow = function (params) {
1062
- scene.fire(msgPrefix + ":infoWindow", { args: [false] }, parentScene);
1063
- }
1064
-
1065
-
1066
-
1067
- /* 显示扩展消息框 */
1068
- that.showInfoWindowEx = function (params) {
1069
- scene.fire(msgPrefix + ":showInfoWindow", {
1070
- args: [params.id || 0, params.title, params.content, params.x, params.y, params.style, params.options]
1071
- }, parentScene);
1072
- }
1073
- /* 显示扩展消息框 */
1074
- that.hideInfoWindowEx = function (id) {
1075
- scene.fire(msgPrefix + ":hideInfoWindow", {
1076
- args: [id]
1077
- }, parentScene);
1078
- }
1079
- /** 设置扩展消息框样式
1080
- * option 基础样式选项,格式如:{noTitle:true,close:true,title:{},background:'#FFF'}
1081
- * noTitle: 是否显示标题栏;
1082
- * close: 是否显示关闭按钮;
1083
- * title: 标题栏的css样式对象
1084
- * background : 除标题栏外的其他部分的颜色
1085
- * style 位置和大小的配置,格式如:{width:300,height:300,achor:'auto',offsetY:0}
1086
- * width: 宽度
1087
- * height:高度
1088
- * achor:箭头方向,其中值包含 'top','left','right','bottom','auto'
1089
- * offsetY:Y方向上的偏移
1090
- **/
1091
- that.setInfoWindowStyle = function (option,style,id) {
1092
- scene.fire(msgPrefix + ":setInfoWindowStyle", {
1093
- args: [option,style,id]
1094
- }, parentScene);
1095
- }
1096
-
1097
- /* 要素查询 */
1098
- that.queryFeature = function(params, callback) {
1099
- if (scene == null)
1100
- return;
1101
- scene.fire(msgPrefix + ":queryFeature", {args: [params.layerID, params.where || null, params.geometry || null, params.outFields, params.outGeometry, params.pointTolorence||0,params.startIndex,params.maxFeatures,null,callback||null,params.sortBy, params.filterNullGeometry, params.options, params.featureIds]}, parentScene);
1102
- }
1103
-
1104
- /* 显示图层
1105
- * layerID:图层ID ,
1106
- * serviceID:服务ID(可选),
1107
- * showAtBottom:是否显示在最底层(true:显示到最底层,false:显示在最顶层),
1108
- * zoomLevel:缩放级别(传入数字为缩放到对应的级别,传入true缩放到最大可视级别)
1109
- */
1110
- that.showVectorLayer = function(layerID,serviceID,showAtBottom,zoomLevel) {
1111
- if (scene == null)
1112
- return;
1113
- scene.fire(msgPrefix + ":showVectorLayer", {args: [layerID,serviceID,showAtBottom,zoomLevel]}, parentScene);
1114
- }
1115
-
1116
- /* 隐藏图层 */
1117
- that.hideVectorLayer = function(layerID,serviceID) {
1118
- if (scene == null)
1119
- return;
1120
- scene.fire(msgPrefix + ":hideVectorLayer", {args: [layerID,serviceID]}, parentScene);
1121
- }
1122
-
1123
- /* 获取当前地图范围 */
1124
- that.getMapExtent = function(callback) {
1125
- // 移除监听
1126
- that.removeEventBind("getMapExtentCallback");
1127
-
1128
- if (callback != undefined) {
1129
- that.bindEvent("getMapExtentCallback", function(evt) {
1130
- callback(evt.args);
1131
- });
1132
- }
1133
- scene.fire(msgPrefix + ":getMapExtent", {args: []}, parentScene);
1134
- }
1135
-
1136
- /**查询表信息*/
1137
- that.queryObjectInfo = function (geoShapes, tableName, xFieldName, yFieldName, callback, usePage, currentPage, numPerPage, params) {
1138
- var queryParam = {
1139
- 'tableName': tableName,
1140
- 'xFieldName': xFieldName,
1141
- 'yFieldName': yFieldName
1142
- };
1143
- if(params) queryParam = MapUtils.deepClones(true, {}, queryParam, params);
1144
-
1145
- that.removeEventBind("queryObjectInfoCallback");
1146
- that.bindEvent("queryObjectInfoCallback", callback);
1147
- scene.fire(msgPrefix + ':queryObjectInfo', {args: [JSON.stringify(geoShapes), JSON.stringify(queryParam), usePage, currentPage, numPerPage]}, parentScene, false);
1148
- }
1149
-
1150
- that.enableMapSnap = function (layerID, callback) {
1151
- if (scene == null) return;
1152
- if(!layerID) return;
1153
- that.removeEventBind("enableMapSnapCallback");
1154
- that.bindEvent("enableMapSnapCallback", callback);
1155
- scene.fire(msgPrefix + ":enableMapSnap", {
1156
- args: [layerID]
1157
- },parentScene);
1158
- }
1159
-
1160
- that.disableMapSnap = function (layerID) {
1161
- if (scene == null) return;
1162
- if(!layerID) return;
1163
- scene.fire(msgPrefix + ":disableMapSnap", {
1164
- args: [layerID]
1165
- },parentScene);
1166
- }
1167
-
1168
- that.addMaskLayer = function(layerID,keyField,values,style,zoom,position) {
1169
- scene.fire(msgPrefix + ":addMaskLayer", {args: [layerID,keyField,values,style,zoom,position]},parentScene);
1170
- }
1171
-
1172
- /* 计算线、面长度,支持线、面格式 */
1173
- that.getGeometryLength = function(geometry) {
1174
- return scene.fire(msgPrefix + ":getGeometryLength", {args: [geometry]},parentScene);
1175
- }
1176
-
1177
- /* 计算多边形面积 */
1178
- that.getPolygonArea = function(geometry) {
1179
- return scene.fire(msgPrefix + ":getPolygonArea", {args: [geometry]},parentScene);
1180
- }
1181
-
1182
- that.intersectGeometry = function (polygon1, polygon2) {
1183
- return scene.fire(msgPrefix + ":intersectGeometry", {args: [polygon1, polygon2]}, parentScene);
1184
- }
1185
-
1186
- that.getCenterPoint = function (polygon) {
1187
- return scene.fire(msgPrefix + ":getCenterPoint", {args: [polygon]}, parentScene);
1188
- }
1189
-
1190
- /* 根据PointID定位空中全景 */
1191
- that.mmsAirPanoLocateByID = function(pointID) {
1192
- if(mmsMap && mmsMap.mmsLoaded) {
1193
- scene.fire(msgPrefix + ":mmsAirPanoLocateCallback", {args: [pointID]}, parentScene);
1194
- }
1195
- }
1196
-
1197
- /* 空中全景历史对比回调 */
1198
- that.mmsAirPanoCompare = function(callback) {
1199
- if(mmsMap && mmsMap.mmsLoaded) {
1200
- scene.fire(msgPrefix + ":mmsAirPanoCompareCallback", {args: [callback]}, parentScene);
1201
- }
1202
- }
1203
-
1204
- that.setMMSEyePositionTest = function(x,y) {
1205
- var pos = {x:x, y:y};
1206
- var evt = {args:[pos]};
1207
- mmsMap.setMMSEyePosition(evt);
1208
- }
1209
-
1210
- /* 切换地图类型 */
1211
- that.changeControlParam = function (type, param) {
1212
- scene.fire(msgPrefix + ":changeControlParam", { args: [type, param] }, parentScene);
1213
- }
1214
-
1215
- /* 获取图层信息 */
1216
- that.getPhyLayerInfo=function (phyLayerID,getPhyLayerInfoCallBack) {
1217
- that.removeEventBind("getPhyLayerInfoCallback");
1218
- if (getPhyLayerInfoCallBack != undefined) {
1219
- that.bindEvent("getPhyLayerInfoCallback", function(evt) {
1220
- getPhyLayerInfoCallBack(evt.args);
1221
- });
1222
- }
1223
- scene.fire((msgPrefix + ":getPhyLayerInfo"), {args: [phyLayerID]}, parentScene,true);
1224
- }
1225
-
1226
- /* 获取图层字段信息 */
1227
- that.getPhyLayerField=function (phyLayerIDs,getPhyLayerFieldCallback) {
1228
- that.removeEventBind("getPhyLayerFieldCallback");
1229
- if (getPhyLayerFieldCallback != undefined) {
1230
- that.bindEvent("getPhyLayerFieldCallback", function(evt) {
1231
- getPhyLayerFieldCallback(evt.args);
1232
- });
1233
- }
1234
- scene.fire((msgPrefix + ":getPhyLayerField"), {args: [phyLayerIDs]}, parentScene,true);
1235
- }
1236
-
1237
- /* 获取图层字段信息 */
1238
- that.getPhyLayerField=function (phyLayerIDs,getPhyLayerFieldCallback) {
1239
- that.removeEventBind("getPhyLayerFieldCallback");
1240
- if (getPhyLayerFieldCallback != undefined) {
1241
- that.bindEvent("getPhyLayerFieldCallback", function(evt) {
1242
- getPhyLayerFieldCallback(evt.args);
1243
- });
1244
- }
1245
- scene.fire((msgPrefix + ":getPhyLayerField"), {args: [phyLayerIDs]}, parentScene,true);
1246
- }
1247
-
1248
- /*对几何图形进行缓冲*/
1249
- that.getGeometryBuffer=function(geometry,radius,callback,autoTransRadius){
1250
- that.removeEventBind("getGeometryBufferCallback");
1251
- if (callback != undefined) {
1252
- that.bindEvent("getGeometryBufferCallback", function(evt) {
1253
- callback(evt.args);
1254
- });
1255
- }
1256
- scene.fire((msgPrefix + ":getGeometryBuffer"), {args: [geometry,radius,autoTransRadius]}, parentScene,true);
1257
- }
1258
-
1259
- /* 移除图层*/
1260
- that.removeLayer = function(layerName){
1261
- scene.fire((msgPrefix + ":removeLayer"), {args: [layerName]}, parentScene,true);
1262
- }
1263
-
1264
- that.change3dlayerUsageConfig=function(){
1265
- if (scene == null)
1266
- return;
1267
- var config=scene.layerUsageConfig;
1268
- scene.fire(msgPrefix + ":change3dlayerUsageConfig", {args: [config]}, parentScene);
1269
- }
1270
- /*显示多轨迹*/
1271
- that.showTraceMultiHisLayer = function(objectIDs, symbolType, beginDate, endDate, clear, zoom, hStyle) {
1272
- scene.fire((msgPrefix + ":showTraceMultiHisLayer"), {args: [objectIDs, symbolType, beginDate, endDate, clear, zoom, hStyle]}, parentScene);
1273
- }
1274
- /*清除多轨迹*/
1275
- that.claerTraceMultiHisLayer = function() {
1276
- scene.fire((msgPrefix + ":claerTraceMultiHisLayer"), {args: []}, parentScene);
1277
- }
1278
- /*多人员图标通过id高亮*/
1279
- that.multiPointsSelectbyID = function(id) {
1280
- scene.fire((msgPrefix + ":multiPointsSelectbyID"), {args: [id]}, parentScene);
1281
- }
1282
- /*多轨迹通过id高亮*/
1283
- that.traceMultiSelectbyID = function(id) {
1284
- scene.fire((msgPrefix + ":traceMultiSelectbyID"), {args: [id]}, parentScene);
1285
- }
1286
-
1287
- that.init();
1288
- }
1289
- export default EGovaGISMap;
1
+ import EGovaMMSMap from "./egovamms";
2
+ import MapUtils from './mapUtils';
3
+ var scene = null;
4
+
5
+ function getCookie(name){
6
+ var strCookie = window.document.cookie;
7
+ var arrCookie = strCookie.split("; ");
8
+ for(var i=0; i<arrCookie.length; i++){
9
+ var arr = arrCookie[i].split("=");
10
+ if(arr[0]==name) return arr[1];
11
+ }
12
+ return null;
13
+ };
14
+ function setCookie(name,value){
15
+ window.document.cookie = name+"="+value;
16
+ }
17
+
18
+ function checkGisServerURL(url,callback){
19
+ if(!url) return;
20
+
21
+ var cookieUrl = getCookie("gisUrl");
22
+ var gisProxyList = url.split(";");
23
+ cookieUrl&&gisProxyList.push(cookieUrl);
24
+ if(gisProxyList.length<=1){
25
+ if(url.indexOf("http")!=0){
26
+ url = window.location.origin + url;
27
+ }
28
+ callback(url);
29
+ return ;
30
+ }
31
+ var params = {isLoad:false};
32
+ for(var i in gisProxyList){
33
+ if(gisProxyList.hasOwnProperty(i)){
34
+ if(gisProxyList[i].indexOf("http")!=0){
35
+ gisProxyList[i] = window.location.origin + url;
36
+ }
37
+ checkGISProxy(gisProxyList[i],params,callback);
38
+ }
39
+ }
40
+ }
41
+
42
+ function checkGISProxy(proxyUrl,params,callback) {
43
+ var img = new Image();
44
+ img.src = proxyUrl + '/symbol/default.png';
45
+ img.onload = function (e1) {
46
+ if(!params.isLoad){
47
+ params.isLoad = true;
48
+ setCookie("gisUrl",proxyUrl);
49
+ callback(proxyUrl);
50
+ }
51
+ img = null;
52
+ };
53
+ }
54
+
55
+ var EGovaGISMap = function ($container, pScene, prefix, gisParams, mapConfig,context) {
56
+ var that = this;
57
+ scene = pScene;
58
+ var parentScene = pScene.pageId || "parentScene";
59
+ var msgPrefix = prefix || "gismappage";
60
+ var mmsMap = null;
61
+ that.gisVisible = false;
62
+ that.gisLoaded = false;
63
+ that.isLoading = false;
64
+
65
+ that.$gisMapFrame = null;
66
+ that.gisMapContainer = null;
67
+
68
+ that.gisMapContainer = $container.getElementsByClassName("emap-container")[0];
69
+ if (!that.gisMapContainer) {
70
+
71
+ var mapHTML = '<iframe class="emap-iframe"></iframe>';
72
+ var element = document.createElement("div");
73
+ element.classList.add("emap-container");
74
+ element.innerHTML = mapHTML;
75
+ $container.appendChild(element);
76
+ that.gisMapContainer = element;
77
+ }
78
+
79
+ that.$gisMapFrame = that.gisMapContainer.getElementsByClassName("emap-iframe")[0];
80
+ that.onMapLoadedHandlers = [];
81
+
82
+ that.onMapLoaded = function () {
83
+ that.isLoading = false;
84
+ that.gisLoaded = true;
85
+ if(context.mapCenterFlag){
86
+ if(context.mapCenterFlag == '1'){
87
+ if(context.coordinateX && context.coordinateY){
88
+ that.centerAndZoom(context.coordinateX, context.coordinateY, 4);
89
+ }
90
+ } else if(context.mapCenterFlag == '2'){
91
+ if(context.coordinateX && context.coordinateY){
92
+ that.centerAndZoom(context.coordinateX, context.coordinateY, 1);
93
+ }
94
+ if(context.humanLayerUsageID && context.regionCode){
95
+ var zoom = gisParams && gisParams.maskZoom == true;
96
+ var style={"type":"esriSFS","style":"esriSFSSolid","color": [100,100,255,125],"outline":{"type":"esriSLS","style":"esriSLSSolid","color":[255,0,0,255],"width":1}};
97
+ var pos = {visible:true,top:95,right:127};
98
+ if(mapConfig && mapConfig.maskPos){
99
+ pos = MapUtils.deepClones({}, pos, mapConfig.maskPos);
100
+ }
101
+ that.addMaskLayer(context.humanLayerUsageID, context.humanLayerKeyFieldName, context.regionCode, style, zoom, pos);
102
+ }
103
+ } else if(context.mapCenterFlag == '3'){
104
+ if(context.coordinateX && context.coordinateY){
105
+ that.centerAndZoom(context.coordinateX, context.coordinateY, 1);
106
+ }
107
+ if(context.humanLayerUsageID && context.regionCode){
108
+ var zoom = gisParams && gisParams.maskZoom == false;
109
+ var style={"type":"esriSFS","style":"esriSFSSolid","color": [100,100,255,0],"outline":{"type":"esriSLS","style":"esriSLSSolid","color":[255,0,0,255],"width":3}};
110
+ var pos = {visible:true,top:95,right:127};
111
+ if(mapConfig && mapConfig.maskPos){
112
+ pos = MapUtils.deepClones({}, pos, mapConfig.maskPos);
113
+ }
114
+ that.addMaskLayer(context.humanLayerUsageID, context.humanLayerKeyFieldName, context.regionCode, style, zoom, pos);
115
+ }
116
+ }
117
+ }
118
+ for(var i=0,len=that.onMapLoadedHandlers.length; i<len; i++){
119
+ that.onMapLoadedHandlers[i]();
120
+ }
121
+ }
122
+
123
+ that.init = function () {
124
+ if (!that.gisLoaded && !that.isLoading) {
125
+ that.isLoading = true;
126
+ checkGisServerURL(context.gisServerURL, function (gisurl) {
127
+ var bust = (new Date()).getTime();
128
+ var gisServerURL = context.gisServerURL = gisurl;
129
+ var gisProxyURL = context.gisServerURL + '/home/gis/proxy.htm';
130
+ var misServerURL = context.rootPath;
131
+ var url = context.rootPath+context.assetsPath+"/map.html?parentScene=" + parentScene + "&msgPrefix=" + msgPrefix + "&bust="+bust
132
+ + "&serverURL=" + gisServerURL + "&proxyURL=" + gisProxyURL + "&misURL="+misServerURL+"&humanID=" + context.humanID;
133
+ if (mapConfig != undefined && mapConfig.params != undefined) {
134
+ for (var item in mapConfig.params) {
135
+ url += "&" + item + "=" +encodeURIComponent(mapConfig.params[item]);
136
+ }
137
+ }
138
+ if(context.mapZoomRange){
139
+ var mapZoomRanges = context.mapZoomRange.split(",");
140
+ if(mapZoomRanges.length == 2 ){
141
+ url += "&minlevel=" +mapZoomRanges[0]+"&maxlevel="+mapZoomRanges[1]
142
+ }
143
+ }
144
+ that.$gisMapFrame.src = url;
145
+ that.$gisMapFrame.onload = function(){
146
+ if(!this.contentDocument.documentElement.getElementsByTagName("head").item(0).outerHTML.includes("/library/egovagis/map/map.js")) {
147
+ var mainScript = this.contentDocument.createElement("script");
148
+ mainScript.setAttribute("type", "text/javascript");
149
+ mainScript.setAttribute("src", gisServerURL + "/library/egovagis/map/map.js");
150
+ this.contentDocument.documentElement.getElementsByTagName("head").item(0).appendChild(mainScript);
151
+ }
152
+ }
153
+ });
154
+ try {
155
+ //如果启用了实景功能需要注册实景监听
156
+ if (context.mmsEnabled != undefined && that.gisMapContainer) {
157
+ var mmsEnabled = Number(context.mmsEnabled);
158
+ if(mmsEnabled > 0){
159
+ mmsMap = new EGovaMMSMap($container, scene, msgPrefix, context.mmsParams, mapConfig, mmsEnabled);
160
+ }
161
+ }
162
+ } catch (e) {
163
+ console.error(e.message);
164
+ }
165
+ }
166
+
167
+ //初始化时不显示地图
168
+ that.closeMap();
169
+ // 监听地图加载完成的事件
170
+ scene.on(msgPrefix + ":mapLoadedCallback", that.onMapLoaded, parentScene, false);
171
+ }
172
+
173
+ /**
174
+ * 二维地图显示
175
+ *
176
+ * @param res
177
+ */
178
+ that.openMap = function (evt) {
179
+ if (!that.gisVisible) {// 初次定位时调整布局
180
+ if (!that.gisLoaded && !that.isLoading) {
181
+ that.isLoading = true;
182
+ checkGisServerURL(context.gisServerURL, function () {
183
+ var gisServerURL = context.gisServerURL;
184
+ var gisProxyURL = context.gisServerURL + '/home/gis/proxy.htm';
185
+ var misServerURL = context.rootPath;
186
+ var url = context.rootPath +context.assetsPath + "/map.html?parentScene=" + parentScene + "&msgPrefix=" + msgPrefix
187
+ + "&serverURL=" + gisServerURL + "&proxyURL=" + gisProxyURL +"&misURL="+misServerURL+ "&humanID=" + context.humanID;
188
+ if (mapConfig != undefined && mapConfig.params != undefined) {
189
+ for (var item in mapConfig.params) {
190
+ url += "&" + item + "=" + mapConfig.params[item];
191
+ }
192
+ }
193
+ that.$gisMapFrame.src = url;
194
+ that.$gisMapFrame.onload = function(){
195
+ if(!this.contentDocument.documentElement.getElementsByTagName("head").item(0).outerHTML.includes("/library/egovagis/map/map.js")) {
196
+ var mainScript = this.contentDocument.createElement("script");
197
+ mainScript.setAttribute("type", "text/javascript");
198
+ mainScript.setAttribute("src", gisServerURL + "/library/egovagis/map/map.js");
199
+ this.contentDocument.documentElement.getElementsByTagName("head").item(0).appendChild(mainScript);
200
+ }
201
+ }
202
+ });
203
+ try {
204
+ //如果启用了实景功能需要注册实景监听,msgPrefix+'old',为了兼容以前的GIS实景结合
205
+ if (context.mmsEnabled != undefined && context.mmsEnabled == "1" && that.gisMapContainer) {
206
+ mmsMap = new EGovaMMSMap($container, scene, msgPrefix + 'old', context.mmsParams, mapConfig);
207
+ }
208
+ } catch (e) {
209
+ alert(e.message);
210
+ }
211
+ }
212
+
213
+ that.gisMapContainer.style.height = '100%';
214
+ that.gisMapContainer.style.display = 'block';
215
+ that.gisVisible = true;
216
+ }
217
+ }
218
+
219
+ /**
220
+ * 二维地图关闭
221
+ */
222
+ that.closeMap = function (evt) {
223
+ that.gisMapContainer.style.display = 'block';
224
+ that.gisMapContainer.style.height = '0';
225
+ that.gisVisible = false;
226
+ }
227
+
228
+
229
+ /* 绑定事件 */
230
+ that.bindEvent = function(msgId, msgHandler, stopOnTop) {
231
+ if (scene == null)
232
+ return;
233
+ scene.on(msgPrefix + ":" + msgId, msgHandler, parentScene, stopOnTop);
234
+ }
235
+ /* 触发事件 */
236
+ that.fireEvent = function(msgId, msgData, stopOnTop) {
237
+ if (scene == null)
238
+ return;
239
+ scene.fire(msgPrefix + ":" + msgId, msgData, parentScene, stopOnTop);
240
+ }
241
+ /* 移除监听 */
242
+ that.removeEventBind = function(msgId, stopOnTop) {
243
+ if (scene == null)
244
+ return;
245
+ scene.remove(msgPrefix + ":" + msgId, parentScene, stopOnTop);
246
+ }
247
+
248
+ /* 切换到平移工具 */
249
+ that.panMap = function() {
250
+ if (scene == null)
251
+ return;
252
+ scene.fire(msgPrefix + ":panMap", parentScene);
253
+ }
254
+ /* 缩放到指定范围 */
255
+ that.zoomToExtent = function(minX, minY, maxX, maxY) {
256
+ if (scene == null)
257
+ return;
258
+ scene.fire((msgPrefix + ":zoomToExtent"), { args : [ Number(minX), Number(minY), Number(maxX), Number(maxY) ] }, parentScene,
259
+ false);
260
+ }
261
+ /* 缩放到指定中心点和级别 */
262
+ that.centerAndZoom = function(x, y, level) {
263
+ if (scene == null)
264
+ return;
265
+ scene.fire((msgPrefix + ":centerAndZoom"), { args : [ x, y, level ] }, parentScene, false);
266
+ }
267
+ /* 缩放到全图范围 */
268
+ that.zoomToFullExtent = function() {
269
+ if (scene == null)
270
+ return;
271
+ scene.fire((msgPrefix + ":fullExtent"), { args : [] }, parentScene, false);
272
+ }
273
+ /* 绘制图形 */
274
+ that.drawGraphic = function(graphic, zoom, clickCallback) {
275
+ if (scene == null)
276
+ return;
277
+ if (graphic.geometry instanceof Array) {
278
+ scene.fire(msgPrefix + ":locateFeatureByCoords", { args : [ graphic.geometry, graphic.type, graphic.id, graphic.style,
279
+ graphic.hstyle, zoom, graphic.keyField, graphic.labelField, graphic.labelStyle, graphic.colorNumber, graphic.renderCanvas, graphic.singleSelected, graphic.options, graphic.layerTag] }, parentScene);
280
+ } else {
281
+ // scene.fire(msgPrefix+":locateFeatureByCoord",
282
+ // {args:[{"geometry":graphic.geometry},graphic.type,graphic.id,graphic.style,graphic.hstyle,zoom]},parentScene);
283
+ scene.fire(msgPrefix + ":locateFeatureByCoords", { args : [ [ graphic.geometry ], graphic.type, graphic.id, graphic.style,
284
+ graphic.hstyle, zoom, graphic.keyField, graphic.labelField, graphic.labelStyle, graphic.colorNumber, graphic.renderCanvas, graphic.singleSelected, graphic.options, graphic.layerTag] }, parentScene);
285
+ }
286
+ that.removeEventBind("locateFeatureByIDsCallback");
287
+ if (clickCallback != undefined) {
288
+ that.bindEvent("locateFeatureByIDsCallback", function(evt) {
289
+ clickCallback(evt.args);
290
+ });
291
+ }
292
+ }
293
+
294
+ /*添加WMS服务图层*/
295
+ that.showWMSLayer = function(layerUsageID, IDs, keyField, geometry, where) {
296
+ if (scene == null)
297
+ return;
298
+ scene.fire(msgPrefix + ":showWMSLayer", { args : [ layerUsageID, IDs, keyField, geometry, where ] }, parentScene, false);
299
+ }
300
+
301
+ /*清除WMS服务图层*/
302
+ that.removeWMSLayer = function(serviceID) {
303
+ if (scene == null)
304
+ return;
305
+ scene.fire(msgPrefix + ":removeWMSLayer", { args : [ serviceID ] }, parentScene, false);
306
+ }
307
+
308
+
309
+ /*根据要素坐标定位显示要素*/
310
+ that.locateFeatureByCoords=function(geometries, type, ID, style, hStyle, zoom, keyFiled, labelField, labelStyle, randomColor, renderCanvas, singleSelected, options, layerTag){
311
+ if (scene == null)
312
+ return;
313
+ scene.fire((msgPrefix + ":locateFeatureByCoords"), { args : [geometries, type, ID, style, hStyle, zoom, keyFiled, labelField, labelStyle, randomColor, renderCanvas, singleSelected, options, layerTag] }, parentScene, false);
314
+ }
315
+ /* 清除指定图形 */
316
+ that.clearGraphic = function(id, tag) {
317
+ if (scene == null)
318
+ return;
319
+ if (typeof id != "string") {
320
+ id = id.join(",");
321
+ }
322
+ if (tag) {
323
+ id = null;
324
+ }
325
+ scene.fire((msgPrefix + ":clearGraphic"), { args : [ id, tag ] }, parentScene, false);
326
+ }
327
+ /* 清除全部图形 */
328
+ that.clearAllGraphics = function(id) {
329
+ if (scene == null)
330
+ return;
331
+ scene.fire((msgPrefix + ":clearAllGraphics"), { args : [] }, parentScene, false);
332
+ }
333
+ /* 在地图上标注 */
334
+ that.pointSelect = function(symbolType, zoomFalg, callback) {
335
+ if (scene == null)
336
+ return;
337
+
338
+ // 移除监听
339
+ scene.remove(msgPrefix + ":pointSelectCallback", parentScene, false);
340
+
341
+ if (zoomFalg == undefined)
342
+ zoomFalg = true;
343
+ if (callback) {
344
+ // 定义回调
345
+ scene.on(msgPrefix + ":pointSelectCallback", function(evt) {
346
+ // 移除监听
347
+ scene.remove(msgPrefix + ":pointSelectCallback", parentScene, false);
348
+ callback(evt.args);
349
+ }, parentScene, false);
350
+ }
351
+ scene.fire(msgPrefix + ":pointSelect", { args : [ symbolType, zoomFalg ] }, parentScene, false);
352
+ }
353
+ /* 获取图形外部矩形 */
354
+ that.getFeaturesExtent = function(features, callback) {
355
+ if (scene == null)
356
+ return;
357
+
358
+ // 移除监听
359
+ scene.remove(msgPrefix + ":getFeaturesExtentCallback", parentScene, false);
360
+
361
+ scene.on(msgPrefix + ":getFeaturesExtentCallback", function(evt) {
362
+ // 移除监听
363
+ scene.remove(msgPrefix + ":getFeaturesExtentCallback", parentScene, false);
364
+ callback(evt.args);
365
+ }, parentScene, false);
366
+ scene.fire((msgPrefix + ":getFeaturesExtent"), { args : features }, parentScene, false);
367
+ }
368
+
369
+ /* 获取可见图层 */
370
+ that.getVisibleLayerIds = function (callback) {
371
+ // 移除监听
372
+ scene.remove(msgPrefix + ":getVisibleLayerIdsCallback", parentScene, false);
373
+
374
+ scene.on(msgPrefix + ":getVisibleLayerIdsCallback", function(evt) {
375
+ // 移除监听
376
+ scene.remove(msgPrefix + ":getVisibleLayerIdsCallback", parentScene, false);
377
+ callback(evt.args);
378
+ }, parentScene, false);
379
+ scene.fire((msgPrefix + ":getVisibleLayerIds"), {args: []}, parentScene, false);
380
+ }
381
+
382
+ that.identifyInfoWindow = function (usageID,keyValue,content,size) {
383
+ if (scene == null)
384
+ return;
385
+ scene.fire((msgPrefix + ":identifyInfoWindow"), {args: [usageID,keyValue,content,size]}, parentScene, false);
386
+
387
+ }
388
+ /* 更改工具条参数 */
389
+ that.changeControlParam = function (id,param) {
390
+ if (scene == null)
391
+ return;
392
+ scene.fire((msgPrefix + ":changeControlParam"), {args: [id,param]}, parentScene, false);
393
+
394
+ }
395
+ /* 图层过滤显示 */
396
+ that.setLayerDef = function (phyLayerID,layerDef) {
397
+ if (scene == null)
398
+ return;
399
+ scene.fire((msgPrefix + ":setLayerDef"), {args: [phyLayerID,layerDef]}, parentScene, false);
400
+
401
+ }
402
+ that.setLayerColorDef=function(phyLayerIDs,colorDefs){
403
+ if(scene == null)
404
+ return;
405
+ scene.fire((msgPrefix + ":setLayerColorDef"), {args: [phyLayerIDs,colorDefs]}, parentScene, false);
406
+ }
407
+
408
+ /* 显示图层树 */
409
+ that.showLayerTree = function(/* humanID, mapID */openTree) {
410
+ if (scene == null)
411
+ return;
412
+ /*
413
+ * var data = null; scene.fire(msgPrefix + ":showLayerTree", {args :
414
+ * [data, humanID, mapID]}, parentScene);
415
+ */
416
+ if (openTree == undefined || arguments.length > 1)
417
+ openTree = true;
418
+ scene.fire(msgPrefix + ":showLayerTree", { args : [ openTree ] }, parentScene);
419
+ }
420
+ /* I查询 */
421
+ that.identify = function(type, humanID, mapID, options) {
422
+ if (scene == null)
423
+ return;
424
+ scene.fire(msgPrefix + ":identify", { args : [ type, humanID, mapID ] }, parentScene);
425
+
426
+ // By hth 2021/4/6: 如果传入了回调函数,则绑定执行回调函数的监听事件
427
+ var cb = options && options.cb
428
+ if (cb) {
429
+ // 移除监听
430
+ that.removeEventBind("identifySelectCallback");
431
+ if (cb !== undefined && typeof cb === 'function') {
432
+ that.bindEvent("identifySelectCallback", function(evt) {
433
+ cb(evt.args);
434
+ });
435
+ }
436
+ }
437
+ }
438
+ /* 地理编码查询 */
439
+ that.geoCode = function(searchStr, callback) {
440
+ if (scene == null)
441
+ return;
442
+ if (callback) {
443
+ // 移除监听
444
+ that.removeEventBind("geoCodeCallback");
445
+ if (callback != undefined) {
446
+ that.bindEvent("geoCodeCallback", function(evt) {
447
+ callback(evt.args);
448
+ });
449
+ }
450
+ }
451
+ scene.fire(msgPrefix + ":geoCode", { args : [ searchStr ] }, parentScene);
452
+ }
453
+ /* 逆地理编码查询 */
454
+ that.getAddressByXY = function(x, y, searchStr, radius, callback) {
455
+ if (scene == null)
456
+ return;
457
+ if(callback) {
458
+ that.removeEventBind("getAddressByXYCallback");
459
+ that.bindEvent("getAddressByXYCallback", function (evt) {
460
+ callback(evt.args);
461
+ });
462
+ }
463
+ scene.fire(msgPrefix + ":getAddressByXY", { args : [ x, y, searchStr, radius ] }, parentScene);
464
+ }
465
+ /* 根据坐标获取单元网格 */
466
+ that.getCellNameByPosXY = function(x, y, gridType) {
467
+ if (scene == null)
468
+ return;
469
+ var args = [];
470
+ var callback = null;
471
+ for (var i = 0; i < arguments.length; i++) {
472
+ var arg = arguments[i];
473
+ if (i == arguments.length-1 && typeof(arg) == "function"){
474
+ callback = arg;
475
+ continue;
476
+ }
477
+ args.push(arg);
478
+ }
479
+ if (callback != null) {
480
+ // 移除监听
481
+ that.removeEventBind("getCellNameByPosXYCallback");
482
+
483
+ function _getCellNameByPosXYCallback(evt) {
484
+ that.removeEventBind("getCellNameByPosXYCallback");
485
+ callback(evt.args);
486
+ }
487
+ that.bindEvent("getCellNameByPosXYCallback", _getCellNameByPosXYCallback);
488
+ }
489
+ that.fireEvent("getCellNameByPosXY", { args : args });
490
+ }
491
+ /* 根据图层字段定位显示 */
492
+ that.locateFeatureByIDs = function (layerID, keyFiled, keyValue, clearMap, style, hStyle, bZoom, randomColor, labelfield, labelstyle, geometry, where, renderCanvas, singleSelected,options,extendProperty,layerTag,outFieldStr,animiteStep,index,clipGeom) {
493
+ if (scene == null)
494
+ return;
495
+ if (bZoom == undefined)
496
+ bZoom = false;
497
+ scene.fire(msgPrefix + ":locateFeatureByIDs", { args: [layerID, keyValue, keyFiled, clearMap, style, hStyle, bZoom, randomColor, labelfield, labelstyle, geometry, where, renderCanvas, singleSelected ,options,extendProperty,layerTag,outFieldStr,animiteStep,index,clipGeom] },
498
+ parentScene);
499
+ }
500
+ /* 显示案件分布 */
501
+ that.showRecListDistribution = function(infoJson, zoom, clickCallback, labelInfo,isShowLegend, symbolUrl, options) {
502
+ if (scene == null || infoJson.length == 0)
503
+ return;
504
+ //如果xy坐标没有值不处理
505
+ for(var i=0,len=infoJson.length; i<len; i++){
506
+ if(!infoJson[i].coordinateX || infoJson[i].coordinateX == "" || !infoJson[i].coordinateY || infoJson[i].coordinateY == ""){
507
+ return;
508
+ }
509
+ }
510
+
511
+ // 移除监听
512
+ that.removeEventBind("showRecListDistributionCallback");
513
+
514
+ if (clickCallback != undefined) {
515
+ that.bindEvent("showRecListDistributionCallback", function(evt) {
516
+ clickCallback(evt.args);
517
+ });
518
+ }
519
+ scene.fire((msgPrefix + ":showRecListDistribution"), { args : [ infoJson, zoom, labelInfo,isShowLegend, symbolUrl, options] }, parentScene, false);
520
+
521
+ //如果启用了实景功能,同时进行实景定位
522
+ if(mmsMap && infoJson.length == 1) {
523
+ var recInfo = infoJson[0];
524
+ if (mmsMap.mmsLoaded){
525
+ if (!mmsMap.mmsVisible) {
526
+ // var pos = {x:recInfo.coordinateX, y:recInfo.coordinateY};
527
+ // var evt = {args:[pos]};
528
+ // mmsMap.setMMSEyePosition(evt);
529
+ } else {
530
+ mmsMap.locateEvent(recInfo.recID, recInfo.coordinateX, recInfo.coordinateY);
531
+ }
532
+ }
533
+ }
534
+ }
535
+ /* 显示多个自定义图标 */
536
+ that.showMultiObjectCurrentPosition = function (jsonInfo, zoom, bClear, hStyleID, infoStyle, bCanvas, tagName, clickCallback, mouseOverCallBack, clusterOption, hasHover, layerID, mouseOutCallback, options) {
537
+ if (scene == null)
538
+ return;
539
+ // 移除监听
540
+ var clickBackName = "showMultiObjectCurrentPositionClick";
541
+ var mouseOverBackName = "showMultiObjectCurrentPositionMouseover";
542
+ var mouseOutBackName = "showMultiObjectCurrentPositionMouseout";
543
+ if (options&&options.callbacksuffix) {
544
+ clickBackName += options.callbacksuffix;
545
+ mouseOverBackName += options.callbacksuffix;
546
+ mouseOutBackName += options.callbacksuffix;
547
+ }
548
+ that.removeEventBind(clickBackName);
549
+ that.removeEventBind(mouseOverBackName);
550
+ that.removeEventBind(mouseOutBackName);
551
+ if (clickCallback instanceof Function) {
552
+ that.bindEvent(clickBackName, function(evt) {
553
+ clickCallback(evt.args);
554
+ });
555
+ }
556
+ if (mouseOverCallBack instanceof Function) {
557
+ that.bindEvent(mouseOverBackName, function(evt) {
558
+ mouseOverCallBack(evt.args);
559
+ });
560
+ }
561
+ if(mouseOutCallback instanceof Function){
562
+ that.bindEvent(mouseOutBackName, function(evt) {
563
+ mouseOutCallback(evt.args);
564
+ });
565
+ }
566
+ scene.fire((msgPrefix + ":showMultiObjectCurrentPosition"), {args: [jsonInfo, zoom, bClear, hStyleID, infoStyle, bCanvas, tagName, clusterOption, hasHover, layerID, options]}, parentScene, false);
567
+ }
568
+ /* 显示监督员 */
569
+ that.showPatrolCurrentPosition = function (jsonInfo, zoom, bClear, hStyleID, clickCallback) {
570
+ if (scene == null)
571
+ return;
572
+
573
+ var args = Array.prototype.slice.call(arguments);
574
+ if (arguments[arguments.length - 1] instanceof Function) {
575
+ clickCallback = arguments[arguments.length - 1];
576
+ args = args.slice(0, args.length - 1);
577
+ }
578
+
579
+ if (clickCallback) {
580
+ that.removeEventBind("showPatrolCurrentPositionCallback");
581
+ that.bindEvent("showPatrolCurrentPositionCallback", function (evt) {
582
+ clickCallback(evt.args);
583
+ });
584
+ }
585
+ scene.fire((msgPrefix + ":showPatrolCurrentPosition"), { args: args }, parentScene, false);
586
+ }
587
+ /* 获取缓冲区 */
588
+ that.getBuffer = function (layerID, x, y, radius,getBufferCallback) {
589
+ if (scene == null)
590
+ return;
591
+
592
+ var args = Array.prototype.slice.call(arguments);
593
+ if (arguments[arguments.length - 1] instanceof Function) {
594
+ getBufferCallback = arguments[arguments.length - 1];
595
+ args = args.slice(0, args.length - 1);
596
+ }
597
+
598
+ if (getBufferCallback) {
599
+ that.removeEventBind("getBufferCallback");
600
+ that.bindEvent("getBufferCallback", function (evt) {
601
+ getBufferCallback(evt.args);
602
+ });
603
+ }
604
+ scene.fire((msgPrefix + ":getBuffer"), {args: args}, parentScene, true);
605
+ }
606
+ /* 获取多点的缓冲区 */
607
+ that.getMultiPointBuffer = function(points, radius){
608
+ if (scene == null)
609
+ return;
610
+ scene.fire((msgPrefix + ":getMultiPointBuffer"), {args: args}, parentScene, true);
611
+
612
+ }
613
+ /**
614
+ * 设置指定图层的样式
615
+ * @param id 元素的id
616
+ * @param tag 图层的标签
617
+ * @param style 图层样式
618
+ * @returns
619
+ */
620
+ that.setGraphicStyle = function(id, tag, style){
621
+ if (scene == null)
622
+ return;
623
+ scene.fire((msgPrefix + ":setGraphicStyle"), {args: args}, parentScene, true);
624
+ }
625
+ /* 显示监督员责任网格 */
626
+ that.showPatrolDutygridCells = function(infoJson, zoom, clickCallback) {
627
+ if (scene == null)
628
+ return;
629
+
630
+ var layerID = infoJson.layerID;
631
+ var layerKeyFieldName = infoJson.keyFieldName;
632
+ var cellID = infoJson.grids;
633
+ var bClearMap = false;
634
+ var gridCellStyle = {};
635
+ gridCellStyle.style = { type : "esriSFS", style : "esriSFSSolid", color : [ 0, 0, 100, 76 ],
636
+ outline : { type : "esriSLS", style : "esriSLSSolid", color : [ 255, 130, 47, 255 ], width : 2 } };
637
+ gridCellStyle.hStyle = MapUtils.deepClones(true, {}, gridCellStyle.style);
638
+ that.locateFeatureByIDs(layerID, layerKeyFieldName, cellID, bClearMap, gridCellStyle.style, gridCellStyle.hStyle, zoom);
639
+ }
640
+ /* 标识位置 */
641
+ that.markMap = function(projectTypeID, eventTypeID, actPropertyID, displayStyleID, layerID, clickCallback, cellIndexName,point,symbolUrl) {
642
+ if (scene == null)
643
+ return;
644
+
645
+ // 移除监听
646
+ that.removeEventBind("markMapCallback");
647
+
648
+ //新增了layerID,因此需要兼容原来的4个参数
649
+ if (arguments.length == 5 && typeof layerID == "function"){
650
+ clickCallback = layerID;
651
+ layerID == null;
652
+ }
653
+
654
+ if (clickCallback != undefined) {
655
+ that.bindEvent("markMapCallback", function(evt) {
656
+ clickCallback(evt.args);
657
+ });
658
+ }
659
+ scene.fire(msgPrefix + ":markMap", {
660
+ args : [ projectTypeID, eventTypeID, actPropertyID, displayStyleID, layerID, cellIndexName,point, symbolUrl]
661
+ }, parentScene, false);
662
+ }
663
+ /* 案件定位 */
664
+ that.eventLocate = that.recLocate = function(eventID, defaultMapRange) {
665
+ if (scene == null)
666
+ return;
667
+
668
+ if (defaultMapRange == undefined)
669
+ defaultMapRange = 200;
670
+ scene.fire(msgPrefix + ":eventLocate", { args : [ eventID, defaultMapRange ] }, parentScene, false);
671
+ }
672
+ /* 显示特定图层 */
673
+ that.showMapLayers = function(layerTag, showLevel, mode, styles) {
674
+ if (scene == null)
675
+ return;
676
+ scene.fire(msgPrefix + ":showMapLayers", { args : [ layerTag, showLevel, mode, styles] }, parentScene, false);
677
+ }
678
+ /* 显示车辆人员轨迹 */
679
+ that.showObjectTrace = function (objectID, symbolType, dateTime, queryCondition, hideControlPanel, symbolPic, optimizeParams, infoCallback, updatePositionCallback, closeCallback, traceDigCallback) {
680
+ if (scene == null)
681
+ return;
682
+
683
+ if (closeCallback) {
684
+ that.removeEventBind("TraceManagerCloseCallback");
685
+ that.bindEvent("TraceManagerCloseCallback", function () {
686
+ closeCallback();
687
+ });
688
+ }
689
+ if (infoCallback) {
690
+ that.removeEventBind("showObjectTraceCallback");
691
+ that.bindEvent("showObjectTraceCallback", function (evt) {
692
+ infoCallback(evt && evt.args);
693
+ });
694
+ }
695
+ if (updatePositionCallback) {
696
+ that.removeEventBind("updatePositionCallback");
697
+ that.bindEvent("updatePositionCallback", function (evt) {
698
+ updatePositionCallback(evt && evt.args);
699
+ });
700
+ }
701
+ if (traceDigCallback) {
702
+ that.removeEventBind("getPatrolTraceDigCallback");
703
+ that.bindEvent("getPatrolTraceDigCallback", function (evt) {
704
+ traceDigCallback(evt && evt.args);
705
+ });
706
+ }
707
+ /*if (context.sysConfig['PATROL_POS_WRITE_TO_FILE']) {
708
+ if (queryCondition) {
709
+ queryCondition = $.extend({}, queryCondition, { 'resourcetype': 2 });
710
+ } else {
711
+ queryCondition = { 'resourcetype': 2 };
712
+ }
713
+ }*/
714
+ scene.fire(msgPrefix + ":showObjectTrace", { args: [objectID, symbolType, dateTime, queryCondition, hideControlPanel, symbolPic, optimizeParams] }, parentScene);
715
+ }
716
+
717
+ /*跳转轨迹位置*/
718
+ that.updatePositionByTime =function(time){
719
+ if (scene == null)
720
+ return;
721
+ scene.fire(msgPrefix + ":updatePositionByTime", { args: [time] }, parentScene);
722
+ }
723
+
724
+ /**
725
+ *轨迹开始播放/暂停
726
+ **/
727
+ that.playObjectTrace = function (speed,doNotChangeState) {
728
+ scene.fire(msgPrefix + ":playObjectTrace", { args: [speed,doNotChangeState] },
729
+ parentScene);
730
+ }
731
+
732
+ /**
733
+ *轨迹停止
734
+ **/
735
+ that.stopObjectTrace = function(){
736
+ scene.fire(msgPrefix + ":stopObjectTrace", { args: [] },
737
+ parentScene);
738
+ }
739
+
740
+ /**
741
+ *更新轨迹播放速度
742
+ **/
743
+ that.updatePlaySpeed = function(value){
744
+ scene.fire(msgPrefix + ":updatePlaySpeed", { args: [value] },
745
+ parentScene);
746
+ }
747
+
748
+ /**
749
+ *停止绘制要素
750
+ **/
751
+ that.stopDraw = function(){
752
+ scene.fire(msgPrefix + ":stopDraw", { args: [] },
753
+ parentScene);
754
+ }
755
+
756
+ /**
757
+ *等值面生成
758
+ **/
759
+ that.isobands = function(attrarry,xarry,yarry,breaks,breakcolors,cellwidth,boundary,hascelllabel,labelcolor,callback, options){
760
+ scene.fire(msgPrefix + ":isobands", { args: [attrarry,xarry,yarry,breaks,breakcolors,cellwidth,boundary,hascelllabel,labelcolor,callback, options] },
761
+ parentScene);
762
+ }
763
+
764
+ //by ysj,2020-06-02
765
+ that.checkObjectTraceItem = function (type,boolean) {
766
+ scene.fire(msgPrefix + ":checkObjectTraceItem", { args: [type,boolean] },
767
+ parentScene);
768
+ }
769
+
770
+ /* 显示车辆人员轨迹热力的接口*/
771
+ that.showTraceHeatMap = function(objectID, symbolType,starttime,endtime,queryCondition,hidePanel) {
772
+ if (scene == null)
773
+ return;
774
+ scene.fire(msgPrefix + ":showTraceHeatMap", { args: [objectID, symbolType,starttime,endtime,queryCondition,hidePanel] }, parentScene);
775
+ };
776
+
777
+ /*添加车辆或人员轨迹*/
778
+ that.addObjectTrace = function(jsonInfo,symbolType,clear,showControlPanel){
779
+ if (scene == null)
780
+ return;
781
+ scene.fire(msgPrefix + ":addObjectTrace", {args: [jsonInfo, symbolType, clear, showControlPanel]},parentScene);
782
+ }
783
+ /* 显示第三方上报人员轨迹 */
784
+ that.showZzTaskTrace = function(objectID, symbolType, dataTime, queryCondition){
785
+ if (scene == null)
786
+ return;
787
+ scene.fire(msgPrefix + ":showObjectTrace", { args : [ objectID, symbolType, dataTime, queryCondition ]}, parentScene);
788
+ }
789
+ /* 绘制巡更路线 */
790
+ that.showPatrolRoute = function(routeList, type, bClear, editable) {
791
+ if (scene == null)
792
+ return;
793
+ if (!(routeList instanceof Array))
794
+ routeList = [ routeList ];
795
+ if (bClear == undefined)
796
+ bClear = false;
797
+ if (editable == undefined)
798
+ editable = false;
799
+
800
+ var graphics = [];
801
+ for ( var i = 0; i < routeList.length; i++) {
802
+ var route = routeList[i];
803
+ var line = [];
804
+ var attributes = [];
805
+ var graphic = { id : route.routeID + "", geometry : { paths : [ line ] }, attributes : attributes };
806
+ for ( var j = 0; j < route.pointList.length; j++) {
807
+ var point = route.pointList[j];
808
+ line.push([ point.coordinateX, point.coordinateY ]);
809
+ attributes.push(point.pointID);
810
+ }
811
+ graphics.push(graphic);
812
+ }
813
+ var style = { color : [ 255, 0, 0, 150 ], width : 2 };
814
+ if (type == "dutyGridRoute") {
815
+ style.color = [ 0, 0, 255, 150 ]
816
+ }
817
+ if (type == "patrolRoute") {
818
+ style.color = [ 0, 255, 0, 150 ]
819
+ }
820
+ scene.fire(msgPrefix + ":showPatrolRoute", { args : [ graphics, bClear, style, editable ] }, parentScene);
821
+ }
822
+ /* 添加巡更路线 */
823
+ that.addPatrolRoute = function(addCallback, editCallback) {
824
+ if (scene == null)
825
+ return;
826
+
827
+ // 移除监听
828
+ that.removeEventBind("drawPatrolRouteNewCallback");
829
+ that.removeEventBind("drawPatrolRouteEditCallback");
830
+
831
+ if (addCallback != undefined) {
832
+ that.bindEvent("drawPatrolRouteNewCallback", function(evt) {
833
+ addCallback(evt.args);
834
+ });
835
+ }
836
+ if (editCallback != undefined) {
837
+ that.bindEvent("drawPatrolRouteEditCallback", function(evt) {
838
+ editCallback(evt.args);
839
+ });
840
+ }
841
+ var style = { color : [ 255, 0, 0, 150 ], width : 2 };
842
+ scene.fire(msgPrefix + ":drawPatrolRoute", { args : [ style ] }, parentScene);
843
+ }
844
+ /* 删除巡更路线 */
845
+ that.deletePatrolRoute = function(callback, withConfirm) {
846
+ if (scene == null)
847
+ return;
848
+
849
+ // 移除监听
850
+ that.removeEventBind("deletePatrolRouteCallback");
851
+
852
+ if (callback != undefined) {
853
+ that.bindEvent("deletePatrolRouteCallback", function(evt) {
854
+ callback(evt.args);
855
+ });
856
+ }
857
+ if(withConfirm){
858
+ scene.fire(msgPrefix + ":deletePatrolRoute", { args : [false] }, parentScene);
859
+ } else {
860
+ scene.fire(msgPrefix + ":deletePatrolRoute", { args : [] }, parentScene);
861
+ }
862
+
863
+ }
864
+ /* 获取正在编辑的路线 */
865
+ that.getPatrolRouteEdit = function(callback) {
866
+ if (scene == null)
867
+ return;
868
+
869
+ // 移除监听
870
+ that.removeEventBind("getPatrolRouteEditCallback");
871
+
872
+ if (callback != undefined) {
873
+ that.bindEvent("getPatrolRouteEditCallback", function(evt) {
874
+ callback(evt.args);
875
+ });
876
+ }
877
+ scene.fire(msgPrefix + ":getPatrolRouteEdit", { args : [] }, parentScene);
878
+ }
879
+
880
+ /* 添加图形 */
881
+ var pointStyle = {};
882
+ pointStyle.style = {"type":"esriSMS","style":"esriSMSCircle","color":[255, 0, 0, 150],"size":8,"angle":0,"xoffset":0,"yoffset":0,"outline":{"color":[255, 0, 0, 150],"width":1}}
883
+ pointStyle.hStyle = MapUtils.deepClones(true, {}, pointStyle.style);
884
+ var polylineStyle = {};
885
+ polylineStyle.style ={"type":"esriSFS","style":"esriSFSSolid","color":[255, 0, 0, 150],"outline":{"type":"esriSLS","style":"esriSLSSolid","color":[0, 0, 255, 150],"width":1}};
886
+ polylineStyle.hStyle = MapUtils.deepClones(true, {}, polylineStyle.style);
887
+ var polygonStyle = {};
888
+ polygonStyle.style ={"type":"esriSFS","style":"esriSFSSolid","color":[255, 0, 0, 150],"outline":{"type":"esriSLS","style":"esriSLSSolid","color":[0, 0, 255, 150],"width":1}};
889
+ polygonStyle.hStyle = MapUtils.deepClones(true, {}, polygonStyle.style);
890
+ var styles = {"point":pointStyle, "polyline":polylineStyle, "polygon":polygonStyle};
891
+
892
+ that.getStyles = function(type, styleType) {
893
+ var result = MapUtils.deepClones(true, {}, styles[type]);
894
+ if (styleType == "esriSFSDiagonalCross") {
895
+ result.style.type = "esriPFS";
896
+ result.style.width = 10;
897
+ result.style.height = 10;
898
+ result.style.url = "images/diagonalcross_red.png";
899
+ }else if(styleType == "esriPolygonHalfYellowTransparent"){
900
+ result.style = {"type":"esriSFS","style":"esriSFSSolid","color":[215, 214, 111, 100],"outline":{"type":"esriSLS","style":"esriSLSSolid","color":[0, 0, 255, 150],"width":1}};;
901
+ }else if(styleType == "esriPointHalfYellowTransparent"){
902
+ result.style = {"type":"esriSMS","style":"esriSMSCircle","color":[215, 214, 111, 100],"size":8,"angle":0,"xoffset":0,"yoffset":0,"outline":{"color":[255, 0, 0, 150],"width":1}};
903
+ result.hStyle =MapUtils.deepClones(true, {}, pointStyle.style);
904
+ }else if(styleType == "esriLineHalfYellowTransparent"){
905
+ result.style = {"type":"esriSFS","style":"esriSFSSolid","color":[215, 214, 111, 100],"outline":{"type":"esriSLS","style":"esriSLSSolid","color":[0, 0, 255, 150],"width":1}};
906
+ result.hStyle = MapUtils.deepClones(true, {}, pointStyle.style);
907
+ }
908
+ return result;
909
+ }
910
+ that.addGraphic = function(params, addCallback, editCallback) {
911
+ if (scene == null)
912
+ return;
913
+
914
+ // 移除监听
915
+ that.removeEventBind("drawGeometryCallback");
916
+ that.removeEventBind("drawGeometryEditCallback");
917
+
918
+ if (addCallback != undefined) {
919
+ that.bindEvent("drawGeometryCallback", function(evt) {
920
+ addCallback(evt.args);
921
+ });
922
+ }
923
+ if (editCallback != undefined) {
924
+ that.bindEvent("drawGeometryEditCallback", function(evt) {
925
+ editCallback(evt.args);
926
+ });
927
+ }
928
+ if (params[1] == null && styles[params[0]]) {
929
+ params[1] = styles[params[0]].style;
930
+ }
931
+ scene.fire(msgPrefix + ":drawGeometry", { args : params }, parentScene);
932
+ }
933
+
934
+ /* 编辑图形 */
935
+ that.editGraphic = function(params, editCallback, deleteCallback) {
936
+ if (scene == null)
937
+ return;
938
+
939
+ // 移除监听
940
+ that.removeEventBind("editGeometryCallback");
941
+ that.removeEventBind("deleteGeometryCallback");
942
+
943
+ if (editCallback != undefined) {
944
+ that.bindEvent("editGeometryCallback", function(evt) {
945
+ editCallback(evt.args);
946
+ });
947
+ }
948
+ if (deleteCallback != undefined) {
949
+ that.bindEvent("deleteGeometryCallback", function(evt) {
950
+ deleteCallback(evt.args);
951
+ });
952
+ }
953
+ if (params[3] == null) {
954
+ params[3] = styles.polygon.style;
955
+ }
956
+ scene.fire(msgPrefix + ":editGeometry", { args : params }, parentScene);
957
+ }
958
+
959
+ /* 圆饼图 */
960
+ that.addCircleChart = function(name, data, color, param) {
961
+ color = color || "#1B5771";
962
+ param = param || {minRadius: 20, rangeRadius: 20};
963
+ scene.fire(msgPrefix + ":addCircleChart", {args: [name, data, color, param]}, parentScene);
964
+ }
965
+
966
+ /* 饼图 */
967
+ //by ysj,2020-06-03
968
+ that.addChart = function (option, zoom, clickCallback, id, minZoom, maxZoom) {
969
+ that.removeEventBind("chartsLayerClickCallback");
970
+ if (clickCallback != undefined) {
971
+ that.bindEvent("chartsLayerClickCallback", function(evt) {
972
+ clickCallback(evt.args);
973
+ });
974
+ }
975
+ scene.fire(msgPrefix + ":addChart", {args: [option, zoom,id,minZoom,maxZoom]}, parentScene);
976
+ }
977
+
978
+ that.drawGeometry = function(type, style, clear, callback, option) {
979
+ type = type || "point";
980
+ style = style || {"type":"esriSLS","style":"esriSLSSolid","color":[255,0,0,255],"width":2};
981
+ //移除监听
982
+ that.removeEventBind("drawGeometryCallback");
983
+ if (callback != undefined) {
984
+ that.bindEvent("drawGeometryCallback", function(evt) {
985
+ callback(evt.args);
986
+ });
987
+ }
988
+
989
+ scene.fire(msgPrefix + ":drawGeometry", {args: [type, style, clear, callback, option]}, parentScene);
990
+ }
991
+
992
+ /* 热力图*/
993
+ that.addHeatMap = function(data, option){
994
+ scene.fire(msgPrefix + ":addHeatMap", {args: [data, option]}, parentScene);
995
+ }
996
+ /* 聚类 */
997
+ that.addClusterLayer = function(data, id){
998
+ scene.fire(msgPrefix + ":addClusterLayer", {args: [data, id]}, parentScene);
999
+ }
1000
+ /* 添加热区图层 */
1001
+ that.addHotLayer = function (layerUsageID, outFields, visiblelevel, clickCallback, style, hstyle) {
1002
+ var usageID = layerUsageID || 3007;
1003
+ var style = style || { "type": "esriSFS", "style": "esriSFSSolid", "color": [100, 100, 100, 125], "outline": { "type": "esriSLS", "style": "esriSLSSolid", "color": [255, 0, 0, 255], "width": 1 } };
1004
+ var hstyle = hstyle || { "type": "esriSFS", "style": "esriSFSSolid", "color": [100, 100, 255, 125], "outline": { "type": "esriSLS", "style": "esriSLSSolid", "color": [255, 0, 0, 255], "width": 1 } };
1005
+ var where = null;
1006
+ scene.fire(msgPrefix + ":addCustomWMSLayer", { args: [usageID, style, hstyle, where, outFields, visiblelevel] }, parentScene);
1007
+
1008
+ if (clickCallback) {
1009
+ that.removeEventBind("CustomWMSLayerMouseClick");
1010
+ that.bindEvent("CustomWMSLayerMouseClick", function (evt) {
1011
+ clickCallback(evt.args);
1012
+ });
1013
+ }
1014
+ }
1015
+
1016
+ /* 添加等值线图 */
1017
+ that.addKrigingMap = function (datalist, options) {
1018
+ scene.fire(msgPrefix + ":addKrigingMap", { args: [datalist, options] }, parentScene);
1019
+ }
1020
+
1021
+ /* 删除热区图层 */
1022
+ that.removeHotLayer = function(){
1023
+ scene.fire(msgPrefix + ":removeLayer", { args: ['CustomWMSLayer'] }, parentScene);
1024
+ }
1025
+
1026
+
1027
+ /* 图层查询 */
1028
+ that.queryPhylayerFeatures = function(params, callback) {
1029
+ // 移除监听
1030
+ that.removeEventBind("queryPhylayerFeaturesCallback");
1031
+
1032
+ if (callback != undefined) {
1033
+ that.bindEvent("queryPhylayerFeaturesCallback", function(evt) {
1034
+ callback(evt.args);
1035
+ });
1036
+ }
1037
+ scene.fire(msgPrefix + ":queryPhylayerFeatures", {args: [params.queryType, params.queryValue, params.phyLayerIDs, params.where, params.params, params.startIndex, params.maxFeatures]}, parentScene);
1038
+ }
1039
+ // /* 执行查询任务 */
1040
+ // that.executeQueryTask = function(params, callback) {
1041
+ // var queryTaskContext = {};
1042
+ // queryTaskContext.callback = callback;
1043
+ // queryTaskContext.gisSuccessFn = queryTaskContext.gisErrorFn = function(data, result) {
1044
+ // this.callback(result);
1045
+ // }
1046
+ // var queryTaskService = http.getInstance("", {type : "post", async: false, "callback": callback }, queryTaskContext.gisSuccessFn, queryTaskContext.gisErrorFn, queryTaskContext);
1047
+ // queryTaskService.settings.url = context.gisServerURL + "/home/gis/event/execquerytask.htm";
1048
+ // queryTaskService.ajax(params);
1049
+ // }
1050
+ /* 显示消息框 */
1051
+ that.showInfoWindow = function (params) {
1052
+ var visible = params.visible;
1053
+ var position = {};
1054
+ position.x = params.x;
1055
+ position.y = params.y;
1056
+ var title = params.title;
1057
+ var content = params.content;
1058
+ scene.fire(msgPrefix + ":infoWindow", { args: [visible, position, title, content] }, parentScene);
1059
+ }
1060
+ /* 隐藏消息框 */
1061
+ that.hideInfoWindow = function (params) {
1062
+ scene.fire(msgPrefix + ":infoWindow", { args: [false] }, parentScene);
1063
+ }
1064
+
1065
+
1066
+
1067
+ /* 显示扩展消息框 */
1068
+ that.showInfoWindowEx = function (params) {
1069
+ scene.fire(msgPrefix + ":showInfoWindow", {
1070
+ args: [params.id || 0, params.title, params.content, params.x, params.y, params.style, params.options]
1071
+ }, parentScene);
1072
+ }
1073
+ /* 显示扩展消息框 */
1074
+ that.hideInfoWindowEx = function (id) {
1075
+ scene.fire(msgPrefix + ":hideInfoWindow", {
1076
+ args: [id]
1077
+ }, parentScene);
1078
+ }
1079
+ /** 设置扩展消息框样式
1080
+ * option 基础样式选项,格式如:{noTitle:true,close:true,title:{},background:'#FFF'}
1081
+ * noTitle: 是否显示标题栏;
1082
+ * close: 是否显示关闭按钮;
1083
+ * title: 标题栏的css样式对象
1084
+ * background : 除标题栏外的其他部分的颜色
1085
+ * style 位置和大小的配置,格式如:{width:300,height:300,achor:'auto',offsetY:0}
1086
+ * width: 宽度
1087
+ * height:高度
1088
+ * achor:箭头方向,其中值包含 'top','left','right','bottom','auto'
1089
+ * offsetY:Y方向上的偏移
1090
+ **/
1091
+ that.setInfoWindowStyle = function (option,style,id) {
1092
+ scene.fire(msgPrefix + ":setInfoWindowStyle", {
1093
+ args: [option,style,id]
1094
+ }, parentScene);
1095
+ }
1096
+
1097
+ /* 要素查询 */
1098
+ that.queryFeature = function(params, callback) {
1099
+ if (scene == null)
1100
+ return;
1101
+ scene.fire(msgPrefix + ":queryFeature", {args: [params.layerID, params.where || null, params.geometry || null, params.outFields, params.outGeometry, params.pointTolorence||0,params.startIndex,params.maxFeatures,null,callback||null,params.sortBy, params.filterNullGeometry, params.options, params.featureIds]}, parentScene);
1102
+ }
1103
+
1104
+ /* 显示图层
1105
+ * layerID:图层ID ,
1106
+ * serviceID:服务ID(可选),
1107
+ * showAtBottom:是否显示在最底层(true:显示到最底层,false:显示在最顶层),
1108
+ * zoomLevel:缩放级别(传入数字为缩放到对应的级别,传入true缩放到最大可视级别)
1109
+ */
1110
+ that.showVectorLayer = function(layerID,serviceID,showAtBottom,zoomLevel) {
1111
+ if (scene == null)
1112
+ return;
1113
+ scene.fire(msgPrefix + ":showVectorLayer", {args: [layerID,serviceID,showAtBottom,zoomLevel]}, parentScene);
1114
+ }
1115
+
1116
+ /* 隐藏图层 */
1117
+ that.hideVectorLayer = function(layerID,serviceID) {
1118
+ if (scene == null)
1119
+ return;
1120
+ scene.fire(msgPrefix + ":hideVectorLayer", {args: [layerID,serviceID]}, parentScene);
1121
+ }
1122
+
1123
+ /* 获取当前地图范围 */
1124
+ that.getMapExtent = function(callback) {
1125
+ // 移除监听
1126
+ that.removeEventBind("getMapExtentCallback");
1127
+
1128
+ if (callback != undefined) {
1129
+ that.bindEvent("getMapExtentCallback", function(evt) {
1130
+ callback(evt.args);
1131
+ });
1132
+ }
1133
+ scene.fire(msgPrefix + ":getMapExtent", {args: []}, parentScene);
1134
+ }
1135
+
1136
+ /**查询表信息*/
1137
+ that.queryObjectInfo = function (geoShapes, tableName, xFieldName, yFieldName, callback, usePage, currentPage, numPerPage, params) {
1138
+ var queryParam = {
1139
+ 'tableName': tableName,
1140
+ 'xFieldName': xFieldName,
1141
+ 'yFieldName': yFieldName
1142
+ };
1143
+ if(params) queryParam = MapUtils.deepClones(true, {}, queryParam, params);
1144
+
1145
+ that.removeEventBind("queryObjectInfoCallback");
1146
+ that.bindEvent("queryObjectInfoCallback", callback);
1147
+ scene.fire(msgPrefix + ':queryObjectInfo', {args: [JSON.stringify(geoShapes), JSON.stringify(queryParam), usePage, currentPage, numPerPage]}, parentScene, false);
1148
+ }
1149
+
1150
+ that.enableMapSnap = function (layerID, callback) {
1151
+ if (scene == null) return;
1152
+ if(!layerID) return;
1153
+ that.removeEventBind("enableMapSnapCallback");
1154
+ that.bindEvent("enableMapSnapCallback", callback);
1155
+ scene.fire(msgPrefix + ":enableMapSnap", {
1156
+ args: [layerID]
1157
+ },parentScene);
1158
+ }
1159
+
1160
+ that.disableMapSnap = function (layerID) {
1161
+ if (scene == null) return;
1162
+ if(!layerID) return;
1163
+ scene.fire(msgPrefix + ":disableMapSnap", {
1164
+ args: [layerID]
1165
+ },parentScene);
1166
+ }
1167
+
1168
+ that.addMaskLayer = function(layerID,keyField,values,style,zoom,position) {
1169
+ scene.fire(msgPrefix + ":addMaskLayer", {args: [layerID,keyField,values,style,zoom,position]},parentScene);
1170
+ }
1171
+
1172
+ /* 计算线、面长度,支持线、面格式 */
1173
+ that.getGeometryLength = function(geometry) {
1174
+ return scene.fire(msgPrefix + ":getGeometryLength", {args: [geometry]},parentScene);
1175
+ }
1176
+
1177
+ /* 计算多边形面积 */
1178
+ that.getPolygonArea = function(geometry) {
1179
+ return scene.fire(msgPrefix + ":getPolygonArea", {args: [geometry]},parentScene);
1180
+ }
1181
+
1182
+ that.intersectGeometry = function (polygon1, polygon2) {
1183
+ return scene.fire(msgPrefix + ":intersectGeometry", {args: [polygon1, polygon2]}, parentScene);
1184
+ }
1185
+
1186
+ that.getCenterPoint = function (polygon) {
1187
+ return scene.fire(msgPrefix + ":getCenterPoint", {args: [polygon]}, parentScene);
1188
+ }
1189
+
1190
+ /* 根据PointID定位空中全景 */
1191
+ that.mmsAirPanoLocateByID = function(pointID) {
1192
+ if(mmsMap && mmsMap.mmsLoaded) {
1193
+ scene.fire(msgPrefix + ":mmsAirPanoLocateCallback", {args: [pointID]}, parentScene);
1194
+ }
1195
+ }
1196
+
1197
+ /* 空中全景历史对比回调 */
1198
+ that.mmsAirPanoCompare = function(callback) {
1199
+ if(mmsMap && mmsMap.mmsLoaded) {
1200
+ scene.fire(msgPrefix + ":mmsAirPanoCompareCallback", {args: [callback]}, parentScene);
1201
+ }
1202
+ }
1203
+
1204
+ that.setMMSEyePositionTest = function(x,y) {
1205
+ var pos = {x:x, y:y};
1206
+ var evt = {args:[pos]};
1207
+ mmsMap.setMMSEyePosition(evt);
1208
+ }
1209
+
1210
+ /* 切换地图类型 */
1211
+ that.changeControlParam = function (type, param) {
1212
+ scene.fire(msgPrefix + ":changeControlParam", { args: [type, param] }, parentScene);
1213
+ }
1214
+
1215
+ /* 获取图层信息 */
1216
+ that.getPhyLayerInfo=function (phyLayerID,getPhyLayerInfoCallBack) {
1217
+ that.removeEventBind("getPhyLayerInfoCallback");
1218
+ if (getPhyLayerInfoCallBack != undefined) {
1219
+ that.bindEvent("getPhyLayerInfoCallback", function(evt) {
1220
+ getPhyLayerInfoCallBack(evt.args);
1221
+ });
1222
+ }
1223
+ scene.fire((msgPrefix + ":getPhyLayerInfo"), {args: [phyLayerID]}, parentScene,true);
1224
+ }
1225
+
1226
+ /* 获取图层字段信息 */
1227
+ that.getPhyLayerField=function (phyLayerIDs,getPhyLayerFieldCallback) {
1228
+ that.removeEventBind("getPhyLayerFieldCallback");
1229
+ if (getPhyLayerFieldCallback != undefined) {
1230
+ that.bindEvent("getPhyLayerFieldCallback", function(evt) {
1231
+ getPhyLayerFieldCallback(evt.args);
1232
+ });
1233
+ }
1234
+ scene.fire((msgPrefix + ":getPhyLayerField"), {args: [phyLayerIDs]}, parentScene,true);
1235
+ }
1236
+
1237
+ /* 获取图层字段信息 */
1238
+ that.getPhyLayerField=function (phyLayerIDs,getPhyLayerFieldCallback) {
1239
+ that.removeEventBind("getPhyLayerFieldCallback");
1240
+ if (getPhyLayerFieldCallback != undefined) {
1241
+ that.bindEvent("getPhyLayerFieldCallback", function(evt) {
1242
+ getPhyLayerFieldCallback(evt.args);
1243
+ });
1244
+ }
1245
+ scene.fire((msgPrefix + ":getPhyLayerField"), {args: [phyLayerIDs]}, parentScene,true);
1246
+ }
1247
+
1248
+ /*对几何图形进行缓冲*/
1249
+ that.getGeometryBuffer=function(geometry,radius,callback,autoTransRadius){
1250
+ that.removeEventBind("getGeometryBufferCallback");
1251
+ if (callback != undefined) {
1252
+ that.bindEvent("getGeometryBufferCallback", function(evt) {
1253
+ callback(evt.args);
1254
+ });
1255
+ }
1256
+ scene.fire((msgPrefix + ":getGeometryBuffer"), {args: [geometry,radius,autoTransRadius]}, parentScene,true);
1257
+ }
1258
+
1259
+ /* 移除图层*/
1260
+ that.removeLayer = function(layerName){
1261
+ scene.fire((msgPrefix + ":removeLayer"), {args: [layerName]}, parentScene,true);
1262
+ }
1263
+
1264
+ that.change3dlayerUsageConfig=function(){
1265
+ if (scene == null)
1266
+ return;
1267
+ var config=scene.layerUsageConfig;
1268
+ scene.fire(msgPrefix + ":change3dlayerUsageConfig", {args: [config]}, parentScene);
1269
+ }
1270
+ /*显示多轨迹*/
1271
+ that.showTraceMultiHisLayer = function(objectIDs, symbolType, beginDate, endDate, clear, zoom, hStyle) {
1272
+ scene.fire((msgPrefix + ":showTraceMultiHisLayer"), {args: [objectIDs, symbolType, beginDate, endDate, clear, zoom, hStyle]}, parentScene);
1273
+ }
1274
+ /*清除多轨迹*/
1275
+ that.claerTraceMultiHisLayer = function() {
1276
+ scene.fire((msgPrefix + ":claerTraceMultiHisLayer"), {args: []}, parentScene);
1277
+ }
1278
+ /*多人员图标通过id高亮*/
1279
+ that.multiPointsSelectbyID = function(id) {
1280
+ scene.fire((msgPrefix + ":multiPointsSelectbyID"), {args: [id]}, parentScene);
1281
+ }
1282
+ /*多轨迹通过id高亮*/
1283
+ that.traceMultiSelectbyID = function(id) {
1284
+ scene.fire((msgPrefix + ":traceMultiSelectbyID"), {args: [id]}, parentScene);
1285
+ }
1286
+
1287
+ that.init();
1288
+ }
1289
+ export default EGovaGISMap;