egovamap 0.15.17 → 0.15.20

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