egovamap 0.15.20 → 0.15.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,1282 +1,1282 @@
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
-
302
- /*根据要素坐标定位显示要素*/
303
- that.locateFeatureByCoords=function(geometries, type, ID, style, hStyle, zoom, keyFiled, labelField, labelStyle, randomColor, renderCanvas, singleSelected, options, layerTag){
304
- if (scene == null)
305
- return;
306
- scene.fire((msgPrefix + ":locateFeatureByCoords"), { args : [geometries, type, ID, style, hStyle, zoom, keyFiled, labelField, labelStyle, randomColor, renderCanvas, singleSelected, options, layerTag] }, parentScene, false);
307
- }
308
- /* 清除指定图形 */
309
- that.clearGraphic = function(id, tag) {
310
- if (scene == null)
311
- return;
312
- if (typeof id != "string") {
313
- id = id.join(",");
314
- }
315
- if (tag) {
316
- id = null;
317
- }
318
- scene.fire((msgPrefix + ":clearGraphic"), { args : [ id, tag ] }, parentScene, false);
319
- }
320
- /* 清除全部图形 */
321
- that.clearAllGraphics = function(id) {
322
- if (scene == null)
323
- return;
324
- scene.fire((msgPrefix + ":clearAllGraphics"), { args : [] }, parentScene, false);
325
- }
326
- /* 在地图上标注 */
327
- that.pointSelect = function(symbolType, zoomFalg, callback) {
328
- if (scene == null)
329
- return;
330
-
331
- // 移除监听
332
- scene.remove(msgPrefix + ":pointSelectCallback", parentScene, false);
333
-
334
- if (zoomFalg == undefined)
335
- zoomFalg = true;
336
- if (callback) {
337
- // 定义回调
338
- scene.on(msgPrefix + ":pointSelectCallback", function(evt) {
339
- // 移除监听
340
- scene.remove(msgPrefix + ":pointSelectCallback", parentScene, false);
341
- callback(evt.args);
342
- }, parentScene, false);
343
- }
344
- scene.fire(msgPrefix + ":pointSelect", { args : [ symbolType, zoomFalg ] }, parentScene, false);
345
- }
346
- /* 获取图形外部矩形 */
347
- that.getFeaturesExtent = function(features, callback) {
348
- if (scene == null)
349
- return;
350
-
351
- // 移除监听
352
- scene.remove(msgPrefix + ":getFeaturesExtentCallback", parentScene, false);
353
-
354
- scene.on(msgPrefix + ":getFeaturesExtentCallback", function(evt) {
355
- // 移除监听
356
- scene.remove(msgPrefix + ":getFeaturesExtentCallback", parentScene, false);
357
- callback(evt.args);
358
- }, parentScene, false);
359
- scene.fire((msgPrefix + ":getFeaturesExtent"), { args : features }, parentScene, false);
360
- }
361
-
362
- /* 获取可见图层 */
363
- that.getVisibleLayerIds = function (callback) {
364
- // 移除监听
365
- scene.remove(msgPrefix + ":getVisibleLayerIdsCallback", parentScene, false);
366
-
367
- scene.on(msgPrefix + ":getVisibleLayerIdsCallback", function(evt) {
368
- // 移除监听
369
- scene.remove(msgPrefix + ":getVisibleLayerIdsCallback", parentScene, false);
370
- callback(evt.args);
371
- }, parentScene, false);
372
- scene.fire((msgPrefix + ":getVisibleLayerIds"), {args: []}, parentScene, false);
373
- }
374
-
375
- that.identifyInfoWindow = function (usageID,keyValue,content,size) {
376
- if (scene == null)
377
- return;
378
- scene.fire((msgPrefix + ":identifyInfoWindow"), {args: [usageID,keyValue,content,size]}, parentScene, false);
379
-
380
- }
381
- /* 更改工具条参数 */
382
- that.changeControlParam = function (id,param) {
383
- if (scene == null)
384
- return;
385
- scene.fire((msgPrefix + ":changeControlParam"), {args: [id,param]}, parentScene, false);
386
-
387
- }
388
- /* 图层过滤显示 */
389
- that.setLayerDef = function (phyLayerID,layerDef) {
390
- if (scene == null)
391
- return;
392
- scene.fire((msgPrefix + ":setLayerDef"), {args: [phyLayerID,layerDef]}, parentScene, false);
393
-
394
- }
395
- that.setLayerColorDef=function(phyLayerIDs,colorDefs){
396
- if(scene == null)
397
- return;
398
- scene.fire((msgPrefix + ":setLayerColorDef"), {args: [phyLayerIDs,colorDefs]}, parentScene, false);
399
- }
400
-
401
- /* 显示图层树 */
402
- that.showLayerTree = function(/* humanID, mapID */openTree) {
403
- if (scene == null)
404
- return;
405
- /*
406
- * var data = null; scene.fire(msgPrefix + ":showLayerTree", {args :
407
- * [data, humanID, mapID]}, parentScene);
408
- */
409
- if (openTree == undefined || arguments.length > 1)
410
- openTree = true;
411
- scene.fire(msgPrefix + ":showLayerTree", { args : [ openTree ] }, parentScene);
412
- }
413
- /* I查询 */
414
- that.identify = function(type, humanID, mapID, options) {
415
- if (scene == null)
416
- return;
417
- scene.fire(msgPrefix + ":identify", { args : [ type, humanID, mapID ] }, parentScene);
418
-
419
- // By hth 2021/4/6: 如果传入了回调函数,则绑定执行回调函数的监听事件
420
- var cb = options && options.cb
421
- if (cb) {
422
- // 移除监听
423
- that.removeEventBind("identifySelectCallback");
424
- if (cb !== undefined && typeof cb === 'function') {
425
- that.bindEvent("identifySelectCallback", function(evt) {
426
- cb(evt.args);
427
- });
428
- }
429
- }
430
- }
431
- /* 地理编码查询 */
432
- that.geoCode = function(searchStr, callback) {
433
- if (scene == null)
434
- return;
435
- if (callback) {
436
- // 移除监听
437
- that.removeEventBind("geoCodeCallback");
438
- if (callback != undefined) {
439
- that.bindEvent("geoCodeCallback", function(evt) {
440
- callback(evt.args);
441
- });
442
- }
443
- }
444
- scene.fire(msgPrefix + ":geoCode", { args : [ searchStr ] }, parentScene);
445
- }
446
- /* 逆地理编码查询 */
447
- that.getAddressByXY = function(x, y, searchStr, radius, callback) {
448
- if (scene == null)
449
- return;
450
- if(callback) {
451
- that.removeEventBind("getAddressByXYCallback");
452
- that.bindEvent("getAddressByXYCallback", function (evt) {
453
- callback(evt.args);
454
- });
455
- }
456
- scene.fire(msgPrefix + ":getAddressByXY", { args : [ x, y, searchStr, radius ] }, parentScene);
457
- }
458
- /* 根据坐标获取单元网格 */
459
- that.getCellNameByPosXY = function(x, y, gridType) {
460
- if (scene == null)
461
- return;
462
- var args = [];
463
- var callback = null;
464
- for (var i = 0; i < arguments.length; i++) {
465
- var arg = arguments[i];
466
- if (i == arguments.length-1 && typeof(arg) == "function"){
467
- callback = arg;
468
- continue;
469
- }
470
- args.push(arg);
471
- }
472
- if (callback != null) {
473
- // 移除监听
474
- that.removeEventBind("getCellNameByPosXYCallback");
475
-
476
- function _getCellNameByPosXYCallback(evt) {
477
- that.removeEventBind("getCellNameByPosXYCallback");
478
- callback(evt.args);
479
- }
480
- that.bindEvent("getCellNameByPosXYCallback", _getCellNameByPosXYCallback);
481
- }
482
- that.fireEvent("getCellNameByPosXY", { args : args });
483
- }
484
- /* 根据图层字段定位显示 */
485
- that.locateFeatureByIDs = function (layerID, keyFiled, keyValue, clearMap, style, hStyle, bZoom, randomColor, labelfield, labelstyle, geometry, where, renderCanvas, singleSelected,options,extendProperty,layerTag,outFieldStr,animiteStep,index,clipGeom) {
486
- if (scene == null)
487
- return;
488
- if (bZoom == undefined)
489
- bZoom = false;
490
- 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] },
491
- parentScene);
492
- }
493
- /* 显示案件分布 */
494
- that.showRecListDistribution = function(infoJson, zoom, clickCallback, labelInfo,isShowLegend, symbolUrl, options) {
495
- if (scene == null || infoJson.length == 0)
496
- return;
497
- //如果xy坐标没有值不处理
498
- for(var i=0,len=infoJson.length; i<len; i++){
499
- if(!infoJson[i].coordinateX || infoJson[i].coordinateX == "" || !infoJson[i].coordinateY || infoJson[i].coordinateY == ""){
500
- return;
501
- }
502
- }
503
-
504
- // 移除监听
505
- that.removeEventBind("showRecListDistributionCallback");
506
-
507
- if (clickCallback != undefined) {
508
- that.bindEvent("showRecListDistributionCallback", function(evt) {
509
- clickCallback(evt.args);
510
- });
511
- }
512
- scene.fire((msgPrefix + ":showRecListDistribution"), { args : [ infoJson, zoom, labelInfo,isShowLegend, symbolUrl, options] }, parentScene, false);
513
-
514
- //如果启用了实景功能,同时进行实景定位
515
- if(mmsMap && infoJson.length == 1) {
516
- var recInfo = infoJson[0];
517
- if (mmsMap.mmsLoaded){
518
- if (!mmsMap.mmsVisible) {
519
- // var pos = {x:recInfo.coordinateX, y:recInfo.coordinateY};
520
- // var evt = {args:[pos]};
521
- // mmsMap.setMMSEyePosition(evt);
522
- } else {
523
- mmsMap.locateEvent(recInfo.recID, recInfo.coordinateX, recInfo.coordinateY);
524
- }
525
- }
526
- }
527
- }
528
- /* 显示多个自定义图标 */
529
- that.showMultiObjectCurrentPosition = function (jsonInfo, zoom, bClear, hStyleID, infoStyle, bCanvas, tagName, clickCallback, mouseOverCallBack, clusterOption, hasHover, layerID, mouseOutCallback, options) {
530
- if (scene == null)
531
- return;
532
- // 移除监听
533
- var clickBackName = "showMultiObjectCurrentPositionClick";
534
- var mouseOverBackName = "showMultiObjectCurrentPositionMouseover";
535
- var mouseOutBackName = "showMultiObjectCurrentPositionMouseout";
536
- if (options&&options.callbacksuffix) {
537
- clickBackName += options.callbacksuffix;
538
- mouseOverBackName += options.callbacksuffix;
539
- mouseOutBackName += options.callbacksuffix;
540
- }
541
- that.removeEventBind(clickBackName);
542
- that.removeEventBind(mouseOverBackName);
543
- that.removeEventBind(mouseOutBackName);
544
- if (clickCallback instanceof Function) {
545
- that.bindEvent(clickBackName, function(evt) {
546
- clickCallback(evt.args);
547
- });
548
- }
549
- if (mouseOverCallBack instanceof Function) {
550
- that.bindEvent(mouseOverBackName, function(evt) {
551
- mouseOverCallBack(evt.args);
552
- });
553
- }
554
- if(mouseOutCallback instanceof Function){
555
- that.bindEvent(mouseOutBackName, function(evt) {
556
- mouseOutCallback(evt.args);
557
- });
558
- }
559
- scene.fire((msgPrefix + ":showMultiObjectCurrentPosition"), {args: [jsonInfo, zoom, bClear, hStyleID, infoStyle, bCanvas, tagName, clusterOption, hasHover, layerID, options]}, parentScene, false);
560
- }
561
- /* 显示监督员 */
562
- that.showPatrolCurrentPosition = function (jsonInfo, zoom, bClear, hStyleID, clickCallback) {
563
- if (scene == null)
564
- return;
565
-
566
- var args = Array.prototype.slice.call(arguments);
567
- if (arguments[arguments.length - 1] instanceof Function) {
568
- clickCallback = arguments[arguments.length - 1];
569
- args = args.slice(0, args.length - 1);
570
- }
571
-
572
- if (clickCallback) {
573
- that.removeEventBind("showPatrolCurrentPositionCallback");
574
- that.bindEvent("showPatrolCurrentPositionCallback", function (evt) {
575
- clickCallback(evt.args);
576
- });
577
- }
578
- scene.fire((msgPrefix + ":showPatrolCurrentPosition"), { args: args }, parentScene, false);
579
- }
580
- /* 获取缓冲区 */
581
- that.getBuffer = function (layerID, x, y, radius,getBufferCallback) {
582
- if (scene == null)
583
- return;
584
-
585
- var args = Array.prototype.slice.call(arguments);
586
- if (arguments[arguments.length - 1] instanceof Function) {
587
- getBufferCallback = arguments[arguments.length - 1];
588
- args = args.slice(0, args.length - 1);
589
- }
590
-
591
- if (getBufferCallback) {
592
- that.removeEventBind("getBufferCallback");
593
- that.bindEvent("getBufferCallback", function (evt) {
594
- getBufferCallback(evt.args);
595
- });
596
- }
597
- scene.fire((msgPrefix + ":getBuffer"), {args: args}, parentScene, true);
598
- }
599
- /* 获取多点的缓冲区 */
600
- that.getMultiPointBuffer = function(points, radius){
601
- if (scene == null)
602
- return;
603
- scene.fire((msgPrefix + ":getMultiPointBuffer"), {args: args}, parentScene, true);
604
-
605
- }
606
- /**
607
- * 设置指定图层的样式
608
- * @param id 元素的id
609
- * @param tag 图层的标签
610
- * @param style 图层样式
611
- * @returns
612
- */
613
- that.setGraphicStyle = function(id, tag, style){
614
- if (scene == null)
615
- return;
616
- scene.fire((msgPrefix + ":setGraphicStyle"), {args: args}, parentScene, true);
617
- }
618
- /* 显示监督员责任网格 */
619
- that.showPatrolDutygridCells = function(infoJson, zoom, clickCallback) {
620
- if (scene == null)
621
- return;
622
-
623
- var layerID = infoJson.layerID;
624
- var layerKeyFieldName = infoJson.keyFieldName;
625
- var cellID = infoJson.grids;
626
- var bClearMap = false;
627
- var gridCellStyle = {};
628
- gridCellStyle.style = { type : "esriSFS", style : "esriSFSSolid", color : [ 0, 0, 100, 76 ],
629
- outline : { type : "esriSLS", style : "esriSLSSolid", color : [ 255, 130, 47, 255 ], width : 2 } };
630
- gridCellStyle.hStyle = MapUtils.deepClones(true, {}, gridCellStyle.style);
631
- that.locateFeatureByIDs(layerID, layerKeyFieldName, cellID, bClearMap, gridCellStyle.style, gridCellStyle.hStyle, zoom);
632
- }
633
- /* 标识位置 */
634
- that.markMap = function(projectTypeID, eventTypeID, actPropertyID, displayStyleID, layerID, clickCallback, cellIndexName,point,symbolUrl) {
635
- if (scene == null)
636
- return;
637
-
638
- // 移除监听
639
- that.removeEventBind("markMapCallback");
640
-
641
- //新增了layerID,因此需要兼容原来的4个参数
642
- if (arguments.length == 5 && typeof layerID == "function"){
643
- clickCallback = layerID;
644
- layerID == null;
645
- }
646
-
647
- if (clickCallback != undefined) {
648
- that.bindEvent("markMapCallback", function(evt) {
649
- clickCallback(evt.args);
650
- });
651
- }
652
- scene.fire(msgPrefix + ":markMap", {
653
- args : [ projectTypeID, eventTypeID, actPropertyID, displayStyleID, layerID, cellIndexName,point, symbolUrl]
654
- }, parentScene, false);
655
- }
656
- /* 案件定位 */
657
- that.eventLocate = that.recLocate = function(eventID, defaultMapRange) {
658
- if (scene == null)
659
- return;
660
-
661
- if (defaultMapRange == undefined)
662
- defaultMapRange = 200;
663
- scene.fire(msgPrefix + ":eventLocate", { args : [ eventID, defaultMapRange ] }, parentScene, false);
664
- }
665
- /* 显示特定图层 */
666
- that.showMapLayers = function(layerTag, showLevel, mode, styles) {
667
- if (scene == null)
668
- return;
669
- scene.fire(msgPrefix + ":showMapLayers", { args : [ layerTag, showLevel, mode, styles] }, parentScene, false);
670
- }
671
- /* 显示车辆人员轨迹 */
672
- that.showObjectTrace = function (objectID, symbolType, dateTime, queryCondition, hideControlPanel, symbolPic, optimizeParams, infoCallback, updatePositionCallback, closeCallback, traceDigCallback) {
673
- if (scene == null)
674
- return;
675
-
676
- if (closeCallback) {
677
- that.removeEventBind("TraceManagerCloseCallback");
678
- that.bindEvent("TraceManagerCloseCallback", function () {
679
- closeCallback();
680
- });
681
- }
682
- if (infoCallback) {
683
- that.removeEventBind("showObjectTraceCallback");
684
- that.bindEvent("showObjectTraceCallback", function (evt) {
685
- infoCallback(evt && evt.args);
686
- });
687
- }
688
- if (updatePositionCallback) {
689
- that.removeEventBind("updatePositionCallback");
690
- that.bindEvent("updatePositionCallback", function (evt) {
691
- updatePositionCallback(evt && evt.args);
692
- });
693
- }
694
- if (traceDigCallback) {
695
- that.removeEventBind("getPatrolTraceDigCallback");
696
- that.bindEvent("getPatrolTraceDigCallback", function (evt) {
697
- traceDigCallback(evt && evt.args);
698
- });
699
- }
700
- /*if (context.sysConfig['PATROL_POS_WRITE_TO_FILE']) {
701
- if (queryCondition) {
702
- queryCondition = $.extend({}, queryCondition, { 'resourcetype': 2 });
703
- } else {
704
- queryCondition = { 'resourcetype': 2 };
705
- }
706
- }*/
707
- scene.fire(msgPrefix + ":showObjectTrace", { args: [objectID, symbolType, dateTime, queryCondition, hideControlPanel, symbolPic, optimizeParams] }, parentScene);
708
- }
709
-
710
- /*跳转轨迹位置*/
711
- that.updatePositionByTime =function(time){
712
- if (scene == null)
713
- return;
714
- scene.fire(msgPrefix + ":updatePositionByTime", { args: [time] }, parentScene);
715
- }
716
-
717
- /**
718
- *轨迹开始播放/暂停
719
- **/
720
- that.playObjectTrace = function (speed,doNotChangeState) {
721
- scene.fire(msgPrefix + ":playObjectTrace", { args: [speed,doNotChangeState] },
722
- parentScene);
723
- }
724
-
725
- /**
726
- *轨迹停止
727
- **/
728
- that.stopObjectTrace = function(){
729
- scene.fire(msgPrefix + ":stopObjectTrace", { args: [] },
730
- parentScene);
731
- }
732
-
733
- /**
734
- *更新轨迹播放速度
735
- **/
736
- that.updatePlaySpeed = function(value){
737
- scene.fire(msgPrefix + ":updatePlaySpeed", { args: [value] },
738
- parentScene);
739
- }
740
-
741
- /**
742
- *停止绘制要素
743
- **/
744
- that.stopDraw = function(){
745
- scene.fire(msgPrefix + ":stopDraw", { args: [] },
746
- parentScene);
747
- }
748
-
749
- /**
750
- *等值面生成
751
- **/
752
- that.isobands = function(attrarry,xarry,yarry,breaks,breakcolors,cellwidth,boundary,hascelllabel,labelcolor,callback){
753
- scene.fire(msgPrefix + ":isobands", { args: [attrarry,xarry,yarry,breaks,breakcolors,cellwidth,boundary,hascelllabel,labelcolor,callback] },
754
- parentScene);
755
- }
756
-
757
- //by ysj,2020-06-02
758
- that.checkObjectTraceItem = function (type,boolean) {
759
- scene.fire(msgPrefix + ":checkObjectTraceItem", { args: [type,boolean] },
760
- parentScene);
761
- }
762
-
763
- /* 显示车辆人员轨迹热力的接口*/
764
- that.showTraceHeatMap = function(objectID, symbolType,starttime,endtime,queryCondition,hidePanel) {
765
- if (scene == null)
766
- return;
767
- scene.fire(msgPrefix + ":showTraceHeatMap", { args: [objectID, symbolType,starttime,endtime,queryCondition,hidePanel] }, parentScene);
768
- };
769
-
770
- /*添加车辆或人员轨迹*/
771
- that.addObjectTrace = function(jsonInfo,symbolType,clear,showControlPanel){
772
- if (scene == null)
773
- return;
774
- scene.fire(msgPrefix + ":addObjectTrace", {args: [jsonInfo, symbolType, clear, showControlPanel]},parentScene);
775
- }
776
- /* 显示第三方上报人员轨迹 */
777
- that.showZzTaskTrace = function(objectID, symbolType, dataTime, queryCondition){
778
- if (scene == null)
779
- return;
780
- scene.fire(msgPrefix + ":showObjectTrace", { args : [ objectID, symbolType, dataTime, queryCondition ]}, parentScene);
781
- }
782
- /* 绘制巡更路线 */
783
- that.showPatrolRoute = function(routeList, type, bClear, editable) {
784
- if (scene == null)
785
- return;
786
- if (!(routeList instanceof Array))
787
- routeList = [ routeList ];
788
- if (bClear == undefined)
789
- bClear = false;
790
- if (editable == undefined)
791
- editable = false;
792
-
793
- var graphics = [];
794
- for ( var i = 0; i < routeList.length; i++) {
795
- var route = routeList[i];
796
- var line = [];
797
- var attributes = [];
798
- var graphic = { id : route.routeID + "", geometry : { paths : [ line ] }, attributes : attributes };
799
- for ( var j = 0; j < route.pointList.length; j++) {
800
- var point = route.pointList[j];
801
- line.push([ point.coordinateX, point.coordinateY ]);
802
- attributes.push(point.pointID);
803
- }
804
- graphics.push(graphic);
805
- }
806
- var style = { color : [ 255, 0, 0, 150 ], width : 2 };
807
- if (type == "dutyGridRoute") {
808
- style.color = [ 0, 0, 255, 150 ]
809
- }
810
- if (type == "patrolRoute") {
811
- style.color = [ 0, 255, 0, 150 ]
812
- }
813
- scene.fire(msgPrefix + ":showPatrolRoute", { args : [ graphics, bClear, style, editable ] }, parentScene);
814
- }
815
- /* 添加巡更路线 */
816
- that.addPatrolRoute = function(addCallback, editCallback) {
817
- if (scene == null)
818
- return;
819
-
820
- // 移除监听
821
- that.removeEventBind("drawPatrolRouteNewCallback");
822
- that.removeEventBind("drawPatrolRouteEditCallback");
823
-
824
- if (addCallback != undefined) {
825
- that.bindEvent("drawPatrolRouteNewCallback", function(evt) {
826
- addCallback(evt.args);
827
- });
828
- }
829
- if (editCallback != undefined) {
830
- that.bindEvent("drawPatrolRouteEditCallback", function(evt) {
831
- editCallback(evt.args);
832
- });
833
- }
834
- var style = { color : [ 255, 0, 0, 150 ], width : 2 };
835
- scene.fire(msgPrefix + ":drawPatrolRoute", { args : [ style ] }, parentScene);
836
- }
837
- /* 删除巡更路线 */
838
- that.deletePatrolRoute = function(callback, withConfirm) {
839
- if (scene == null)
840
- return;
841
-
842
- // 移除监听
843
- that.removeEventBind("deletePatrolRouteCallback");
844
-
845
- if (callback != undefined) {
846
- that.bindEvent("deletePatrolRouteCallback", function(evt) {
847
- callback(evt.args);
848
- });
849
- }
850
- if(withConfirm){
851
- scene.fire(msgPrefix + ":deletePatrolRoute", { args : [false] }, parentScene);
852
- } else {
853
- scene.fire(msgPrefix + ":deletePatrolRoute", { args : [] }, parentScene);
854
- }
855
-
856
- }
857
- /* 获取正在编辑的路线 */
858
- that.getPatrolRouteEdit = function(callback) {
859
- if (scene == null)
860
- return;
861
-
862
- // 移除监听
863
- that.removeEventBind("getPatrolRouteEditCallback");
864
-
865
- if (callback != undefined) {
866
- that.bindEvent("getPatrolRouteEditCallback", function(evt) {
867
- callback(evt.args);
868
- });
869
- }
870
- scene.fire(msgPrefix + ":getPatrolRouteEdit", { args : [] }, parentScene);
871
- }
872
-
873
- /* 添加图形 */
874
- var pointStyle = {};
875
- 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}}
876
- pointStyle.hStyle = MapUtils.deepClones(true, {}, pointStyle.style);
877
- var polylineStyle = {};
878
- polylineStyle.style ={"type":"esriSFS","style":"esriSFSSolid","color":[255, 0, 0, 150],"outline":{"type":"esriSLS","style":"esriSLSSolid","color":[0, 0, 255, 150],"width":1}};
879
- polylineStyle.hStyle = MapUtils.deepClones(true, {}, polylineStyle.style);
880
- var polygonStyle = {};
881
- polygonStyle.style ={"type":"esriSFS","style":"esriSFSSolid","color":[255, 0, 0, 150],"outline":{"type":"esriSLS","style":"esriSLSSolid","color":[0, 0, 255, 150],"width":1}};
882
- polygonStyle.hStyle = MapUtils.deepClones(true, {}, polygonStyle.style);
883
- var styles = {"point":pointStyle, "polyline":polylineStyle, "polygon":polygonStyle};
884
-
885
- that.getStyles = function(type, styleType) {
886
- var result = MapUtils.deepClones(true, {}, styles[type]);
887
- if (styleType == "esriSFSDiagonalCross") {
888
- result.style.type = "esriPFS";
889
- result.style.width = 10;
890
- result.style.height = 10;
891
- result.style.url = "images/diagonalcross_red.png";
892
- }else if(styleType == "esriPolygonHalfYellowTransparent"){
893
- result.style = {"type":"esriSFS","style":"esriSFSSolid","color":[215, 214, 111, 100],"outline":{"type":"esriSLS","style":"esriSLSSolid","color":[0, 0, 255, 150],"width":1}};;
894
- }else if(styleType == "esriPointHalfYellowTransparent"){
895
- 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}};
896
- result.hStyle =MapUtils.deepClones(true, {}, pointStyle.style);
897
- }else if(styleType == "esriLineHalfYellowTransparent"){
898
- result.style = {"type":"esriSFS","style":"esriSFSSolid","color":[215, 214, 111, 100],"outline":{"type":"esriSLS","style":"esriSLSSolid","color":[0, 0, 255, 150],"width":1}};
899
- result.hStyle = MapUtils.deepClones(true, {}, pointStyle.style);
900
- }
901
- return result;
902
- }
903
- that.addGraphic = function(params, addCallback, editCallback) {
904
- if (scene == null)
905
- return;
906
-
907
- // 移除监听
908
- that.removeEventBind("drawGeometryCallback");
909
- that.removeEventBind("drawGeometryEditCallback");
910
-
911
- if (addCallback != undefined) {
912
- that.bindEvent("drawGeometryCallback", function(evt) {
913
- addCallback(evt.args);
914
- });
915
- }
916
- if (editCallback != undefined) {
917
- that.bindEvent("drawGeometryEditCallback", function(evt) {
918
- editCallback(evt.args);
919
- });
920
- }
921
- if (params[1] == null && styles[params[0]]) {
922
- params[1] = styles[params[0]].style;
923
- }
924
- scene.fire(msgPrefix + ":drawGeometry", { args : params }, parentScene);
925
- }
926
-
927
- /* 编辑图形 */
928
- that.editGraphic = function(params, editCallback, deleteCallback) {
929
- if (scene == null)
930
- return;
931
-
932
- // 移除监听
933
- that.removeEventBind("editGeometryCallback");
934
- that.removeEventBind("deleteGeometryCallback");
935
-
936
- if (editCallback != undefined) {
937
- that.bindEvent("editGeometryCallback", function(evt) {
938
- editCallback(evt.args);
939
- });
940
- }
941
- if (deleteCallback != undefined) {
942
- that.bindEvent("deleteGeometryCallback", function(evt) {
943
- deleteCallback(evt.args);
944
- });
945
- }
946
- if (params[3] == null) {
947
- params[3] = styles.polygon.style;
948
- }
949
- scene.fire(msgPrefix + ":editGeometry", { args : params }, parentScene);
950
- }
951
-
952
- /* 圆饼图 */
953
- that.addCircleChart = function(name, data, color, param) {
954
- color = color || "#1B5771";
955
- param = param || {minRadius: 20, rangeRadius: 20};
956
- scene.fire(msgPrefix + ":addCircleChart", {args: [name, data, color, param]}, parentScene);
957
- }
958
-
959
- /* 饼图 */
960
- //by ysj,2020-06-03
961
- that.addChart = function (option, zoom, clickCallback, id, minZoom, maxZoom) {
962
- that.removeEventBind("chartsLayerClickCallback");
963
- if (clickCallback != undefined) {
964
- that.bindEvent("chartsLayerClickCallback", function(evt) {
965
- clickCallback(evt.args);
966
- });
967
- }
968
- scene.fire(msgPrefix + ":addChart", {args: [option, zoom,id,minZoom,maxZoom]}, parentScene);
969
- }
970
-
971
- that.drawGeometry = function(type, style, clear, callback, option) {
972
- type = type || "point";
973
- style = style || {"type":"esriSLS","style":"esriSLSSolid","color":[255,0,0,255],"width":2};
974
- //移除监听
975
- that.removeEventBind("drawGeometryCallback");
976
- if (callback != undefined) {
977
- that.bindEvent("drawGeometryCallback", function(evt) {
978
- callback(evt.args);
979
- });
980
- }
981
-
982
- scene.fire(msgPrefix + ":drawGeometry", {args: [type, style, clear, callback, option]}, parentScene);
983
- }
984
-
985
- /* 热力图*/
986
- that.addHeatMap = function(data, option){
987
- scene.fire(msgPrefix + ":addHeatMap", {args: [data, option]}, parentScene);
988
- }
989
- /* 聚类 */
990
- that.addClusterLayer = function(data, id){
991
- scene.fire(msgPrefix + ":addClusterLayer", {args: [data, id]}, parentScene);
992
- }
993
- /* 添加热区图层 */
994
- that.addHotLayer = function (layerUsageID, outFields, visiblelevel, clickCallback, style, hstyle) {
995
- var usageID = layerUsageID || 3007;
996
- var style = style || { "type": "esriSFS", "style": "esriSFSSolid", "color": [100, 100, 100, 125], "outline": { "type": "esriSLS", "style": "esriSLSSolid", "color": [255, 0, 0, 255], "width": 1 } };
997
- var hstyle = hstyle || { "type": "esriSFS", "style": "esriSFSSolid", "color": [100, 100, 255, 125], "outline": { "type": "esriSLS", "style": "esriSLSSolid", "color": [255, 0, 0, 255], "width": 1 } };
998
- var where = null;
999
- scene.fire(msgPrefix + ":addCustomWMSLayer", { args: [usageID, style, hstyle, where, outFields, visiblelevel] }, parentScene);
1000
-
1001
- if (clickCallback) {
1002
- that.removeEventBind("CustomWMSLayerMouseClick");
1003
- that.bindEvent("CustomWMSLayerMouseClick", function (evt) {
1004
- clickCallback(evt.args);
1005
- });
1006
- }
1007
- }
1008
-
1009
- /* 添加等值线图 */
1010
- that.addKrigingMap = function (datalist, options) {
1011
- scene.fire(msgPrefix + ":addKrigingMap", { args: [datalist, options] }, parentScene);
1012
- }
1013
-
1014
- /* 删除热区图层 */
1015
- that.removeHotLayer = function(){
1016
- scene.fire(msgPrefix + ":removeLayer", { args: ['CustomWMSLayer'] }, parentScene);
1017
- }
1018
-
1019
-
1020
- /* 图层查询 */
1021
- that.queryPhylayerFeatures = function(params, callback) {
1022
- // 移除监听
1023
- that.removeEventBind("queryPhylayerFeaturesCallback");
1024
-
1025
- if (callback != undefined) {
1026
- that.bindEvent("queryPhylayerFeaturesCallback", function(evt) {
1027
- callback(evt.args);
1028
- });
1029
- }
1030
- scene.fire(msgPrefix + ":queryPhylayerFeatures", {args: [params.queryType, params.queryValue, params.phyLayerIDs, params.where, params.params, params.startIndex, params.maxFeatures]}, parentScene);
1031
- }
1032
- // /* 执行查询任务 */
1033
- // that.executeQueryTask = function(params, callback) {
1034
- // var queryTaskContext = {};
1035
- // queryTaskContext.callback = callback;
1036
- // queryTaskContext.gisSuccessFn = queryTaskContext.gisErrorFn = function(data, result) {
1037
- // this.callback(result);
1038
- // }
1039
- // var queryTaskService = http.getInstance("", {type : "post", async: false, "callback": callback }, queryTaskContext.gisSuccessFn, queryTaskContext.gisErrorFn, queryTaskContext);
1040
- // queryTaskService.settings.url = context.gisServerURL + "/home/gis/event/execquerytask.htm";
1041
- // queryTaskService.ajax(params);
1042
- // }
1043
- /* 显示消息框 */
1044
- that.showInfoWindow = function (params) {
1045
- var visible = params.visible;
1046
- var position = {};
1047
- position.x = params.x;
1048
- position.y = params.y;
1049
- var title = params.title;
1050
- var content = params.content;
1051
- scene.fire(msgPrefix + ":infoWindow", { args: [visible, position, title, content] }, parentScene);
1052
- }
1053
- /* 隐藏消息框 */
1054
- that.hideInfoWindow = function (params) {
1055
- scene.fire(msgPrefix + ":infoWindow", { args: [false] }, parentScene);
1056
- }
1057
-
1058
-
1059
-
1060
- /* 显示扩展消息框 */
1061
- that.showInfoWindowEx = function (params) {
1062
- scene.fire(msgPrefix + ":showInfoWindow", {
1063
- args: [params.id || 0, params.title, params.content, params.x, params.y, params.style, params.options]
1064
- }, parentScene);
1065
- }
1066
- /* 显示扩展消息框 */
1067
- that.hideInfoWindowEx = function (id) {
1068
- scene.fire(msgPrefix + ":hideInfoWindow", {
1069
- args: [id]
1070
- }, parentScene);
1071
- }
1072
- /** 设置扩展消息框样式
1073
- * option 基础样式选项,格式如:{noTitle:true,close:true,title:{},background:'#FFF'}
1074
- * noTitle: 是否显示标题栏;
1075
- * close: 是否显示关闭按钮;
1076
- * title: 标题栏的css样式对象
1077
- * background : 除标题栏外的其他部分的颜色
1078
- * style 位置和大小的配置,格式如:{width:300,height:300,achor:'auto',offsetY:0}
1079
- * width: 宽度
1080
- * height:高度
1081
- * achor:箭头方向,其中值包含 'top','left','right','bottom','auto'
1082
- * offsetY:Y方向上的偏移
1083
- **/
1084
- that.setInfoWindowStyle = function (option,style,id) {
1085
- scene.fire(msgPrefix + ":setInfoWindowStyle", {
1086
- args: [option,style,id]
1087
- }, parentScene);
1088
- }
1089
-
1090
- /* 要素查询 */
1091
- that.queryFeature = function(params, callback) {
1092
- if (scene == null)
1093
- return;
1094
- 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]}, parentScene);
1095
- }
1096
-
1097
- /* 显示图层
1098
- * layerID:图层ID ,
1099
- * serviceID:服务ID(可选),
1100
- * showAtBottom:是否显示在最底层(true:显示到最底层,false:显示在最顶层),
1101
- * zoomLevel:缩放级别(传入数字为缩放到对应的级别,传入true缩放到最大可视级别)
1102
- */
1103
- that.showVectorLayer = function(layerID,serviceID,showAtBottom,zoomLevel) {
1104
- if (scene == null)
1105
- return;
1106
- scene.fire(msgPrefix + ":showVectorLayer", {args: [layerID,serviceID,showAtBottom,zoomLevel]}, parentScene);
1107
- }
1108
-
1109
- /* 隐藏图层 */
1110
- that.hideVectorLayer = function(layerID,serviceID) {
1111
- if (scene == null)
1112
- return;
1113
- scene.fire(msgPrefix + ":hideVectorLayer", {args: [layerID,serviceID]}, parentScene);
1114
- }
1115
-
1116
- /* 获取当前地图范围 */
1117
- that.getMapExtent = function(callback) {
1118
- // 移除监听
1119
- that.removeEventBind("getMapExtentCallback");
1120
-
1121
- if (callback != undefined) {
1122
- that.bindEvent("getMapExtentCallback", function(evt) {
1123
- callback(evt.args);
1124
- });
1125
- }
1126
- scene.fire(msgPrefix + ":getMapExtent", {args: []}, parentScene);
1127
- }
1128
-
1129
- /**查询表信息*/
1130
- that.queryObjectInfo = function (geoShapes, tableName, xFieldName, yFieldName, callback, usePage, currentPage, numPerPage, params) {
1131
- var queryParam = {
1132
- 'tableName': tableName,
1133
- 'xFieldName': xFieldName,
1134
- 'yFieldName': yFieldName
1135
- };
1136
- if(params) queryParam = MapUtils.deepClones(true, {}, queryParam, params);
1137
-
1138
- that.removeEventBind("queryObjectInfoCallback");
1139
- that.bindEvent("queryObjectInfoCallback", callback);
1140
- scene.fire(msgPrefix + ':queryObjectInfo', {args: [JSON.stringify(geoShapes), JSON.stringify(queryParam), usePage, currentPage, numPerPage]}, parentScene, false);
1141
- }
1142
-
1143
- that.enableMapSnap = function (layerID, callback) {
1144
- if (scene == null) return;
1145
- if(!layerID) return;
1146
- that.removeEventBind("enableMapSnapCallback");
1147
- that.bindEvent("enableMapSnapCallback", callback);
1148
- scene.fire(msgPrefix + ":enableMapSnap", {
1149
- args: [layerID]
1150
- },parentScene);
1151
- }
1152
-
1153
- that.disableMapSnap = function (layerID) {
1154
- if (scene == null) return;
1155
- if(!layerID) return;
1156
- scene.fire(msgPrefix + ":disableMapSnap", {
1157
- args: [layerID]
1158
- },parentScene);
1159
- }
1160
-
1161
- that.addMaskLayer = function(layerID,keyField,values,style,zoom,position) {
1162
- scene.fire(msgPrefix + ":addMaskLayer", {args: [layerID,keyField,values,style,zoom,position]},parentScene);
1163
- }
1164
-
1165
- /* 计算线、面长度,支持线、面格式 */
1166
- that.getGeometryLength = function(geometry) {
1167
- return scene.fire(msgPrefix + ":getGeometryLength", {args: [geometry]},parentScene);
1168
- }
1169
-
1170
- /* 计算多边形面积 */
1171
- that.getPolygonArea = function(geometry) {
1172
- return scene.fire(msgPrefix + ":getPolygonArea", {args: [geometry]},parentScene);
1173
- }
1174
-
1175
- that.intersectGeometry = function (polygon1, polygon2) {
1176
- return scene.fire(msgPrefix + ":intersectGeometry", {args: [polygon1, polygon2]}, parentScene);
1177
- }
1178
-
1179
- that.getCenterPoint = function (polygon) {
1180
- return scene.fire(msgPrefix + ":getCenterPoint", {args: [polygon]}, parentScene);
1181
- }
1182
-
1183
- /* 根据PointID定位空中全景 */
1184
- that.mmsAirPanoLocateByID = function(pointID) {
1185
- if(mmsMap && mmsMap.mmsLoaded) {
1186
- scene.fire(msgPrefix + ":mmsAirPanoLocateCallback", {args: [pointID]}, parentScene);
1187
- }
1188
- }
1189
-
1190
- /* 空中全景历史对比回调 */
1191
- that.mmsAirPanoCompare = function(callback) {
1192
- if(mmsMap && mmsMap.mmsLoaded) {
1193
- scene.fire(msgPrefix + ":mmsAirPanoCompareCallback", {args: [callback]}, parentScene);
1194
- }
1195
- }
1196
-
1197
- that.setMMSEyePositionTest = function(x,y) {
1198
- var pos = {x:x, y:y};
1199
- var evt = {args:[pos]};
1200
- mmsMap.setMMSEyePosition(evt);
1201
- }
1202
-
1203
- /* 切换地图类型 */
1204
- that.changeControlParam = function (type, param) {
1205
- scene.fire(msgPrefix + ":changeControlParam", { args: [type, param] }, parentScene);
1206
- }
1207
-
1208
- /* 获取图层信息 */
1209
- that.getPhyLayerInfo=function (phyLayerID,getPhyLayerInfoCallBack) {
1210
- that.removeEventBind("getPhyLayerInfoCallback");
1211
- if (getPhyLayerInfoCallBack != undefined) {
1212
- that.bindEvent("getPhyLayerInfoCallback", function(evt) {
1213
- getPhyLayerInfoCallBack(evt.args);
1214
- });
1215
- }
1216
- scene.fire((msgPrefix + ":getPhyLayerInfo"), {args: [phyLayerID]}, parentScene,true);
1217
- }
1218
-
1219
- /* 获取图层字段信息 */
1220
- that.getPhyLayerField=function (phyLayerIDs,getPhyLayerFieldCallback) {
1221
- that.removeEventBind("getPhyLayerFieldCallback");
1222
- if (getPhyLayerFieldCallback != undefined) {
1223
- that.bindEvent("getPhyLayerFieldCallback", function(evt) {
1224
- getPhyLayerFieldCallback(evt.args);
1225
- });
1226
- }
1227
- scene.fire((msgPrefix + ":getPhyLayerField"), {args: [phyLayerIDs]}, parentScene,true);
1228
- }
1229
-
1230
- /* 获取图层字段信息 */
1231
- that.getPhyLayerField=function (phyLayerIDs,getPhyLayerFieldCallback) {
1232
- that.removeEventBind("getPhyLayerFieldCallback");
1233
- if (getPhyLayerFieldCallback != undefined) {
1234
- that.bindEvent("getPhyLayerFieldCallback", function(evt) {
1235
- getPhyLayerFieldCallback(evt.args);
1236
- });
1237
- }
1238
- scene.fire((msgPrefix + ":getPhyLayerField"), {args: [phyLayerIDs]}, parentScene,true);
1239
- }
1240
-
1241
- /*对几何图形进行缓冲*/
1242
- that.getGeometryBuffer=function(geometry,radius,callback){
1243
- that.removeEventBind("getGeometryBufferCallback");
1244
- if (callback != undefined) {
1245
- that.bindEvent("getGeometryBufferCallback", function(evt) {
1246
- callback(evt.args);
1247
- });
1248
- }
1249
- scene.fire((msgPrefix + ":getGeometryBuffer"), {args: [geometry,radius]}, parentScene,true);
1250
- }
1251
-
1252
- /* 移除图层*/
1253
- that.removeLayer = function(layerName){
1254
- scene.fire((msgPrefix + ":removeLayer"), {args: [layerName]}, parentScene,true);
1255
- }
1256
-
1257
- that.change3dlayerUsageConfig=function(){
1258
- if (scene == null)
1259
- return;
1260
- var config=scene.layerUsageConfig;
1261
- scene.fire(msgPrefix + ":change3dlayerUsageConfig", {args: [config]}, parentScene);
1262
- }
1263
- /*显示多轨迹*/
1264
- that.showTraceMultiHisLayer = function(objectIDs, symbolType, beginDate, endDate, clear, zoom, hStyle) {
1265
- scene.fire((msgPrefix + ":showTraceMultiHisLayer"), {args: [objectIDs, symbolType, beginDate, endDate, clear, zoom, hStyle]}, parentScene);
1266
- }
1267
- /*清除多轨迹*/
1268
- that.claerTraceMultiHisLayer = function() {
1269
- scene.fire((msgPrefix + ":claerTraceMultiHisLayer"), {args: []}, parentScene);
1270
- }
1271
- /*多人员图标通过id高亮*/
1272
- that.multiPointsSelectbyID = function(id) {
1273
- scene.fire((msgPrefix + ":multiPointsSelectbyID"), {args: [id]}, parentScene);
1274
- }
1275
- /*多轨迹通过id高亮*/
1276
- that.traceMultiSelectbyID = function(id) {
1277
- scene.fire((msgPrefix + ":traceMultiSelectbyID"), {args: [id]}, parentScene);
1278
- }
1279
-
1280
- that.init();
1281
- }
1282
- 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
+
302
+ /*根据要素坐标定位显示要素*/
303
+ that.locateFeatureByCoords=function(geometries, type, ID, style, hStyle, zoom, keyFiled, labelField, labelStyle, randomColor, renderCanvas, singleSelected, options, layerTag){
304
+ if (scene == null)
305
+ return;
306
+ scene.fire((msgPrefix + ":locateFeatureByCoords"), { args : [geometries, type, ID, style, hStyle, zoom, keyFiled, labelField, labelStyle, randomColor, renderCanvas, singleSelected, options, layerTag] }, parentScene, false);
307
+ }
308
+ /* 清除指定图形 */
309
+ that.clearGraphic = function(id, tag) {
310
+ if (scene == null)
311
+ return;
312
+ if (typeof id != "string") {
313
+ id = id.join(",");
314
+ }
315
+ if (tag) {
316
+ id = null;
317
+ }
318
+ scene.fire((msgPrefix + ":clearGraphic"), { args : [ id, tag ] }, parentScene, false);
319
+ }
320
+ /* 清除全部图形 */
321
+ that.clearAllGraphics = function(id) {
322
+ if (scene == null)
323
+ return;
324
+ scene.fire((msgPrefix + ":clearAllGraphics"), { args : [] }, parentScene, false);
325
+ }
326
+ /* 在地图上标注 */
327
+ that.pointSelect = function(symbolType, zoomFalg, callback) {
328
+ if (scene == null)
329
+ return;
330
+
331
+ // 移除监听
332
+ scene.remove(msgPrefix + ":pointSelectCallback", parentScene, false);
333
+
334
+ if (zoomFalg == undefined)
335
+ zoomFalg = true;
336
+ if (callback) {
337
+ // 定义回调
338
+ scene.on(msgPrefix + ":pointSelectCallback", function(evt) {
339
+ // 移除监听
340
+ scene.remove(msgPrefix + ":pointSelectCallback", parentScene, false);
341
+ callback(evt.args);
342
+ }, parentScene, false);
343
+ }
344
+ scene.fire(msgPrefix + ":pointSelect", { args : [ symbolType, zoomFalg ] }, parentScene, false);
345
+ }
346
+ /* 获取图形外部矩形 */
347
+ that.getFeaturesExtent = function(features, callback) {
348
+ if (scene == null)
349
+ return;
350
+
351
+ // 移除监听
352
+ scene.remove(msgPrefix + ":getFeaturesExtentCallback", parentScene, false);
353
+
354
+ scene.on(msgPrefix + ":getFeaturesExtentCallback", function(evt) {
355
+ // 移除监听
356
+ scene.remove(msgPrefix + ":getFeaturesExtentCallback", parentScene, false);
357
+ callback(evt.args);
358
+ }, parentScene, false);
359
+ scene.fire((msgPrefix + ":getFeaturesExtent"), { args : features }, parentScene, false);
360
+ }
361
+
362
+ /* 获取可见图层 */
363
+ that.getVisibleLayerIds = function (callback) {
364
+ // 移除监听
365
+ scene.remove(msgPrefix + ":getVisibleLayerIdsCallback", parentScene, false);
366
+
367
+ scene.on(msgPrefix + ":getVisibleLayerIdsCallback", function(evt) {
368
+ // 移除监听
369
+ scene.remove(msgPrefix + ":getVisibleLayerIdsCallback", parentScene, false);
370
+ callback(evt.args);
371
+ }, parentScene, false);
372
+ scene.fire((msgPrefix + ":getVisibleLayerIds"), {args: []}, parentScene, false);
373
+ }
374
+
375
+ that.identifyInfoWindow = function (usageID,keyValue,content,size) {
376
+ if (scene == null)
377
+ return;
378
+ scene.fire((msgPrefix + ":identifyInfoWindow"), {args: [usageID,keyValue,content,size]}, parentScene, false);
379
+
380
+ }
381
+ /* 更改工具条参数 */
382
+ that.changeControlParam = function (id,param) {
383
+ if (scene == null)
384
+ return;
385
+ scene.fire((msgPrefix + ":changeControlParam"), {args: [id,param]}, parentScene, false);
386
+
387
+ }
388
+ /* 图层过滤显示 */
389
+ that.setLayerDef = function (phyLayerID,layerDef) {
390
+ if (scene == null)
391
+ return;
392
+ scene.fire((msgPrefix + ":setLayerDef"), {args: [phyLayerID,layerDef]}, parentScene, false);
393
+
394
+ }
395
+ that.setLayerColorDef=function(phyLayerIDs,colorDefs){
396
+ if(scene == null)
397
+ return;
398
+ scene.fire((msgPrefix + ":setLayerColorDef"), {args: [phyLayerIDs,colorDefs]}, parentScene, false);
399
+ }
400
+
401
+ /* 显示图层树 */
402
+ that.showLayerTree = function(/* humanID, mapID */openTree) {
403
+ if (scene == null)
404
+ return;
405
+ /*
406
+ * var data = null; scene.fire(msgPrefix + ":showLayerTree", {args :
407
+ * [data, humanID, mapID]}, parentScene);
408
+ */
409
+ if (openTree == undefined || arguments.length > 1)
410
+ openTree = true;
411
+ scene.fire(msgPrefix + ":showLayerTree", { args : [ openTree ] }, parentScene);
412
+ }
413
+ /* I查询 */
414
+ that.identify = function(type, humanID, mapID, options) {
415
+ if (scene == null)
416
+ return;
417
+ scene.fire(msgPrefix + ":identify", { args : [ type, humanID, mapID ] }, parentScene);
418
+
419
+ // By hth 2021/4/6: 如果传入了回调函数,则绑定执行回调函数的监听事件
420
+ var cb = options && options.cb
421
+ if (cb) {
422
+ // 移除监听
423
+ that.removeEventBind("identifySelectCallback");
424
+ if (cb !== undefined && typeof cb === 'function') {
425
+ that.bindEvent("identifySelectCallback", function(evt) {
426
+ cb(evt.args);
427
+ });
428
+ }
429
+ }
430
+ }
431
+ /* 地理编码查询 */
432
+ that.geoCode = function(searchStr, callback) {
433
+ if (scene == null)
434
+ return;
435
+ if (callback) {
436
+ // 移除监听
437
+ that.removeEventBind("geoCodeCallback");
438
+ if (callback != undefined) {
439
+ that.bindEvent("geoCodeCallback", function(evt) {
440
+ callback(evt.args);
441
+ });
442
+ }
443
+ }
444
+ scene.fire(msgPrefix + ":geoCode", { args : [ searchStr ] }, parentScene);
445
+ }
446
+ /* 逆地理编码查询 */
447
+ that.getAddressByXY = function(x, y, searchStr, radius, callback) {
448
+ if (scene == null)
449
+ return;
450
+ if(callback) {
451
+ that.removeEventBind("getAddressByXYCallback");
452
+ that.bindEvent("getAddressByXYCallback", function (evt) {
453
+ callback(evt.args);
454
+ });
455
+ }
456
+ scene.fire(msgPrefix + ":getAddressByXY", { args : [ x, y, searchStr, radius ] }, parentScene);
457
+ }
458
+ /* 根据坐标获取单元网格 */
459
+ that.getCellNameByPosXY = function(x, y, gridType) {
460
+ if (scene == null)
461
+ return;
462
+ var args = [];
463
+ var callback = null;
464
+ for (var i = 0; i < arguments.length; i++) {
465
+ var arg = arguments[i];
466
+ if (i == arguments.length-1 && typeof(arg) == "function"){
467
+ callback = arg;
468
+ continue;
469
+ }
470
+ args.push(arg);
471
+ }
472
+ if (callback != null) {
473
+ // 移除监听
474
+ that.removeEventBind("getCellNameByPosXYCallback");
475
+
476
+ function _getCellNameByPosXYCallback(evt) {
477
+ that.removeEventBind("getCellNameByPosXYCallback");
478
+ callback(evt.args);
479
+ }
480
+ that.bindEvent("getCellNameByPosXYCallback", _getCellNameByPosXYCallback);
481
+ }
482
+ that.fireEvent("getCellNameByPosXY", { args : args });
483
+ }
484
+ /* 根据图层字段定位显示 */
485
+ that.locateFeatureByIDs = function (layerID, keyFiled, keyValue, clearMap, style, hStyle, bZoom, randomColor, labelfield, labelstyle, geometry, where, renderCanvas, singleSelected,options,extendProperty,layerTag,outFieldStr,animiteStep,index,clipGeom) {
486
+ if (scene == null)
487
+ return;
488
+ if (bZoom == undefined)
489
+ bZoom = false;
490
+ 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] },
491
+ parentScene);
492
+ }
493
+ /* 显示案件分布 */
494
+ that.showRecListDistribution = function(infoJson, zoom, clickCallback, labelInfo,isShowLegend, symbolUrl, options) {
495
+ if (scene == null || infoJson.length == 0)
496
+ return;
497
+ //如果xy坐标没有值不处理
498
+ for(var i=0,len=infoJson.length; i<len; i++){
499
+ if(!infoJson[i].coordinateX || infoJson[i].coordinateX == "" || !infoJson[i].coordinateY || infoJson[i].coordinateY == ""){
500
+ return;
501
+ }
502
+ }
503
+
504
+ // 移除监听
505
+ that.removeEventBind("showRecListDistributionCallback");
506
+
507
+ if (clickCallback != undefined) {
508
+ that.bindEvent("showRecListDistributionCallback", function(evt) {
509
+ clickCallback(evt.args);
510
+ });
511
+ }
512
+ scene.fire((msgPrefix + ":showRecListDistribution"), { args : [ infoJson, zoom, labelInfo,isShowLegend, symbolUrl, options] }, parentScene, false);
513
+
514
+ //如果启用了实景功能,同时进行实景定位
515
+ if(mmsMap && infoJson.length == 1) {
516
+ var recInfo = infoJson[0];
517
+ if (mmsMap.mmsLoaded){
518
+ if (!mmsMap.mmsVisible) {
519
+ // var pos = {x:recInfo.coordinateX, y:recInfo.coordinateY};
520
+ // var evt = {args:[pos]};
521
+ // mmsMap.setMMSEyePosition(evt);
522
+ } else {
523
+ mmsMap.locateEvent(recInfo.recID, recInfo.coordinateX, recInfo.coordinateY);
524
+ }
525
+ }
526
+ }
527
+ }
528
+ /* 显示多个自定义图标 */
529
+ that.showMultiObjectCurrentPosition = function (jsonInfo, zoom, bClear, hStyleID, infoStyle, bCanvas, tagName, clickCallback, mouseOverCallBack, clusterOption, hasHover, layerID, mouseOutCallback, options) {
530
+ if (scene == null)
531
+ return;
532
+ // 移除监听
533
+ var clickBackName = "showMultiObjectCurrentPositionClick";
534
+ var mouseOverBackName = "showMultiObjectCurrentPositionMouseover";
535
+ var mouseOutBackName = "showMultiObjectCurrentPositionMouseout";
536
+ if (options&&options.callbacksuffix) {
537
+ clickBackName += options.callbacksuffix;
538
+ mouseOverBackName += options.callbacksuffix;
539
+ mouseOutBackName += options.callbacksuffix;
540
+ }
541
+ that.removeEventBind(clickBackName);
542
+ that.removeEventBind(mouseOverBackName);
543
+ that.removeEventBind(mouseOutBackName);
544
+ if (clickCallback instanceof Function) {
545
+ that.bindEvent(clickBackName, function(evt) {
546
+ clickCallback(evt.args);
547
+ });
548
+ }
549
+ if (mouseOverCallBack instanceof Function) {
550
+ that.bindEvent(mouseOverBackName, function(evt) {
551
+ mouseOverCallBack(evt.args);
552
+ });
553
+ }
554
+ if(mouseOutCallback instanceof Function){
555
+ that.bindEvent(mouseOutBackName, function(evt) {
556
+ mouseOutCallback(evt.args);
557
+ });
558
+ }
559
+ scene.fire((msgPrefix + ":showMultiObjectCurrentPosition"), {args: [jsonInfo, zoom, bClear, hStyleID, infoStyle, bCanvas, tagName, clusterOption, hasHover, layerID, options]}, parentScene, false);
560
+ }
561
+ /* 显示监督员 */
562
+ that.showPatrolCurrentPosition = function (jsonInfo, zoom, bClear, hStyleID, clickCallback) {
563
+ if (scene == null)
564
+ return;
565
+
566
+ var args = Array.prototype.slice.call(arguments);
567
+ if (arguments[arguments.length - 1] instanceof Function) {
568
+ clickCallback = arguments[arguments.length - 1];
569
+ args = args.slice(0, args.length - 1);
570
+ }
571
+
572
+ if (clickCallback) {
573
+ that.removeEventBind("showPatrolCurrentPositionCallback");
574
+ that.bindEvent("showPatrolCurrentPositionCallback", function (evt) {
575
+ clickCallback(evt.args);
576
+ });
577
+ }
578
+ scene.fire((msgPrefix + ":showPatrolCurrentPosition"), { args: args }, parentScene, false);
579
+ }
580
+ /* 获取缓冲区 */
581
+ that.getBuffer = function (layerID, x, y, radius,getBufferCallback) {
582
+ if (scene == null)
583
+ return;
584
+
585
+ var args = Array.prototype.slice.call(arguments);
586
+ if (arguments[arguments.length - 1] instanceof Function) {
587
+ getBufferCallback = arguments[arguments.length - 1];
588
+ args = args.slice(0, args.length - 1);
589
+ }
590
+
591
+ if (getBufferCallback) {
592
+ that.removeEventBind("getBufferCallback");
593
+ that.bindEvent("getBufferCallback", function (evt) {
594
+ getBufferCallback(evt.args);
595
+ });
596
+ }
597
+ scene.fire((msgPrefix + ":getBuffer"), {args: args}, parentScene, true);
598
+ }
599
+ /* 获取多点的缓冲区 */
600
+ that.getMultiPointBuffer = function(points, radius){
601
+ if (scene == null)
602
+ return;
603
+ scene.fire((msgPrefix + ":getMultiPointBuffer"), {args: args}, parentScene, true);
604
+
605
+ }
606
+ /**
607
+ * 设置指定图层的样式
608
+ * @param id 元素的id
609
+ * @param tag 图层的标签
610
+ * @param style 图层样式
611
+ * @returns
612
+ */
613
+ that.setGraphicStyle = function(id, tag, style){
614
+ if (scene == null)
615
+ return;
616
+ scene.fire((msgPrefix + ":setGraphicStyle"), {args: args}, parentScene, true);
617
+ }
618
+ /* 显示监督员责任网格 */
619
+ that.showPatrolDutygridCells = function(infoJson, zoom, clickCallback) {
620
+ if (scene == null)
621
+ return;
622
+
623
+ var layerID = infoJson.layerID;
624
+ var layerKeyFieldName = infoJson.keyFieldName;
625
+ var cellID = infoJson.grids;
626
+ var bClearMap = false;
627
+ var gridCellStyle = {};
628
+ gridCellStyle.style = { type : "esriSFS", style : "esriSFSSolid", color : [ 0, 0, 100, 76 ],
629
+ outline : { type : "esriSLS", style : "esriSLSSolid", color : [ 255, 130, 47, 255 ], width : 2 } };
630
+ gridCellStyle.hStyle = MapUtils.deepClones(true, {}, gridCellStyle.style);
631
+ that.locateFeatureByIDs(layerID, layerKeyFieldName, cellID, bClearMap, gridCellStyle.style, gridCellStyle.hStyle, zoom);
632
+ }
633
+ /* 标识位置 */
634
+ that.markMap = function(projectTypeID, eventTypeID, actPropertyID, displayStyleID, layerID, clickCallback, cellIndexName,point,symbolUrl) {
635
+ if (scene == null)
636
+ return;
637
+
638
+ // 移除监听
639
+ that.removeEventBind("markMapCallback");
640
+
641
+ //新增了layerID,因此需要兼容原来的4个参数
642
+ if (arguments.length == 5 && typeof layerID == "function"){
643
+ clickCallback = layerID;
644
+ layerID == null;
645
+ }
646
+
647
+ if (clickCallback != undefined) {
648
+ that.bindEvent("markMapCallback", function(evt) {
649
+ clickCallback(evt.args);
650
+ });
651
+ }
652
+ scene.fire(msgPrefix + ":markMap", {
653
+ args : [ projectTypeID, eventTypeID, actPropertyID, displayStyleID, layerID, cellIndexName,point, symbolUrl]
654
+ }, parentScene, false);
655
+ }
656
+ /* 案件定位 */
657
+ that.eventLocate = that.recLocate = function(eventID, defaultMapRange) {
658
+ if (scene == null)
659
+ return;
660
+
661
+ if (defaultMapRange == undefined)
662
+ defaultMapRange = 200;
663
+ scene.fire(msgPrefix + ":eventLocate", { args : [ eventID, defaultMapRange ] }, parentScene, false);
664
+ }
665
+ /* 显示特定图层 */
666
+ that.showMapLayers = function(layerTag, showLevel, mode, styles) {
667
+ if (scene == null)
668
+ return;
669
+ scene.fire(msgPrefix + ":showMapLayers", { args : [ layerTag, showLevel, mode, styles] }, parentScene, false);
670
+ }
671
+ /* 显示车辆人员轨迹 */
672
+ that.showObjectTrace = function (objectID, symbolType, dateTime, queryCondition, hideControlPanel, symbolPic, optimizeParams, infoCallback, updatePositionCallback, closeCallback, traceDigCallback) {
673
+ if (scene == null)
674
+ return;
675
+
676
+ if (closeCallback) {
677
+ that.removeEventBind("TraceManagerCloseCallback");
678
+ that.bindEvent("TraceManagerCloseCallback", function () {
679
+ closeCallback();
680
+ });
681
+ }
682
+ if (infoCallback) {
683
+ that.removeEventBind("showObjectTraceCallback");
684
+ that.bindEvent("showObjectTraceCallback", function (evt) {
685
+ infoCallback(evt && evt.args);
686
+ });
687
+ }
688
+ if (updatePositionCallback) {
689
+ that.removeEventBind("updatePositionCallback");
690
+ that.bindEvent("updatePositionCallback", function (evt) {
691
+ updatePositionCallback(evt && evt.args);
692
+ });
693
+ }
694
+ if (traceDigCallback) {
695
+ that.removeEventBind("getPatrolTraceDigCallback");
696
+ that.bindEvent("getPatrolTraceDigCallback", function (evt) {
697
+ traceDigCallback(evt && evt.args);
698
+ });
699
+ }
700
+ /*if (context.sysConfig['PATROL_POS_WRITE_TO_FILE']) {
701
+ if (queryCondition) {
702
+ queryCondition = $.extend({}, queryCondition, { 'resourcetype': 2 });
703
+ } else {
704
+ queryCondition = { 'resourcetype': 2 };
705
+ }
706
+ }*/
707
+ scene.fire(msgPrefix + ":showObjectTrace", { args: [objectID, symbolType, dateTime, queryCondition, hideControlPanel, symbolPic, optimizeParams] }, parentScene);
708
+ }
709
+
710
+ /*跳转轨迹位置*/
711
+ that.updatePositionByTime =function(time){
712
+ if (scene == null)
713
+ return;
714
+ scene.fire(msgPrefix + ":updatePositionByTime", { args: [time] }, parentScene);
715
+ }
716
+
717
+ /**
718
+ *轨迹开始播放/暂停
719
+ **/
720
+ that.playObjectTrace = function (speed,doNotChangeState) {
721
+ scene.fire(msgPrefix + ":playObjectTrace", { args: [speed,doNotChangeState] },
722
+ parentScene);
723
+ }
724
+
725
+ /**
726
+ *轨迹停止
727
+ **/
728
+ that.stopObjectTrace = function(){
729
+ scene.fire(msgPrefix + ":stopObjectTrace", { args: [] },
730
+ parentScene);
731
+ }
732
+
733
+ /**
734
+ *更新轨迹播放速度
735
+ **/
736
+ that.updatePlaySpeed = function(value){
737
+ scene.fire(msgPrefix + ":updatePlaySpeed", { args: [value] },
738
+ parentScene);
739
+ }
740
+
741
+ /**
742
+ *停止绘制要素
743
+ **/
744
+ that.stopDraw = function(){
745
+ scene.fire(msgPrefix + ":stopDraw", { args: [] },
746
+ parentScene);
747
+ }
748
+
749
+ /**
750
+ *等值面生成
751
+ **/
752
+ that.isobands = function(attrarry,xarry,yarry,breaks,breakcolors,cellwidth,boundary,hascelllabel,labelcolor,callback){
753
+ scene.fire(msgPrefix + ":isobands", { args: [attrarry,xarry,yarry,breaks,breakcolors,cellwidth,boundary,hascelllabel,labelcolor,callback] },
754
+ parentScene);
755
+ }
756
+
757
+ //by ysj,2020-06-02
758
+ that.checkObjectTraceItem = function (type,boolean) {
759
+ scene.fire(msgPrefix + ":checkObjectTraceItem", { args: [type,boolean] },
760
+ parentScene);
761
+ }
762
+
763
+ /* 显示车辆人员轨迹热力的接口*/
764
+ that.showTraceHeatMap = function(objectID, symbolType,starttime,endtime,queryCondition,hidePanel) {
765
+ if (scene == null)
766
+ return;
767
+ scene.fire(msgPrefix + ":showTraceHeatMap", { args: [objectID, symbolType,starttime,endtime,queryCondition,hidePanel] }, parentScene);
768
+ };
769
+
770
+ /*添加车辆或人员轨迹*/
771
+ that.addObjectTrace = function(jsonInfo,symbolType,clear,showControlPanel){
772
+ if (scene == null)
773
+ return;
774
+ scene.fire(msgPrefix + ":addObjectTrace", {args: [jsonInfo, symbolType, clear, showControlPanel]},parentScene);
775
+ }
776
+ /* 显示第三方上报人员轨迹 */
777
+ that.showZzTaskTrace = function(objectID, symbolType, dataTime, queryCondition){
778
+ if (scene == null)
779
+ return;
780
+ scene.fire(msgPrefix + ":showObjectTrace", { args : [ objectID, symbolType, dataTime, queryCondition ]}, parentScene);
781
+ }
782
+ /* 绘制巡更路线 */
783
+ that.showPatrolRoute = function(routeList, type, bClear, editable) {
784
+ if (scene == null)
785
+ return;
786
+ if (!(routeList instanceof Array))
787
+ routeList = [ routeList ];
788
+ if (bClear == undefined)
789
+ bClear = false;
790
+ if (editable == undefined)
791
+ editable = false;
792
+
793
+ var graphics = [];
794
+ for ( var i = 0; i < routeList.length; i++) {
795
+ var route = routeList[i];
796
+ var line = [];
797
+ var attributes = [];
798
+ var graphic = { id : route.routeID + "", geometry : { paths : [ line ] }, attributes : attributes };
799
+ for ( var j = 0; j < route.pointList.length; j++) {
800
+ var point = route.pointList[j];
801
+ line.push([ point.coordinateX, point.coordinateY ]);
802
+ attributes.push(point.pointID);
803
+ }
804
+ graphics.push(graphic);
805
+ }
806
+ var style = { color : [ 255, 0, 0, 150 ], width : 2 };
807
+ if (type == "dutyGridRoute") {
808
+ style.color = [ 0, 0, 255, 150 ]
809
+ }
810
+ if (type == "patrolRoute") {
811
+ style.color = [ 0, 255, 0, 150 ]
812
+ }
813
+ scene.fire(msgPrefix + ":showPatrolRoute", { args : [ graphics, bClear, style, editable ] }, parentScene);
814
+ }
815
+ /* 添加巡更路线 */
816
+ that.addPatrolRoute = function(addCallback, editCallback) {
817
+ if (scene == null)
818
+ return;
819
+
820
+ // 移除监听
821
+ that.removeEventBind("drawPatrolRouteNewCallback");
822
+ that.removeEventBind("drawPatrolRouteEditCallback");
823
+
824
+ if (addCallback != undefined) {
825
+ that.bindEvent("drawPatrolRouteNewCallback", function(evt) {
826
+ addCallback(evt.args);
827
+ });
828
+ }
829
+ if (editCallback != undefined) {
830
+ that.bindEvent("drawPatrolRouteEditCallback", function(evt) {
831
+ editCallback(evt.args);
832
+ });
833
+ }
834
+ var style = { color : [ 255, 0, 0, 150 ], width : 2 };
835
+ scene.fire(msgPrefix + ":drawPatrolRoute", { args : [ style ] }, parentScene);
836
+ }
837
+ /* 删除巡更路线 */
838
+ that.deletePatrolRoute = function(callback, withConfirm) {
839
+ if (scene == null)
840
+ return;
841
+
842
+ // 移除监听
843
+ that.removeEventBind("deletePatrolRouteCallback");
844
+
845
+ if (callback != undefined) {
846
+ that.bindEvent("deletePatrolRouteCallback", function(evt) {
847
+ callback(evt.args);
848
+ });
849
+ }
850
+ if(withConfirm){
851
+ scene.fire(msgPrefix + ":deletePatrolRoute", { args : [false] }, parentScene);
852
+ } else {
853
+ scene.fire(msgPrefix + ":deletePatrolRoute", { args : [] }, parentScene);
854
+ }
855
+
856
+ }
857
+ /* 获取正在编辑的路线 */
858
+ that.getPatrolRouteEdit = function(callback) {
859
+ if (scene == null)
860
+ return;
861
+
862
+ // 移除监听
863
+ that.removeEventBind("getPatrolRouteEditCallback");
864
+
865
+ if (callback != undefined) {
866
+ that.bindEvent("getPatrolRouteEditCallback", function(evt) {
867
+ callback(evt.args);
868
+ });
869
+ }
870
+ scene.fire(msgPrefix + ":getPatrolRouteEdit", { args : [] }, parentScene);
871
+ }
872
+
873
+ /* 添加图形 */
874
+ var pointStyle = {};
875
+ 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}}
876
+ pointStyle.hStyle = MapUtils.deepClones(true, {}, pointStyle.style);
877
+ var polylineStyle = {};
878
+ polylineStyle.style ={"type":"esriSFS","style":"esriSFSSolid","color":[255, 0, 0, 150],"outline":{"type":"esriSLS","style":"esriSLSSolid","color":[0, 0, 255, 150],"width":1}};
879
+ polylineStyle.hStyle = MapUtils.deepClones(true, {}, polylineStyle.style);
880
+ var polygonStyle = {};
881
+ polygonStyle.style ={"type":"esriSFS","style":"esriSFSSolid","color":[255, 0, 0, 150],"outline":{"type":"esriSLS","style":"esriSLSSolid","color":[0, 0, 255, 150],"width":1}};
882
+ polygonStyle.hStyle = MapUtils.deepClones(true, {}, polygonStyle.style);
883
+ var styles = {"point":pointStyle, "polyline":polylineStyle, "polygon":polygonStyle};
884
+
885
+ that.getStyles = function(type, styleType) {
886
+ var result = MapUtils.deepClones(true, {}, styles[type]);
887
+ if (styleType == "esriSFSDiagonalCross") {
888
+ result.style.type = "esriPFS";
889
+ result.style.width = 10;
890
+ result.style.height = 10;
891
+ result.style.url = "images/diagonalcross_red.png";
892
+ }else if(styleType == "esriPolygonHalfYellowTransparent"){
893
+ result.style = {"type":"esriSFS","style":"esriSFSSolid","color":[215, 214, 111, 100],"outline":{"type":"esriSLS","style":"esriSLSSolid","color":[0, 0, 255, 150],"width":1}};;
894
+ }else if(styleType == "esriPointHalfYellowTransparent"){
895
+ 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}};
896
+ result.hStyle =MapUtils.deepClones(true, {}, pointStyle.style);
897
+ }else if(styleType == "esriLineHalfYellowTransparent"){
898
+ result.style = {"type":"esriSFS","style":"esriSFSSolid","color":[215, 214, 111, 100],"outline":{"type":"esriSLS","style":"esriSLSSolid","color":[0, 0, 255, 150],"width":1}};
899
+ result.hStyle = MapUtils.deepClones(true, {}, pointStyle.style);
900
+ }
901
+ return result;
902
+ }
903
+ that.addGraphic = function(params, addCallback, editCallback) {
904
+ if (scene == null)
905
+ return;
906
+
907
+ // 移除监听
908
+ that.removeEventBind("drawGeometryCallback");
909
+ that.removeEventBind("drawGeometryEditCallback");
910
+
911
+ if (addCallback != undefined) {
912
+ that.bindEvent("drawGeometryCallback", function(evt) {
913
+ addCallback(evt.args);
914
+ });
915
+ }
916
+ if (editCallback != undefined) {
917
+ that.bindEvent("drawGeometryEditCallback", function(evt) {
918
+ editCallback(evt.args);
919
+ });
920
+ }
921
+ if (params[1] == null && styles[params[0]]) {
922
+ params[1] = styles[params[0]].style;
923
+ }
924
+ scene.fire(msgPrefix + ":drawGeometry", { args : params }, parentScene);
925
+ }
926
+
927
+ /* 编辑图形 */
928
+ that.editGraphic = function(params, editCallback, deleteCallback) {
929
+ if (scene == null)
930
+ return;
931
+
932
+ // 移除监听
933
+ that.removeEventBind("editGeometryCallback");
934
+ that.removeEventBind("deleteGeometryCallback");
935
+
936
+ if (editCallback != undefined) {
937
+ that.bindEvent("editGeometryCallback", function(evt) {
938
+ editCallback(evt.args);
939
+ });
940
+ }
941
+ if (deleteCallback != undefined) {
942
+ that.bindEvent("deleteGeometryCallback", function(evt) {
943
+ deleteCallback(evt.args);
944
+ });
945
+ }
946
+ if (params[3] == null) {
947
+ params[3] = styles.polygon.style;
948
+ }
949
+ scene.fire(msgPrefix + ":editGeometry", { args : params }, parentScene);
950
+ }
951
+
952
+ /* 圆饼图 */
953
+ that.addCircleChart = function(name, data, color, param) {
954
+ color = color || "#1B5771";
955
+ param = param || {minRadius: 20, rangeRadius: 20};
956
+ scene.fire(msgPrefix + ":addCircleChart", {args: [name, data, color, param]}, parentScene);
957
+ }
958
+
959
+ /* 饼图 */
960
+ //by ysj,2020-06-03
961
+ that.addChart = function (option, zoom, clickCallback, id, minZoom, maxZoom) {
962
+ that.removeEventBind("chartsLayerClickCallback");
963
+ if (clickCallback != undefined) {
964
+ that.bindEvent("chartsLayerClickCallback", function(evt) {
965
+ clickCallback(evt.args);
966
+ });
967
+ }
968
+ scene.fire(msgPrefix + ":addChart", {args: [option, zoom,id,minZoom,maxZoom]}, parentScene);
969
+ }
970
+
971
+ that.drawGeometry = function(type, style, clear, callback, option) {
972
+ type = type || "point";
973
+ style = style || {"type":"esriSLS","style":"esriSLSSolid","color":[255,0,0,255],"width":2};
974
+ //移除监听
975
+ that.removeEventBind("drawGeometryCallback");
976
+ if (callback != undefined) {
977
+ that.bindEvent("drawGeometryCallback", function(evt) {
978
+ callback(evt.args);
979
+ });
980
+ }
981
+
982
+ scene.fire(msgPrefix + ":drawGeometry", {args: [type, style, clear, callback, option]}, parentScene);
983
+ }
984
+
985
+ /* 热力图*/
986
+ that.addHeatMap = function(data, option){
987
+ scene.fire(msgPrefix + ":addHeatMap", {args: [data, option]}, parentScene);
988
+ }
989
+ /* 聚类 */
990
+ that.addClusterLayer = function(data, id){
991
+ scene.fire(msgPrefix + ":addClusterLayer", {args: [data, id]}, parentScene);
992
+ }
993
+ /* 添加热区图层 */
994
+ that.addHotLayer = function (layerUsageID, outFields, visiblelevel, clickCallback, style, hstyle) {
995
+ var usageID = layerUsageID || 3007;
996
+ var style = style || { "type": "esriSFS", "style": "esriSFSSolid", "color": [100, 100, 100, 125], "outline": { "type": "esriSLS", "style": "esriSLSSolid", "color": [255, 0, 0, 255], "width": 1 } };
997
+ var hstyle = hstyle || { "type": "esriSFS", "style": "esriSFSSolid", "color": [100, 100, 255, 125], "outline": { "type": "esriSLS", "style": "esriSLSSolid", "color": [255, 0, 0, 255], "width": 1 } };
998
+ var where = null;
999
+ scene.fire(msgPrefix + ":addCustomWMSLayer", { args: [usageID, style, hstyle, where, outFields, visiblelevel] }, parentScene);
1000
+
1001
+ if (clickCallback) {
1002
+ that.removeEventBind("CustomWMSLayerMouseClick");
1003
+ that.bindEvent("CustomWMSLayerMouseClick", function (evt) {
1004
+ clickCallback(evt.args);
1005
+ });
1006
+ }
1007
+ }
1008
+
1009
+ /* 添加等值线图 */
1010
+ that.addKrigingMap = function (datalist, options) {
1011
+ scene.fire(msgPrefix + ":addKrigingMap", { args: [datalist, options] }, parentScene);
1012
+ }
1013
+
1014
+ /* 删除热区图层 */
1015
+ that.removeHotLayer = function(){
1016
+ scene.fire(msgPrefix + ":removeLayer", { args: ['CustomWMSLayer'] }, parentScene);
1017
+ }
1018
+
1019
+
1020
+ /* 图层查询 */
1021
+ that.queryPhylayerFeatures = function(params, callback) {
1022
+ // 移除监听
1023
+ that.removeEventBind("queryPhylayerFeaturesCallback");
1024
+
1025
+ if (callback != undefined) {
1026
+ that.bindEvent("queryPhylayerFeaturesCallback", function(evt) {
1027
+ callback(evt.args);
1028
+ });
1029
+ }
1030
+ scene.fire(msgPrefix + ":queryPhylayerFeatures", {args: [params.queryType, params.queryValue, params.phyLayerIDs, params.where, params.params, params.startIndex, params.maxFeatures]}, parentScene);
1031
+ }
1032
+ // /* 执行查询任务 */
1033
+ // that.executeQueryTask = function(params, callback) {
1034
+ // var queryTaskContext = {};
1035
+ // queryTaskContext.callback = callback;
1036
+ // queryTaskContext.gisSuccessFn = queryTaskContext.gisErrorFn = function(data, result) {
1037
+ // this.callback(result);
1038
+ // }
1039
+ // var queryTaskService = http.getInstance("", {type : "post", async: false, "callback": callback }, queryTaskContext.gisSuccessFn, queryTaskContext.gisErrorFn, queryTaskContext);
1040
+ // queryTaskService.settings.url = context.gisServerURL + "/home/gis/event/execquerytask.htm";
1041
+ // queryTaskService.ajax(params);
1042
+ // }
1043
+ /* 显示消息框 */
1044
+ that.showInfoWindow = function (params) {
1045
+ var visible = params.visible;
1046
+ var position = {};
1047
+ position.x = params.x;
1048
+ position.y = params.y;
1049
+ var title = params.title;
1050
+ var content = params.content;
1051
+ scene.fire(msgPrefix + ":infoWindow", { args: [visible, position, title, content] }, parentScene);
1052
+ }
1053
+ /* 隐藏消息框 */
1054
+ that.hideInfoWindow = function (params) {
1055
+ scene.fire(msgPrefix + ":infoWindow", { args: [false] }, parentScene);
1056
+ }
1057
+
1058
+
1059
+
1060
+ /* 显示扩展消息框 */
1061
+ that.showInfoWindowEx = function (params) {
1062
+ scene.fire(msgPrefix + ":showInfoWindow", {
1063
+ args: [params.id || 0, params.title, params.content, params.x, params.y, params.style, params.options]
1064
+ }, parentScene);
1065
+ }
1066
+ /* 显示扩展消息框 */
1067
+ that.hideInfoWindowEx = function (id) {
1068
+ scene.fire(msgPrefix + ":hideInfoWindow", {
1069
+ args: [id]
1070
+ }, parentScene);
1071
+ }
1072
+ /** 设置扩展消息框样式
1073
+ * option 基础样式选项,格式如:{noTitle:true,close:true,title:{},background:'#FFF'}
1074
+ * noTitle: 是否显示标题栏;
1075
+ * close: 是否显示关闭按钮;
1076
+ * title: 标题栏的css样式对象
1077
+ * background : 除标题栏外的其他部分的颜色
1078
+ * style 位置和大小的配置,格式如:{width:300,height:300,achor:'auto',offsetY:0}
1079
+ * width: 宽度
1080
+ * height:高度
1081
+ * achor:箭头方向,其中值包含 'top','left','right','bottom','auto'
1082
+ * offsetY:Y方向上的偏移
1083
+ **/
1084
+ that.setInfoWindowStyle = function (option,style,id) {
1085
+ scene.fire(msgPrefix + ":setInfoWindowStyle", {
1086
+ args: [option,style,id]
1087
+ }, parentScene);
1088
+ }
1089
+
1090
+ /* 要素查询 */
1091
+ that.queryFeature = function(params, callback) {
1092
+ if (scene == null)
1093
+ return;
1094
+ 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]}, parentScene);
1095
+ }
1096
+
1097
+ /* 显示图层
1098
+ * layerID:图层ID ,
1099
+ * serviceID:服务ID(可选),
1100
+ * showAtBottom:是否显示在最底层(true:显示到最底层,false:显示在最顶层),
1101
+ * zoomLevel:缩放级别(传入数字为缩放到对应的级别,传入true缩放到最大可视级别)
1102
+ */
1103
+ that.showVectorLayer = function(layerID,serviceID,showAtBottom,zoomLevel) {
1104
+ if (scene == null)
1105
+ return;
1106
+ scene.fire(msgPrefix + ":showVectorLayer", {args: [layerID,serviceID,showAtBottom,zoomLevel]}, parentScene);
1107
+ }
1108
+
1109
+ /* 隐藏图层 */
1110
+ that.hideVectorLayer = function(layerID,serviceID) {
1111
+ if (scene == null)
1112
+ return;
1113
+ scene.fire(msgPrefix + ":hideVectorLayer", {args: [layerID,serviceID]}, parentScene);
1114
+ }
1115
+
1116
+ /* 获取当前地图范围 */
1117
+ that.getMapExtent = function(callback) {
1118
+ // 移除监听
1119
+ that.removeEventBind("getMapExtentCallback");
1120
+
1121
+ if (callback != undefined) {
1122
+ that.bindEvent("getMapExtentCallback", function(evt) {
1123
+ callback(evt.args);
1124
+ });
1125
+ }
1126
+ scene.fire(msgPrefix + ":getMapExtent", {args: []}, parentScene);
1127
+ }
1128
+
1129
+ /**查询表信息*/
1130
+ that.queryObjectInfo = function (geoShapes, tableName, xFieldName, yFieldName, callback, usePage, currentPage, numPerPage, params) {
1131
+ var queryParam = {
1132
+ 'tableName': tableName,
1133
+ 'xFieldName': xFieldName,
1134
+ 'yFieldName': yFieldName
1135
+ };
1136
+ if(params) queryParam = MapUtils.deepClones(true, {}, queryParam, params);
1137
+
1138
+ that.removeEventBind("queryObjectInfoCallback");
1139
+ that.bindEvent("queryObjectInfoCallback", callback);
1140
+ scene.fire(msgPrefix + ':queryObjectInfo', {args: [JSON.stringify(geoShapes), JSON.stringify(queryParam), usePage, currentPage, numPerPage]}, parentScene, false);
1141
+ }
1142
+
1143
+ that.enableMapSnap = function (layerID, callback) {
1144
+ if (scene == null) return;
1145
+ if(!layerID) return;
1146
+ that.removeEventBind("enableMapSnapCallback");
1147
+ that.bindEvent("enableMapSnapCallback", callback);
1148
+ scene.fire(msgPrefix + ":enableMapSnap", {
1149
+ args: [layerID]
1150
+ },parentScene);
1151
+ }
1152
+
1153
+ that.disableMapSnap = function (layerID) {
1154
+ if (scene == null) return;
1155
+ if(!layerID) return;
1156
+ scene.fire(msgPrefix + ":disableMapSnap", {
1157
+ args: [layerID]
1158
+ },parentScene);
1159
+ }
1160
+
1161
+ that.addMaskLayer = function(layerID,keyField,values,style,zoom,position) {
1162
+ scene.fire(msgPrefix + ":addMaskLayer", {args: [layerID,keyField,values,style,zoom,position]},parentScene);
1163
+ }
1164
+
1165
+ /* 计算线、面长度,支持线、面格式 */
1166
+ that.getGeometryLength = function(geometry) {
1167
+ return scene.fire(msgPrefix + ":getGeometryLength", {args: [geometry]},parentScene);
1168
+ }
1169
+
1170
+ /* 计算多边形面积 */
1171
+ that.getPolygonArea = function(geometry) {
1172
+ return scene.fire(msgPrefix + ":getPolygonArea", {args: [geometry]},parentScene);
1173
+ }
1174
+
1175
+ that.intersectGeometry = function (polygon1, polygon2) {
1176
+ return scene.fire(msgPrefix + ":intersectGeometry", {args: [polygon1, polygon2]}, parentScene);
1177
+ }
1178
+
1179
+ that.getCenterPoint = function (polygon) {
1180
+ return scene.fire(msgPrefix + ":getCenterPoint", {args: [polygon]}, parentScene);
1181
+ }
1182
+
1183
+ /* 根据PointID定位空中全景 */
1184
+ that.mmsAirPanoLocateByID = function(pointID) {
1185
+ if(mmsMap && mmsMap.mmsLoaded) {
1186
+ scene.fire(msgPrefix + ":mmsAirPanoLocateCallback", {args: [pointID]}, parentScene);
1187
+ }
1188
+ }
1189
+
1190
+ /* 空中全景历史对比回调 */
1191
+ that.mmsAirPanoCompare = function(callback) {
1192
+ if(mmsMap && mmsMap.mmsLoaded) {
1193
+ scene.fire(msgPrefix + ":mmsAirPanoCompareCallback", {args: [callback]}, parentScene);
1194
+ }
1195
+ }
1196
+
1197
+ that.setMMSEyePositionTest = function(x,y) {
1198
+ var pos = {x:x, y:y};
1199
+ var evt = {args:[pos]};
1200
+ mmsMap.setMMSEyePosition(evt);
1201
+ }
1202
+
1203
+ /* 切换地图类型 */
1204
+ that.changeControlParam = function (type, param) {
1205
+ scene.fire(msgPrefix + ":changeControlParam", { args: [type, param] }, parentScene);
1206
+ }
1207
+
1208
+ /* 获取图层信息 */
1209
+ that.getPhyLayerInfo=function (phyLayerID,getPhyLayerInfoCallBack) {
1210
+ that.removeEventBind("getPhyLayerInfoCallback");
1211
+ if (getPhyLayerInfoCallBack != undefined) {
1212
+ that.bindEvent("getPhyLayerInfoCallback", function(evt) {
1213
+ getPhyLayerInfoCallBack(evt.args);
1214
+ });
1215
+ }
1216
+ scene.fire((msgPrefix + ":getPhyLayerInfo"), {args: [phyLayerID]}, parentScene,true);
1217
+ }
1218
+
1219
+ /* 获取图层字段信息 */
1220
+ that.getPhyLayerField=function (phyLayerIDs,getPhyLayerFieldCallback) {
1221
+ that.removeEventBind("getPhyLayerFieldCallback");
1222
+ if (getPhyLayerFieldCallback != undefined) {
1223
+ that.bindEvent("getPhyLayerFieldCallback", function(evt) {
1224
+ getPhyLayerFieldCallback(evt.args);
1225
+ });
1226
+ }
1227
+ scene.fire((msgPrefix + ":getPhyLayerField"), {args: [phyLayerIDs]}, parentScene,true);
1228
+ }
1229
+
1230
+ /* 获取图层字段信息 */
1231
+ that.getPhyLayerField=function (phyLayerIDs,getPhyLayerFieldCallback) {
1232
+ that.removeEventBind("getPhyLayerFieldCallback");
1233
+ if (getPhyLayerFieldCallback != undefined) {
1234
+ that.bindEvent("getPhyLayerFieldCallback", function(evt) {
1235
+ getPhyLayerFieldCallback(evt.args);
1236
+ });
1237
+ }
1238
+ scene.fire((msgPrefix + ":getPhyLayerField"), {args: [phyLayerIDs]}, parentScene,true);
1239
+ }
1240
+
1241
+ /*对几何图形进行缓冲*/
1242
+ that.getGeometryBuffer=function(geometry,radius,callback){
1243
+ that.removeEventBind("getGeometryBufferCallback");
1244
+ if (callback != undefined) {
1245
+ that.bindEvent("getGeometryBufferCallback", function(evt) {
1246
+ callback(evt.args);
1247
+ });
1248
+ }
1249
+ scene.fire((msgPrefix + ":getGeometryBuffer"), {args: [geometry,radius]}, parentScene,true);
1250
+ }
1251
+
1252
+ /* 移除图层*/
1253
+ that.removeLayer = function(layerName){
1254
+ scene.fire((msgPrefix + ":removeLayer"), {args: [layerName]}, parentScene,true);
1255
+ }
1256
+
1257
+ that.change3dlayerUsageConfig=function(){
1258
+ if (scene == null)
1259
+ return;
1260
+ var config=scene.layerUsageConfig;
1261
+ scene.fire(msgPrefix + ":change3dlayerUsageConfig", {args: [config]}, parentScene);
1262
+ }
1263
+ /*显示多轨迹*/
1264
+ that.showTraceMultiHisLayer = function(objectIDs, symbolType, beginDate, endDate, clear, zoom, hStyle) {
1265
+ scene.fire((msgPrefix + ":showTraceMultiHisLayer"), {args: [objectIDs, symbolType, beginDate, endDate, clear, zoom, hStyle]}, parentScene);
1266
+ }
1267
+ /*清除多轨迹*/
1268
+ that.claerTraceMultiHisLayer = function() {
1269
+ scene.fire((msgPrefix + ":claerTraceMultiHisLayer"), {args: []}, parentScene);
1270
+ }
1271
+ /*多人员图标通过id高亮*/
1272
+ that.multiPointsSelectbyID = function(id) {
1273
+ scene.fire((msgPrefix + ":multiPointsSelectbyID"), {args: [id]}, parentScene);
1274
+ }
1275
+ /*多轨迹通过id高亮*/
1276
+ that.traceMultiSelectbyID = function(id) {
1277
+ scene.fire((msgPrefix + ":traceMultiSelectbyID"), {args: [id]}, parentScene);
1278
+ }
1279
+
1280
+ that.init();
1281
+ }
1282
+ export default EGovaGISMap;