egovamap 0.35.19 → 0.35.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2535 +1,2535 @@
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 (
56
- $container,
57
- pScene,
58
- prefix,
59
- gisParams,
60
- mapConfig,
61
- context
62
- ) {
63
- var that = this;
64
- scene = pScene;
65
- var parentScene = pScene.pageId || "parentScene";
66
- var msgPrefix = prefix || "gismappage";
67
- var mmsMap = null;
68
- that.gisVisible = false;
69
- that.gisLoaded = false;
70
- that.isLoading = false;
71
-
72
- that.$gisMapFrame = null;
73
- that.gisMapContainer = null;
74
-
75
- that.gisMapContainer =
76
- $container.getElementsByClassName("emap-container")[0];
77
- if (!that.gisMapContainer) {
78
- var mapHTML = '<iframe class="emap-iframe"></iframe>';
79
- var element = document.createElement("div");
80
- element.classList.add("emap-container");
81
- element.innerHTML = mapHTML;
82
- $container.appendChild(element);
83
- that.gisMapContainer = element;
84
- }
85
-
86
- that.$gisMapFrame =
87
- that.gisMapContainer.getElementsByClassName("emap-iframe")[0];
88
- that.onMapLoadedHandlers = [];
89
-
90
- that.onMapLoaded = function () {
91
- that.isLoading = false;
92
- that.gisLoaded = true;
93
- if (context.mapCenterFlag) {
94
- if (context.mapCenterFlag == "1") {
95
- if (context.coordinateX && context.coordinateY) {
96
- that.centerAndZoom(
97
- context.coordinateX,
98
- context.coordinateY,
99
- 4
100
- );
101
- }
102
- } else if (context.mapCenterFlag == "2") {
103
- if (context.coordinateX && context.coordinateY) {
104
- that.centerAndZoom(
105
- context.coordinateX,
106
- context.coordinateY,
107
- 1
108
- );
109
- }
110
- if (context.humanLayerUsageID && context.regionCode) {
111
- var zoom = gisParams && gisParams.maskZoom == true;
112
- var style = {
113
- type: "esriSFS",
114
- style: "esriSFSSolid",
115
- color: [100, 100, 255, 125],
116
- outline: {
117
- type: "esriSLS",
118
- style: "esriSLSSolid",
119
- color: [255, 0, 0, 255],
120
- width: 1,
121
- },
122
- };
123
- var pos = { visible: true, top: 95, right: 127 };
124
- if (mapConfig && mapConfig.maskPos) {
125
- pos = MapUtils.deepClones({}, pos, mapConfig.maskPos);
126
- }
127
- that.addMaskLayer(
128
- context.humanLayerUsageID,
129
- context.humanLayerKeyFieldName,
130
- context.regionCode,
131
- style,
132
- zoom,
133
- pos
134
- );
135
- }
136
- } else if (context.mapCenterFlag == "3") {
137
- if (context.coordinateX && context.coordinateY) {
138
- that.centerAndZoom(
139
- context.coordinateX,
140
- context.coordinateY,
141
- 1
142
- );
143
- }
144
- if (context.humanLayerUsageID && context.regionCode) {
145
- var zoom = gisParams && gisParams.maskZoom == false;
146
- var style = {
147
- type: "esriSFS",
148
- style: "esriSFSSolid",
149
- color: [100, 100, 255, 0],
150
- outline: {
151
- type: "esriSLS",
152
- style: "esriSLSSolid",
153
- color: [255, 0, 0, 255],
154
- width: 3,
155
- },
156
- };
157
- var pos = { visible: true, top: 95, right: 127 };
158
- if (mapConfig && mapConfig.maskPos) {
159
- pos = MapUtils.deepClones({}, pos, mapConfig.maskPos);
160
- }
161
- that.addMaskLayer(
162
- context.humanLayerUsageID,
163
- context.humanLayerKeyFieldName,
164
- context.regionCode,
165
- style,
166
- zoom,
167
- pos
168
- );
169
- }
170
- }
171
- }
172
- for (var i = 0, len = that.onMapLoadedHandlers.length; i < len; i++) {
173
- that.onMapLoadedHandlers[i]();
174
- }
175
- };
176
-
177
- that.init = function () {
178
- if (!that.gisLoaded && !that.isLoading) {
179
- that.isLoading = true;
180
- checkGisServerURL(context.gisServerURL, function (gisurl) {
181
- var bust = new Date().getTime();
182
- var gisServerURL = (context.gisServerURL = gisurl);
183
- var gisProxyURL = context.gisServerURL + "/home/gis/proxy.htm";
184
- var misServerURL = context.rootPath;
185
- var url =
186
- context.rootPath +
187
- context.assetsPath +
188
- "/map.html?parentScene=" +
189
- parentScene +
190
- "&msgPrefix=" +
191
- msgPrefix +
192
- "&bust=" +
193
- bust +
194
- "&serverURL=" +
195
- gisServerURL +
196
- "&proxyURL=" +
197
- gisProxyURL +
198
- "&misURL=" +
199
- misServerURL +
200
- "&humanID=" +
201
- context.humanID;
202
- if (mapConfig != undefined && mapConfig.params != undefined) {
203
- for (var item in mapConfig.params) {
204
- url +=
205
- "&" +
206
- item +
207
- "=" +
208
- encodeURIComponent(mapConfig.params[item]);
209
- }
210
- }
211
- if (context.mapZoomRange) {
212
- var mapZoomRanges = context.mapZoomRange.split(",");
213
- if (mapZoomRanges.length == 2) {
214
- url +=
215
- "&minlevel=" +
216
- mapZoomRanges[0] +
217
- "&maxlevel=" +
218
- mapZoomRanges[1];
219
- }
220
- }
221
- that.$gisMapFrame.src = url;
222
- that.$gisMapFrame.onload = function () {
223
- if (
224
- !this.contentDocument.documentElement
225
- .getElementsByTagName("head")
226
- .item(0)
227
- .outerHTML.includes("/library/egovagis/map/map.js")
228
- ) {
229
- var mainScript =
230
- this.contentDocument.createElement("script");
231
- mainScript.setAttribute("type", "text/javascript");
232
- mainScript.setAttribute(
233
- "src",
234
- gisServerURL + "/library/egovagis/map/map.js"
235
- );
236
- this.contentDocument.documentElement
237
- .getElementsByTagName("head")
238
- .item(0)
239
- .appendChild(mainScript);
240
- }
241
- };
242
- });
243
- try {
244
- //如果启用了实景功能需要注册实景监听
245
- if (context.mmsEnabled != undefined && that.gisMapContainer) {
246
- var mmsEnabled = Number(context.mmsEnabled);
247
- if (mmsEnabled > 0) {
248
- mmsMap = new EGovaMMSMap(
249
- $container,
250
- scene,
251
- msgPrefix,
252
- context.mmsParams,
253
- mapConfig,
254
- mmsEnabled
255
- );
256
- }
257
- }
258
- } catch (e) {
259
- console.error(e.message);
260
- }
261
- }
262
-
263
- //初始化时不显示地图
264
- that.closeMap();
265
- // 监听地图加载完成的事件
266
- scene.on(
267
- msgPrefix + ":mapLoadedCallback",
268
- that.onMapLoaded,
269
- parentScene,
270
- false
271
- );
272
- };
273
-
274
- /**
275
- * 二维地图显示
276
- *
277
- * @param res
278
- */
279
- that.openMap = function (evt) {
280
- if (!that.gisVisible) {
281
- // 初次定位时调整布局
282
- if (!that.gisLoaded && !that.isLoading) {
283
- that.isLoading = true;
284
- checkGisServerURL(context.gisServerURL, function () {
285
- var gisServerURL = context.gisServerURL;
286
- var gisProxyURL =
287
- context.gisServerURL + "/home/gis/proxy.htm";
288
- var misServerURL = context.rootPath;
289
- var url =
290
- context.rootPath +
291
- context.assetsPath +
292
- "/map.html?parentScene=" +
293
- parentScene +
294
- "&msgPrefix=" +
295
- msgPrefix +
296
- "&serverURL=" +
297
- gisServerURL +
298
- "&proxyURL=" +
299
- gisProxyURL +
300
- "&misURL=" +
301
- misServerURL +
302
- "&humanID=" +
303
- context.humanID;
304
- if (
305
- mapConfig != undefined &&
306
- mapConfig.params != undefined
307
- ) {
308
- for (var item in mapConfig.params) {
309
- url += "&" + item + "=" + mapConfig.params[item];
310
- }
311
- }
312
- that.$gisMapFrame.src = url;
313
- that.$gisMapFrame.onload = function () {
314
- if (
315
- !this.contentDocument.documentElement
316
- .getElementsByTagName("head")
317
- .item(0)
318
- .outerHTML.includes(
319
- "/library/egovagis/map/map.js"
320
- )
321
- ) {
322
- var mainScript =
323
- this.contentDocument.createElement("script");
324
- mainScript.setAttribute("type", "text/javascript");
325
- mainScript.setAttribute(
326
- "src",
327
- gisServerURL + "/library/egovagis/map/map.js"
328
- );
329
- this.contentDocument.documentElement
330
- .getElementsByTagName("head")
331
- .item(0)
332
- .appendChild(mainScript);
333
- }
334
- };
335
- });
336
- try {
337
- //如果启用了实景功能需要注册实景监听,msgPrefix+'old',为了兼容以前的GIS实景结合
338
- if (
339
- context.mmsEnabled != undefined &&
340
- context.mmsEnabled == "1" &&
341
- that.gisMapContainer
342
- ) {
343
- mmsMap = new EGovaMMSMap(
344
- $container,
345
- scene,
346
- msgPrefix + "old",
347
- context.mmsParams,
348
- mapConfig
349
- );
350
- }
351
- } catch (e) {
352
- alert(e.message);
353
- }
354
- }
355
-
356
- that.gisMapContainer.style.height = "100%";
357
- that.gisMapContainer.style.display = "block";
358
- that.gisVisible = true;
359
- }
360
- };
361
-
362
- /**
363
- * 二维地图关闭
364
- */
365
- that.closeMap = function (evt) {
366
- that.gisMapContainer.style.display = "block";
367
- that.gisMapContainer.style.height = "0";
368
- that.gisVisible = false;
369
- };
370
-
371
- /* 绑定事件 */
372
- that.bindEvent = function (msgId, msgHandler, stopOnTop) {
373
- if (scene == null) return;
374
- scene.on(msgPrefix + ":" + msgId, msgHandler, parentScene, stopOnTop);
375
- };
376
- /* 触发事件 */
377
- that.fireEvent = function (msgId, msgData, stopOnTop) {
378
- if (scene == null) return;
379
- scene.fire(msgPrefix + ":" + msgId, msgData, parentScene, stopOnTop);
380
- };
381
- /* 移除监听 */
382
- that.removeEventBind = function (msgId, stopOnTop) {
383
- if (scene == null) return;
384
- scene.remove(msgPrefix + ":" + msgId, parentScene, stopOnTop);
385
- };
386
- /* 设置图层显示顺序 */
387
- that.reorderLayer = function (id, order, options) {
388
- if (scene == null) return;
389
- scene.fire(
390
- msgPrefix + ":reorderLayer",
391
- { args: [id, order, options] },
392
- parentScene
393
- );
394
- };
395
- /* 切换到平移工具 */
396
- that.panMap = function () {
397
- if (scene == null) return;
398
- scene.fire(msgPrefix + ":panMap", parentScene);
399
- };
400
- /* 缩放到指定范围 */
401
- that.zoomToExtent = function (minX, minY, maxX, maxY) {
402
- if (scene == null) return;
403
- scene.fire(
404
- msgPrefix + ":zoomToExtent",
405
- { args: [Number(minX), Number(minY), Number(maxX), Number(maxY)] },
406
- parentScene,
407
- false
408
- );
409
- };
410
- /* 缩放到指定中心点和级别 */
411
- that.centerAndZoom = function (x, y, level) {
412
- if (scene == null) return;
413
- scene.fire(
414
- msgPrefix + ":centerAndZoom",
415
- { args: [x, y, level] },
416
- parentScene,
417
- false
418
- );
419
- };
420
- /* 缩放到全图范围 */
421
- that.zoomToFullExtent = function () {
422
- if (scene == null) return;
423
- scene.fire(msgPrefix + ":fullExtent", { args: [] }, parentScene, false);
424
- };
425
- /* 绘制图形 */
426
- that.drawGraphic = function (graphic, zoom, clickCallback) {
427
- if (scene == null) return;
428
- if (graphic.geometry instanceof Array) {
429
- scene.fire(
430
- msgPrefix + ":locateFeatureByCoords",
431
- {
432
- args: [
433
- graphic.geometry,
434
- graphic.type,
435
- graphic.id,
436
- graphic.style,
437
- graphic.hstyle,
438
- zoom,
439
- graphic.keyField,
440
- graphic.labelField,
441
- graphic.labelStyle,
442
- graphic.colorNumber,
443
- graphic.renderCanvas,
444
- graphic.singleSelected,
445
- graphic.options,
446
- graphic.layerTag,
447
- ],
448
- },
449
- parentScene
450
- );
451
- } else {
452
- // scene.fire(msgPrefix+":locateFeatureByCoord",
453
- // {args:[{"geometry":graphic.geometry},graphic.type,graphic.id,graphic.style,graphic.hstyle,zoom]},parentScene);
454
- scene.fire(
455
- msgPrefix + ":locateFeatureByCoords",
456
- {
457
- args: [
458
- [graphic.geometry],
459
- graphic.type,
460
- graphic.id,
461
- graphic.style,
462
- graphic.hstyle,
463
- zoom,
464
- graphic.keyField,
465
- graphic.labelField,
466
- graphic.labelStyle,
467
- graphic.colorNumber,
468
- graphic.renderCanvas,
469
- graphic.singleSelected,
470
- graphic.options,
471
- graphic.layerTag,
472
- ],
473
- },
474
- parentScene
475
- );
476
- }
477
- that.removeEventBind("locateFeatureByIDsCallback");
478
- if (clickCallback != undefined) {
479
- that.bindEvent("locateFeatureByIDsCallback", function (evt) {
480
- clickCallback(evt.args);
481
- });
482
- }
483
- };
484
-
485
- /*添加WMS服务图层*/
486
- that.showWMSLayer = function (
487
- layerUsageID,
488
- IDs,
489
- keyField,
490
- geometry,
491
- where
492
- ) {
493
- if (scene == null) return;
494
- scene.fire(
495
- msgPrefix + ":showWMSLayer",
496
- { args: [layerUsageID, IDs, keyField, geometry, where] },
497
- parentScene,
498
- false
499
- );
500
- };
501
-
502
- /*清除WMS服务图层*/
503
- that.removeWMSLayer = function (serviceID) {
504
- if (scene == null) return;
505
- scene.fire(
506
- msgPrefix + ":removeWMSLayer",
507
- { args: [serviceID] },
508
- parentScene,
509
- false
510
- );
511
- };
512
-
513
- /*添加自定义WMS服务图层*/
514
- that.addCustomWMSLayer = function (
515
- layerID,
516
- style,
517
- hStyle,
518
- where,
519
- outFields,
520
- visibleLevel,
521
- colorseparField,
522
- colorseparoptions
523
- ) {
524
- if (scene == null) return;
525
- scene.fire(
526
- msgPrefix + ":addCustomWMSLayer",
527
- {
528
- args: [
529
- layerID,
530
- style,
531
- hStyle,
532
- where,
533
- outFields,
534
- visibleLevel,
535
- colorseparField,
536
- colorseparoptions,
537
- ],
538
- },
539
- parentScene,
540
- false
541
- );
542
- };
543
-
544
- /*根据要素坐标定位显示要素*/
545
- that.locateFeatureByCoords = function (
546
- geometries,
547
- type,
548
- ID,
549
- style,
550
- hStyle,
551
- zoom,
552
- keyFiled,
553
- labelField,
554
- labelStyle,
555
- randomColor,
556
- renderCanvas,
557
- singleSelected,
558
- options,
559
- layerTag
560
- ) {
561
- if (scene == null) return;
562
- scene.fire(
563
- msgPrefix + ":locateFeatureByCoords",
564
- {
565
- args: [
566
- geometries,
567
- type,
568
- ID,
569
- style,
570
- hStyle,
571
- zoom,
572
- keyFiled,
573
- labelField,
574
- labelStyle,
575
- randomColor,
576
- renderCanvas,
577
- singleSelected,
578
- options,
579
- layerTag,
580
- ],
581
- },
582
- parentScene,
583
- false
584
- );
585
- };
586
- /* 清除指定图形 */
587
- that.clearGraphic = function (id, tag) {
588
- if (scene == null) return;
589
- if (typeof id != "string") {
590
- id = id.join(",");
591
- }
592
- if (tag) {
593
- id = null;
594
- }
595
- scene.fire(
596
- msgPrefix + ":clearGraphic",
597
- { args: [id, tag] },
598
- parentScene,
599
- false
600
- );
601
- };
602
- /* 清除全部图形 */
603
- that.clearAllGraphics = function (id) {
604
- if (scene == null) return;
605
- scene.fire(
606
- msgPrefix + ":clearAllGraphics",
607
- { args: [] },
608
- parentScene,
609
- false
610
- );
611
- };
612
- /* 在地图上标注 */
613
- that.pointSelect = function (symbolType, zoomFalg, callback) {
614
- if (scene == null) return;
615
-
616
- // 移除监听
617
- scene.remove(msgPrefix + ":pointSelectCallback", parentScene, false);
618
-
619
- if (zoomFalg == undefined) zoomFalg = true;
620
- if (callback) {
621
- // 定义回调
622
- scene.on(
623
- msgPrefix + ":pointSelectCallback",
624
- function (evt) {
625
- // 移除监听
626
- scene.remove(
627
- msgPrefix + ":pointSelectCallback",
628
- parentScene,
629
- false
630
- );
631
- callback(evt.args);
632
- },
633
- parentScene,
634
- false
635
- );
636
- }
637
- scene.fire(
638
- msgPrefix + ":pointSelect",
639
- { args: [symbolType, zoomFalg] },
640
- parentScene,
641
- false
642
- );
643
- };
644
- /* 获取图形外部矩形 */
645
- that.getFeaturesExtent = function (features, callback) {
646
- if (scene == null) return;
647
-
648
- // 移除监听
649
- scene.remove(
650
- msgPrefix + ":getFeaturesExtentCallback",
651
- parentScene,
652
- false
653
- );
654
-
655
- scene.on(
656
- msgPrefix + ":getFeaturesExtentCallback",
657
- function (evt) {
658
- // 移除监听
659
- scene.remove(
660
- msgPrefix + ":getFeaturesExtentCallback",
661
- parentScene,
662
- false
663
- );
664
- callback(evt.args);
665
- },
666
- parentScene,
667
- false
668
- );
669
- scene.fire(
670
- msgPrefix + ":getFeaturesExtent",
671
- { args: features },
672
- parentScene,
673
- false
674
- );
675
- };
676
-
677
- /* 获取可见图层 */
678
- that.getVisibleLayerIds = function (callback) {
679
- // 移除监听
680
- scene.remove(
681
- msgPrefix + ":getVisibleLayerIdsCallback",
682
- parentScene,
683
- false
684
- );
685
-
686
- scene.on(
687
- msgPrefix + ":getVisibleLayerIdsCallback",
688
- function (evt) {
689
- // 移除监听
690
- scene.remove(
691
- msgPrefix + ":getVisibleLayerIdsCallback",
692
- parentScene,
693
- false
694
- );
695
- callback(evt.args);
696
- },
697
- parentScene,
698
- false
699
- );
700
- scene.fire(
701
- msgPrefix + ":getVisibleLayerIds",
702
- { args: [] },
703
- parentScene,
704
- false
705
- );
706
- };
707
-
708
- that.identifyInfoWindow = function (usageID, keyValue, content, size) {
709
- if (scene == null) return;
710
- scene.fire(
711
- msgPrefix + ":identifyInfoWindow",
712
- { args: [usageID, keyValue, content, size] },
713
- parentScene,
714
- false
715
- );
716
- };
717
- /* 更改工具条参数 */
718
- that.changeControlParam = function (id, param) {
719
- if (scene == null) return;
720
- scene.fire(
721
- msgPrefix + ":changeControlParam",
722
- { args: [id, param] },
723
- parentScene,
724
- false
725
- );
726
- };
727
- /* 图层过滤显示 */
728
- that.setLayerDef = function (phyLayerID, layerDef) {
729
- if (scene == null) return;
730
- scene.fire(
731
- msgPrefix + ":setLayerDef",
732
- { args: [phyLayerID, layerDef] },
733
- parentScene,
734
- false
735
- );
736
- };
737
- that.setLayerColorDef = function (phyLayerIDs, colorDefs) {
738
- if (scene == null) return;
739
- scene.fire(
740
- msgPrefix + ":setLayerColorDef",
741
- { args: [phyLayerIDs, colorDefs] },
742
- parentScene,
743
- false
744
- );
745
- };
746
-
747
- /* 显示图层树 */
748
- that.showLayerTree = function (/* humanID, mapID */ openTree) {
749
- if (scene == null) return;
750
- /*
751
- * var data = null; scene.fire(msgPrefix + ":showLayerTree", {args :
752
- * [data, humanID, mapID]}, parentScene);
753
- */
754
- if (openTree == undefined || arguments.length > 1) openTree = true;
755
- scene.fire(
756
- msgPrefix + ":showLayerTree",
757
- { args: [openTree] },
758
- parentScene
759
- );
760
- };
761
- /* I查询 */
762
- that.identify = function (type, humanID, mapID, options) {
763
- if (scene == null) return;
764
- scene.fire(
765
- msgPrefix + ":identify",
766
- { args: [type, humanID, mapID] },
767
- parentScene
768
- );
769
-
770
- // By hth 2021/4/6: 如果传入了回调函数,则绑定执行回调函数的监听事件
771
- var cb = options && options.cb;
772
- if (cb) {
773
- // 移除监听
774
- that.removeEventBind("identifySelectCallback");
775
- if (cb !== undefined && typeof cb === "function") {
776
- that.bindEvent("identifySelectCallback", function (evt) {
777
- cb(evt.args);
778
- });
779
- }
780
- }
781
- };
782
- /* 地理编码查询 */
783
- that.geoCode = function (searchStr, callback) {
784
- if (scene == null) return;
785
- if (callback) {
786
- // 移除监听
787
- that.removeEventBind("geoCodeCallback");
788
- if (callback != undefined) {
789
- that.bindEvent("geoCodeCallback", function (evt) {
790
- callback(evt.args);
791
- });
792
- }
793
- }
794
- scene.fire(msgPrefix + ":geoCode", { args: [searchStr] }, parentScene);
795
- };
796
- /* 逆地理编码查询 */
797
- that.getAddressByXY = function (x, y, searchStr, radius, callback) {
798
- if (scene == null) return;
799
- if (callback) {
800
- that.removeEventBind("getAddressByXYCallback");
801
- that.bindEvent("getAddressByXYCallback", function (evt) {
802
- callback(evt.args);
803
- });
804
- }
805
- scene.fire(
806
- msgPrefix + ":getAddressByXY",
807
- { args: [x, y, searchStr, radius] },
808
- parentScene
809
- );
810
- };
811
- that.getGaAddressByXY = function (x, y, options, callback) {
812
- if (scene == null) return;
813
- if (callback) {
814
- that.removeEventBind("getGaAddressByXYCallback");
815
- that.bindEvent("getGaAddressByXYCallback", function (evt) {
816
- callback(evt.args);
817
- });
818
- }
819
- scene.fire(
820
- msgPrefix + ":getGaAddressByXY",
821
- { args: [x, y, options] },
822
- parentScene
823
- );
824
- };
825
- that.getGaStandardAddress = function (params, callback) {
826
- if (scene == null) return;
827
- if (callback) {
828
- that.removeEventBind("getGaStandardAddressCallbackCallback");
829
- that.bindEvent(
830
- "getGaStandardAddressCallbackCallback",
831
- function (evt) {
832
- callback(evt.args);
833
- }
834
- );
835
- }
836
- scene.fire(
837
- msgPrefix + ":getGaStandardAddress",
838
- { args: [params] },
839
- parentScene
840
- );
841
- };
842
- /* 根据坐标获取单元网格 */
843
- that.getCellNameByPosXY = function (x, y, gridType) {
844
- if (scene == null) return;
845
- var args = [];
846
- var callback = null;
847
- for (var i = 0; i < arguments.length; i++) {
848
- var arg = arguments[i];
849
- if (i == arguments.length - 1 && typeof arg == "function") {
850
- callback = arg;
851
- continue;
852
- }
853
- args.push(arg);
854
- }
855
- if (callback != null) {
856
- // 移除监听
857
- that.removeEventBind("getCellNameByPosXYCallback");
858
-
859
- function _getCellNameByPosXYCallback(evt) {
860
- that.removeEventBind("getCellNameByPosXYCallback");
861
- callback(evt.args);
862
- }
863
- that.bindEvent(
864
- "getCellNameByPosXYCallback",
865
- _getCellNameByPosXYCallback
866
- );
867
- }
868
- that.fireEvent("getCellNameByPosXY", { args: args });
869
- };
870
- /* 根据图层字段定位显示 */
871
- that.locateFeatureByIDs = function (
872
- layerID,
873
- keyFiled,
874
- keyValue,
875
- clearMap,
876
- style,
877
- hStyle,
878
- bZoom,
879
- randomColor,
880
- labelfield,
881
- labelstyle,
882
- geometry,
883
- where,
884
- renderCanvas,
885
- singleSelected,
886
- options,
887
- extendProperty,
888
- layerTag,
889
- outFieldStr,
890
- animiteStep,
891
- index,
892
- clipGeom
893
- ) {
894
- if (scene == null) return;
895
- if (bZoom == undefined) bZoom = false;
896
- scene.fire(
897
- msgPrefix + ":locateFeatureByIDs",
898
- {
899
- args: [
900
- layerID,
901
- keyValue,
902
- keyFiled,
903
- clearMap,
904
- style,
905
- hStyle,
906
- bZoom,
907
- randomColor,
908
- labelfield,
909
- labelstyle,
910
- geometry,
911
- where,
912
- renderCanvas,
913
- singleSelected,
914
- options,
915
- extendProperty,
916
- layerTag,
917
- outFieldStr,
918
- animiteStep,
919
- index,
920
- clipGeom,
921
- ],
922
- },
923
- parentScene
924
- );
925
- };
926
- /* 显示案件分布 */
927
- that.showRecListDistribution = function (
928
- infoJson,
929
- zoom,
930
- clickCallback,
931
- labelInfo,
932
- isShowLegend,
933
- symbolUrl,
934
- options
935
- ) {
936
- if (scene == null || infoJson.length == 0) return;
937
- //如果xy坐标没有值不处理
938
- for (var i = 0, len = infoJson.length; i < len; i++) {
939
- if (
940
- !infoJson[i].coordinateX ||
941
- infoJson[i].coordinateX == "" ||
942
- !infoJson[i].coordinateY ||
943
- infoJson[i].coordinateY == ""
944
- ) {
945
- return;
946
- }
947
- }
948
-
949
- // 移除监听
950
- that.removeEventBind("showRecListDistributionCallback");
951
-
952
- if (clickCallback != undefined) {
953
- that.bindEvent("showRecListDistributionCallback", function (evt) {
954
- clickCallback(evt.args);
955
- });
956
- }
957
- scene.fire(
958
- msgPrefix + ":showRecListDistribution",
959
- {
960
- args: [
961
- infoJson,
962
- zoom,
963
- labelInfo,
964
- isShowLegend,
965
- symbolUrl,
966
- clickCallback,
967
- options,
968
- ],
969
- },
970
- parentScene,
971
- false
972
- );
973
-
974
- //如果启用了实景功能,同时进行实景定位
975
- if (mmsMap && infoJson.length == 1) {
976
- var recInfo = infoJson[0];
977
- if (mmsMap.mmsLoaded) {
978
- if (!mmsMap.mmsVisible) {
979
- // var pos = {x:recInfo.coordinateX, y:recInfo.coordinateY};
980
- // var evt = {args:[pos]};
981
- // mmsMap.setMMSEyePosition(evt);
982
- } else {
983
- mmsMap.locateEvent(
984
- recInfo.recID,
985
- recInfo.coordinateX,
986
- recInfo.coordinateY
987
- );
988
- }
989
- }
990
- }
991
- };
992
- that.highLightMultiObjectCurrentPosition = function (
993
- objectID,
994
- zoom,
995
- cluster,
996
- showPopup,
997
- layerID
998
- ) {
999
- if (scene == null) return;
1000
- scene.fire(
1001
- msgPrefix + ":highLightMultiObjectCurrentPosition",
1002
- { args: [objectID, zoom, cluster, showPopup, layerID] },
1003
- parentScene,
1004
- false
1005
- );
1006
- };
1007
- /* 显示多个自定义图标 */
1008
- that.showMultiObjectCurrentPosition = function (
1009
- jsonInfo,
1010
- zoom,
1011
- bClear,
1012
- hStyleID,
1013
- infoStyle,
1014
- bCanvas,
1015
- tagName,
1016
- clickCallback,
1017
- mouseOverCallBack,
1018
- clusterOption,
1019
- hasHover,
1020
- layerID,
1021
- mouseOutCallback,
1022
- options
1023
- ) {
1024
- if (scene == null) return;
1025
- // 移除监听
1026
- var clickBackName = "showMultiObjectCurrentPositionClick";
1027
- var mouseOverBackName = "showMultiObjectCurrentPositionMouseover";
1028
- var mouseOutBackName = "showMultiObjectCurrentPositionMouseout";
1029
- if (options && options.callbacksuffix) {
1030
- clickBackName += options.callbacksuffix;
1031
- mouseOverBackName += options.callbacksuffix;
1032
- mouseOutBackName += options.callbacksuffix;
1033
- }
1034
- that.removeEventBind(clickBackName);
1035
- that.removeEventBind(mouseOverBackName);
1036
- that.removeEventBind(mouseOutBackName);
1037
- if (clickCallback instanceof Function) {
1038
- that.bindEvent(clickBackName, function (evt) {
1039
- clickCallback(evt.args);
1040
- });
1041
- }
1042
- if (mouseOverCallBack instanceof Function) {
1043
- that.bindEvent(mouseOverBackName, function (evt) {
1044
- mouseOverCallBack(evt.args);
1045
- });
1046
- }
1047
- if (mouseOutCallback instanceof Function) {
1048
- that.bindEvent(mouseOutBackName, function (evt) {
1049
- mouseOutCallback(evt.args);
1050
- });
1051
- }
1052
- if (options && options.getgeohashCallback && options.getgeohashCallback instanceof Function) {
1053
- that.removeEventBind("getGeoHashesCallback");
1054
- scene.on(msgPrefix + ":getGeoHashesCallback", options.getgeohashCallback, parentScene, false);
1055
- }
1056
-
1057
- scene.fire(
1058
- msgPrefix + ":showMultiObjectCurrentPosition",
1059
- {
1060
- args: [
1061
- jsonInfo,
1062
- zoom,
1063
- bClear,
1064
- hStyleID,
1065
- infoStyle,
1066
- bCanvas,
1067
- tagName,
1068
- clusterOption,
1069
- hasHover,
1070
- layerID,
1071
- options,
1072
- ],
1073
- },
1074
- parentScene,
1075
- false
1076
- );
1077
- };
1078
- /**
1079
- * 新聚类传入数据的接口
1080
- */
1081
- that.showMultiObjectCurrentPositionWithData = function (jsonInfo) {
1082
- if (scene == null) return;
1083
- scene.fire(
1084
- msgPrefix + ":showMultiObjectCurrentPositionWithData",
1085
- {
1086
- args: [jsonInfo],
1087
- },
1088
- parentScene,
1089
- false
1090
- );
1091
- };
1092
- /* 显示监督员 */
1093
- that.showPatrolCurrentPosition = function (
1094
- jsonInfo,
1095
- zoom,
1096
- bClear,
1097
- hStyleID,
1098
- clickCallback
1099
- ) {
1100
- if (scene == null) return;
1101
-
1102
- var args = Array.prototype.slice.call(arguments);
1103
- if (arguments[arguments.length - 1] instanceof Function) {
1104
- clickCallback = arguments[arguments.length - 1];
1105
- args = args.slice(0, args.length - 1);
1106
- }
1107
-
1108
- if (clickCallback) {
1109
- that.removeEventBind("showPatrolCurrentPositionCallback");
1110
- that.bindEvent("showPatrolCurrentPositionCallback", function (evt) {
1111
- clickCallback(evt.args);
1112
- });
1113
- }
1114
- scene.fire(
1115
- msgPrefix + ":showPatrolCurrentPosition",
1116
- { args: args },
1117
- parentScene,
1118
- false
1119
- );
1120
- };
1121
- /* 获取缓冲区 */
1122
- that.getBuffer = function (layerID, x, y, radius, getBufferCallback) {
1123
- if (scene == null) return;
1124
-
1125
- var args = Array.prototype.slice.call(arguments);
1126
- if (arguments[arguments.length - 1] instanceof Function) {
1127
- getBufferCallback = arguments[arguments.length - 1];
1128
- args = args.slice(0, args.length - 1);
1129
- }
1130
-
1131
- if (getBufferCallback) {
1132
- that.removeEventBind("getBufferCallback");
1133
- that.bindEvent("getBufferCallback", function (evt) {
1134
- getBufferCallback(evt.args);
1135
- });
1136
- }
1137
- scene.fire(msgPrefix + ":getBuffer", { args: args }, parentScene, true);
1138
- };
1139
- /* 获取多点的缓冲区 */
1140
- that.getMultiPointBuffer = function (points, radius, callback, options) {
1141
- if (scene == null) return;
1142
- scene.fire(
1143
- msgPrefix + ":getMultiPointBuffer",
1144
- { args: [points, radius, callback, options] },
1145
- parentScene,
1146
- true
1147
- );
1148
- };
1149
- /**
1150
- * 设置指定图层的样式
1151
- * @param id 元素的id
1152
- * @param tag 图层的标签
1153
- * @param style 图层样式
1154
- * @returns
1155
- */
1156
- that.setGraphicStyle = function (id, tag, style) {
1157
- if (scene == null) return;
1158
- scene.fire(
1159
- msgPrefix + ":setGraphicStyle",
1160
- { args: [id, tag, style] },
1161
- parentScene,
1162
- true
1163
- );
1164
- };
1165
- /* 显示监督员责任网格 */
1166
- that.showPatrolDutygridCells = function (infoJson, zoom, clickCallback) {
1167
- if (scene == null) return;
1168
-
1169
- var layerID = infoJson.layerID;
1170
- var layerKeyFieldName = infoJson.keyFieldName;
1171
- var cellID = infoJson.grids;
1172
- var bClearMap = false;
1173
- var gridCellStyle = {};
1174
- gridCellStyle.style = {
1175
- type: "esriSFS",
1176
- style: "esriSFSSolid",
1177
- color: [0, 0, 100, 76],
1178
- outline: {
1179
- type: "esriSLS",
1180
- style: "esriSLSSolid",
1181
- color: [255, 130, 47, 255],
1182
- width: 2,
1183
- },
1184
- };
1185
- gridCellStyle.hStyle = MapUtils.deepClones(
1186
- true,
1187
- {},
1188
- gridCellStyle.style
1189
- );
1190
- that.locateFeatureByIDs(
1191
- layerID,
1192
- layerKeyFieldName,
1193
- cellID,
1194
- bClearMap,
1195
- gridCellStyle.style,
1196
- gridCellStyle.hStyle,
1197
- zoom
1198
- );
1199
- };
1200
- /* 标识位置 */
1201
- that.markMap = function (
1202
- projectTypeID,
1203
- eventTypeID,
1204
- actPropertyID,
1205
- displayStyleID,
1206
- layerID,
1207
- clickCallback,
1208
- cellIndexName,
1209
- point,
1210
- symbolUrl,
1211
- bdGridCodeOpt
1212
- ) {
1213
- if (scene == null) return;
1214
-
1215
- // 移除监听
1216
- that.removeEventBind("markMapCallback");
1217
-
1218
- //新增了layerID,因此需要兼容原来的4个参数
1219
- if (arguments.length == 5 && typeof layerID == "function") {
1220
- clickCallback = layerID;
1221
- layerID == null;
1222
- }
1223
-
1224
- if (clickCallback != undefined) {
1225
- that.bindEvent("markMapCallback", function (evt) {
1226
- clickCallback(evt.args);
1227
- });
1228
- }
1229
- scene.fire(
1230
- msgPrefix + ":markMap",
1231
- {
1232
- args: [
1233
- projectTypeID,
1234
- eventTypeID,
1235
- actPropertyID,
1236
- displayStyleID,
1237
- layerID,
1238
- cellIndexName,
1239
- point,
1240
- symbolUrl,
1241
- bdGridCodeOpt,
1242
- ],
1243
- },
1244
- parentScene,
1245
- false
1246
- );
1247
- };
1248
- /* 案件定位 */
1249
- that.eventLocate = that.recLocate = function (eventID, defaultMapRange) {
1250
- if (scene == null) return;
1251
-
1252
- if (defaultMapRange == undefined) defaultMapRange = 200;
1253
- scene.fire(
1254
- msgPrefix + ":eventLocate",
1255
- { args: [eventID, defaultMapRange] },
1256
- parentScene,
1257
- false
1258
- );
1259
- };
1260
- /* 显示特定图层 */
1261
- that.showMapLayers = function (
1262
- layerTag,
1263
- showLevel,
1264
- mode,
1265
- styles,
1266
- layerDefs
1267
- ) {
1268
- if (scene == null) return;
1269
- scene.fire(
1270
- msgPrefix + ":showMapLayers",
1271
- { args: [layerTag, showLevel, mode, styles, layerDefs] },
1272
- parentScene,
1273
- false
1274
- );
1275
- };
1276
- /**
1277
- * 刷新地图图层
1278
- */
1279
- that.refreshMapLayers = function () {
1280
- if (scene) {
1281
- scene.fire(
1282
- msgPrefix + ":refreshMapLayers",
1283
- { args: [] },
1284
- parentScene,
1285
- false
1286
- );
1287
- }
1288
- };
1289
- /* 显示车辆人员轨迹 */
1290
- that.showObjectTrace = function (
1291
- objectID,
1292
- symbolType,
1293
- dateTime,
1294
- queryCondition,
1295
- hideControlPanel,
1296
- symbolPic,
1297
- optimizeParams,
1298
- infoCallback,
1299
- updatePositionCallback,
1300
- closeCallback,
1301
- traceDigCallback
1302
- ) {
1303
- if (scene == null) return;
1304
-
1305
- if (closeCallback) {
1306
- that.removeEventBind("TraceManagerCloseCallback");
1307
- that.bindEvent("TraceManagerCloseCallback", function () {
1308
- closeCallback();
1309
- });
1310
- }
1311
- if (infoCallback) {
1312
- that.removeEventBind("showObjectTraceCallback");
1313
- that.bindEvent("showObjectTraceCallback", function (evt) {
1314
- infoCallback(evt && evt.args);
1315
- });
1316
- }
1317
- if (updatePositionCallback) {
1318
- that.removeEventBind("updatePositionCallback");
1319
- that.bindEvent("updatePositionCallback", function (evt) {
1320
- updatePositionCallback(evt && evt.args);
1321
- });
1322
- }
1323
- if (traceDigCallback) {
1324
- that.removeEventBind("getPatrolTraceDigCallback");
1325
- that.bindEvent("getPatrolTraceDigCallback", function (evt) {
1326
- traceDigCallback(evt && evt.args);
1327
- });
1328
- }
1329
- /*if (context.sysConfig['PATROL_POS_WRITE_TO_FILE']) {
1330
- if (queryCondition) {
1331
- queryCondition = $.extend({}, queryCondition, { 'resourcetype': 2 });
1332
- } else {
1333
- queryCondition = { 'resourcetype': 2 };
1334
- }
1335
- }*/
1336
- scene.fire(
1337
- msgPrefix + ":showObjectTrace",
1338
- {
1339
- args: [
1340
- objectID,
1341
- symbolType,
1342
- dateTime,
1343
- queryCondition,
1344
- hideControlPanel,
1345
- symbolPic,
1346
- optimizeParams,
1347
- ],
1348
- },
1349
- parentScene
1350
- );
1351
- };
1352
-
1353
- /*跳转轨迹位置*/
1354
- that.updatePositionByTime = function (time) {
1355
- if (scene == null) return;
1356
- scene.fire(
1357
- msgPrefix + ":updatePositionByTime",
1358
- { args: [time] },
1359
- parentScene
1360
- );
1361
- };
1362
-
1363
- /**
1364
- *轨迹开始播放/暂停
1365
- **/
1366
- that.playObjectTrace = function (speed, doNotChangeState) {
1367
- scene.fire(
1368
- msgPrefix + ":playObjectTrace",
1369
- { args: [speed, doNotChangeState] },
1370
- parentScene
1371
- );
1372
- };
1373
-
1374
- /**
1375
- *轨迹停止
1376
- **/
1377
- that.stopObjectTrace = function () {
1378
- scene.fire(msgPrefix + ":stopObjectTrace", { args: [] }, parentScene);
1379
- };
1380
-
1381
- /**
1382
- *更新轨迹播放速度
1383
- **/
1384
- that.updatePlaySpeed = function (value) {
1385
- scene.fire(
1386
- msgPrefix + ":updatePlaySpeed",
1387
- { args: [value] },
1388
- parentScene
1389
- );
1390
- };
1391
-
1392
- that.startRealtimeTrace = function (
1393
- groupIDs,
1394
- objectIDs,
1395
- objectType,
1396
- resourceType,
1397
- uiOption,
1398
- traceOption,
1399
- jobOption,
1400
- options
1401
- ) {
1402
- if (scene == null) return;
1403
-
1404
- var groupIDStrs = "";
1405
- if (groupIDs instanceof Array && groupIDs.length > 0) {
1406
- for (var i = 0; i < groupIDs.length; i++) {
1407
- if (i != groupIDs.length - 1) {
1408
- groupIDStrs += "comp_" + groupIDs[i] + ",";
1409
- } else {
1410
- groupIDStrs += "comp_" + groupIDs[i];
1411
- }
1412
- }
1413
- }
1414
-
1415
- var objectIDStrs = "";
1416
- if (
1417
- objectIDs instanceof Array &&
1418
- objectIDs.length > 0 &&
1419
- groupIDs instanceof Array &&
1420
- groupIDs.length > 0
1421
- ) {
1422
- for (var i = 0; i < groupIDs.length; i++) {
1423
- for (var j = 0; j < objectIDs.length; j++) {
1424
- if (j != objectIDs.length - 1) {
1425
- objectIDStrs += groupIDs[i] + "_" + objectIDs[j] + ",";
1426
- } else {
1427
- objectIDStrs += groupIDs[i] + "_" + objectIDs[j];
1428
- }
1429
- }
1430
- }
1431
- }
1432
- // 监听
1433
- if (!options) options = {};
1434
- if (typeof options.MultiTraceDataCallback === "function") {
1435
- that.removeEventBind("MultiTraceDataCallback");
1436
- that.bindEvent("MultiTraceDataCallback", function (evt) {
1437
- options.MultiTraceDataCallback(evt && evt.args);
1438
- });
1439
- }
1440
-
1441
- if (typeof options.mouseOverCallback === "function") {
1442
- that.removeEventBind("MultiTraceMouseOver");
1443
- that.bindEvent("MultiTraceMouseOver", function (evt) {
1444
- options.mouseOverCallback(evt && evt.args);
1445
- });
1446
- }
1447
- if (typeof options.mouseOutCallback === "function") {
1448
- that.removeEventBind("MultiTraceMouseOut");
1449
- that.bindEvent("MultiTraceMouseOut", function (evt) {
1450
- options.mouseOutCallback(evt && evt.args);
1451
- });
1452
- }
1453
- if (typeof options.clickCallback === "function") {
1454
- that.removeEventBind("MultiTraceClick");
1455
- that.bindEvent("MultiTraceClick", function (evt) {
1456
- options.clickCallback(evt && evt.args);
1457
- });
1458
- }
1459
- scene.fire(
1460
- msgPrefix + ":startRealtimeTrace",
1461
- {
1462
- args: [
1463
- groupIDStrs,
1464
- objectIDStrs,
1465
- objectType,
1466
- resourceType,
1467
- uiOption,
1468
- traceOption,
1469
- jobOption,
1470
- ],
1471
- },
1472
- parentScene
1473
- );
1474
- };
1475
-
1476
- that.stopRealtimeTrace = function (objectType, resourceType) {
1477
- if (scene == null) return;
1478
-
1479
- scene.fire(msgPrefix + ":stopRealtimeTrace", { args: [objectType, resourceType] }, parentScene);
1480
- };
1481
- /**
1482
- *停止绘制要素
1483
- **/
1484
- that.stopDraw = function () {
1485
- scene.fire(msgPrefix + ":stopDraw", { args: [] }, parentScene);
1486
- };
1487
-
1488
- /**
1489
- *等值面生成
1490
- **/
1491
- that.isobands = function (
1492
- attrarry,
1493
- xarry,
1494
- yarry,
1495
- breaks,
1496
- breakcolors,
1497
- cellwidth,
1498
- boundary,
1499
- hascelllabel,
1500
- labelcolor,
1501
- callback,
1502
- options
1503
- ) {
1504
- scene.fire(
1505
- msgPrefix + ":isobands",
1506
- {
1507
- args: [
1508
- attrarry,
1509
- xarry,
1510
- yarry,
1511
- breaks,
1512
- breakcolors,
1513
- cellwidth,
1514
- boundary,
1515
- hascelllabel,
1516
- labelcolor,
1517
- callback,
1518
- options,
1519
- ],
1520
- },
1521
- parentScene
1522
- );
1523
- };
1524
-
1525
- //by ysj,2020-06-02
1526
- that.checkObjectTraceItem = function (type, boolean) {
1527
- scene.fire(
1528
- msgPrefix + ":checkObjectTraceItem",
1529
- { args: [type, boolean] },
1530
- parentScene
1531
- );
1532
- };
1533
-
1534
- /* 显示车辆人员轨迹热力的接口*/
1535
- that.showTraceHeatMap = function (
1536
- objectID,
1537
- symbolType,
1538
- starttime,
1539
- endtime,
1540
- queryCondition,
1541
- hidePanel
1542
- ) {
1543
- if (scene == null) return;
1544
- scene.fire(
1545
- msgPrefix + ":showTraceHeatMap",
1546
- {
1547
- args: [
1548
- objectID,
1549
- symbolType,
1550
- starttime,
1551
- endtime,
1552
- queryCondition,
1553
- hidePanel,
1554
- ],
1555
- },
1556
- parentScene
1557
- );
1558
- };
1559
-
1560
- /*添加车辆或人员轨迹*/
1561
- that.addObjectTrace = function (
1562
- jsonInfo,
1563
- symbolType,
1564
- clear,
1565
- showControlPanel
1566
- ) {
1567
- if (scene == null) return;
1568
- scene.fire(
1569
- msgPrefix + ":addObjectTrace",
1570
- { args: [jsonInfo, symbolType, clear, showControlPanel] },
1571
- parentScene
1572
- );
1573
- };
1574
- /* 显示第三方上报人员轨迹 */
1575
- that.showZzTaskTrace = function (
1576
- objectID,
1577
- symbolType,
1578
- dataTime,
1579
- queryCondition
1580
- ) {
1581
- if (scene == null) return;
1582
- scene.fire(
1583
- msgPrefix + ":showObjectTrace",
1584
- { args: [objectID, symbolType, dataTime, queryCondition] },
1585
- parentScene
1586
- );
1587
- };
1588
- /* 绘制巡更路线 */
1589
- that.showPatrolRoute = function (
1590
- routeList,
1591
- type,
1592
- bClear,
1593
- editable,
1594
- zoom,
1595
- options
1596
- ) {
1597
- if (scene == null) return;
1598
- if (!(routeList instanceof Array)) routeList = [routeList];
1599
- if (bClear == undefined) bClear = false;
1600
- if (editable == undefined) editable = false;
1601
-
1602
- var graphics = [];
1603
- for (var i = 0; i < routeList.length; i++) {
1604
- var route = routeList[i];
1605
- var line = [];
1606
- var attributes = [];
1607
- var graphic = {
1608
- id: route.routeID + "",
1609
- geometry: { paths: [line] },
1610
- attributes: attributes,
1611
- };
1612
- for (var j = 0; j < route.pointList.length; j++) {
1613
- var point = route.pointList[j];
1614
- line.push([point.coordinateX, point.coordinateY]);
1615
- attributes.push(point.pointID);
1616
- }
1617
- graphics.push(graphic);
1618
- }
1619
- options = options || {};
1620
- var lineStyle = options.lineStyle || {};
1621
- var arrowStyle = options.arrowStyle || {};
1622
- var style = { color: [255, 0, 0, 150], width: 6 };
1623
- if (type == "dutyGridRoute") {
1624
- style.color = [0, 0, 255, 150];
1625
- }
1626
- if (type == "patrolRoute") {
1627
- style.color = [0, 255, 0, 150];
1628
- }
1629
- var lineSymbol = Object.assign(style, lineStyle);
1630
- var arrowSymbol = Object.assign({ size: 6 }, arrowStyle);
1631
- var option = {};
1632
- option.arrowStyle = arrowSymbol;
1633
- option.visible =
1634
- options.visible == null || options.visible == "undefined"
1635
- ? true
1636
- : options.visible;
1637
- scene.fire(
1638
- msgPrefix + ":showPatrolRoute",
1639
- { args: [graphics, bClear, lineSymbol, editable, zoom, option] },
1640
- parentScene
1641
- );
1642
- };
1643
- /* 添加巡更路线 */
1644
- that.addPatrolRoute = function (addCallback, editCallback) {
1645
- if (scene == null) return;
1646
-
1647
- // 移除监听
1648
- that.removeEventBind("drawPatrolRouteNewCallback");
1649
- that.removeEventBind("drawPatrolRouteEditCallback");
1650
-
1651
- if (addCallback != undefined) {
1652
- that.bindEvent("drawPatrolRouteNewCallback", function (evt) {
1653
- addCallback(evt.args);
1654
- });
1655
- }
1656
- if (editCallback != undefined) {
1657
- that.bindEvent("drawPatrolRouteEditCallback", function (evt) {
1658
- editCallback(evt.args);
1659
- });
1660
- }
1661
- var style = { color: [255, 0, 0, 150], width: 2 };
1662
- scene.fire(
1663
- msgPrefix + ":drawPatrolRoute",
1664
- { args: [style] },
1665
- parentScene
1666
- );
1667
- };
1668
- /* 删除巡更路线 */
1669
- that.deletePatrolRoute = function (callback, withConfirm) {
1670
- if (scene == null) return;
1671
-
1672
- // 移除监听
1673
- that.removeEventBind("deletePatrolRouteCallback");
1674
-
1675
- if (callback != undefined) {
1676
- that.bindEvent("deletePatrolRouteCallback", function (evt) {
1677
- callback(evt.args);
1678
- });
1679
- }
1680
- if (withConfirm) {
1681
- scene.fire(
1682
- msgPrefix + ":deletePatrolRoute",
1683
- { args: [false] },
1684
- parentScene
1685
- );
1686
- } else {
1687
- scene.fire(
1688
- msgPrefix + ":deletePatrolRoute",
1689
- { args: [] },
1690
- parentScene
1691
- );
1692
- }
1693
- };
1694
- /* 获取正在编辑的路线 */
1695
- that.getPatrolRouteEdit = function (callback) {
1696
- if (scene == null) return;
1697
-
1698
- // 移除监听
1699
- that.removeEventBind("getPatrolRouteEditCallback");
1700
-
1701
- if (callback != undefined) {
1702
- that.bindEvent("getPatrolRouteEditCallback", function (evt) {
1703
- callback(evt.args);
1704
- });
1705
- }
1706
- scene.fire(
1707
- msgPrefix + ":getPatrolRouteEdit",
1708
- { args: [] },
1709
- parentScene
1710
- );
1711
- };
1712
-
1713
- /* 添加图形 */
1714
- var pointStyle = {};
1715
- pointStyle.style = {
1716
- type: "esriSMS",
1717
- style: "esriSMSCircle",
1718
- color: [255, 0, 0, 150],
1719
- size: 8,
1720
- angle: 0,
1721
- xoffset: 0,
1722
- yoffset: 0,
1723
- outline: { color: [255, 0, 0, 150], width: 1 },
1724
- };
1725
- pointStyle.hStyle = MapUtils.deepClones(true, {}, pointStyle.style);
1726
- var polylineStyle = {};
1727
- polylineStyle.style = {
1728
- type: "esriSFS",
1729
- style: "esriSFSSolid",
1730
- color: [255, 0, 0, 150],
1731
- outline: {
1732
- type: "esriSLS",
1733
- style: "esriSLSSolid",
1734
- color: [0, 0, 255, 150],
1735
- width: 1,
1736
- },
1737
- };
1738
- polylineStyle.hStyle = MapUtils.deepClones(true, {}, polylineStyle.style);
1739
- var polygonStyle = {};
1740
- polygonStyle.style = {
1741
- type: "esriSFS",
1742
- style: "esriSFSSolid",
1743
- color: [255, 0, 0, 150],
1744
- outline: {
1745
- type: "esriSLS",
1746
- style: "esriSLSSolid",
1747
- color: [0, 0, 255, 150],
1748
- width: 1,
1749
- },
1750
- };
1751
- polygonStyle.hStyle = MapUtils.deepClones(true, {}, polygonStyle.style);
1752
- var styles = {
1753
- point: pointStyle,
1754
- polyline: polylineStyle,
1755
- polygon: polygonStyle,
1756
- };
1757
-
1758
- that.getStyles = function (type, styleType) {
1759
- var result = MapUtils.deepClones(true, {}, styles[type]);
1760
- if (styleType == "esriSFSDiagonalCross") {
1761
- result.style.type = "esriPFS";
1762
- result.style.width = 10;
1763
- result.style.height = 10;
1764
- result.style.url = "images/diagonalcross_red.png";
1765
- } else if (styleType == "esriPolygonHalfYellowTransparent") {
1766
- result.style = {
1767
- type: "esriSFS",
1768
- style: "esriSFSSolid",
1769
- color: [215, 214, 111, 100],
1770
- outline: {
1771
- type: "esriSLS",
1772
- style: "esriSLSSolid",
1773
- color: [0, 0, 255, 150],
1774
- width: 1,
1775
- },
1776
- };
1777
- } else if (styleType == "esriPointHalfYellowTransparent") {
1778
- result.style = {
1779
- type: "esriSMS",
1780
- style: "esriSMSCircle",
1781
- color: [215, 214, 111, 100],
1782
- size: 8,
1783
- angle: 0,
1784
- xoffset: 0,
1785
- yoffset: 0,
1786
- outline: { color: [255, 0, 0, 150], width: 1 },
1787
- };
1788
- result.hStyle = MapUtils.deepClones(true, {}, pointStyle.style);
1789
- } else if (styleType == "esriLineHalfYellowTransparent") {
1790
- result.style = {
1791
- type: "esriSFS",
1792
- style: "esriSFSSolid",
1793
- color: [215, 214, 111, 100],
1794
- outline: {
1795
- type: "esriSLS",
1796
- style: "esriSLSSolid",
1797
- color: [0, 0, 255, 150],
1798
- width: 1,
1799
- },
1800
- };
1801
- result.hStyle = MapUtils.deepClones(true, {}, pointStyle.style);
1802
- }
1803
- return result;
1804
- };
1805
- that.addGraphic = function (params, addCallback, editCallback) {
1806
- if (scene == null) return;
1807
-
1808
- // 移除监听
1809
- that.removeEventBind("drawGeometryCallback");
1810
- that.removeEventBind("drawGeometryEditCallback");
1811
-
1812
- if (addCallback != undefined) {
1813
- that.bindEvent("drawGeometryCallback", function (evt) {
1814
- addCallback(evt.args);
1815
- });
1816
- }
1817
- if (editCallback != undefined) {
1818
- that.bindEvent("drawGeometryEditCallback", function (evt) {
1819
- editCallback(evt.args);
1820
- });
1821
- }
1822
- if (params[1] == null && styles[params[0]]) {
1823
- params[1] = styles[params[0]].style;
1824
- }
1825
- scene.fire(msgPrefix + ":drawGeometry", { args: params }, parentScene);
1826
- };
1827
-
1828
- /* 编辑图形 */
1829
- that.editGraphic = function (params, editCallback, deleteCallback) {
1830
- if (scene == null) return;
1831
-
1832
- // 移除监听
1833
- that.removeEventBind("editGeometryCallback");
1834
- that.removeEventBind("deleteGeometryCallback");
1835
-
1836
- if (editCallback != undefined) {
1837
- that.bindEvent("editGeometryCallback", function (evt) {
1838
- editCallback(evt.args);
1839
- });
1840
- }
1841
- if (deleteCallback != undefined) {
1842
- that.bindEvent("deleteGeometryCallback", function (evt) {
1843
- deleteCallback(evt.args);
1844
- });
1845
- }
1846
- if (params[3] == null) {
1847
- params[3] = styles.polygon.style;
1848
- }
1849
- scene.fire(msgPrefix + ":editGeometry", { args: params }, parentScene);
1850
- };
1851
-
1852
- /* 圆饼图 */
1853
- that.addCircleChart = function (name, data, color, param) {
1854
- color = color || "#1B5771";
1855
- param = param || { minRadius: 20, rangeRadius: 20 };
1856
- scene.fire(
1857
- msgPrefix + ":addCircleChart",
1858
- { args: [name, data, color, param] },
1859
- parentScene
1860
- );
1861
- };
1862
-
1863
- /* 饼图 */
1864
- //by ysj,2020-06-03
1865
- that.addChart = function (
1866
- option,
1867
- zoom,
1868
- clickCallback,
1869
- id,
1870
- minZoom,
1871
- maxZoom
1872
- ) {
1873
- that.removeEventBind("chartsLayerClickCallback");
1874
- if (clickCallback != undefined) {
1875
- that.bindEvent("chartsLayerClickCallback", function (evt) {
1876
- clickCallback(evt.args);
1877
- });
1878
- }
1879
- scene.fire(
1880
- msgPrefix + ":addChart",
1881
- { args: [option, zoom, id, minZoom, maxZoom] },
1882
- parentScene
1883
- );
1884
- };
1885
-
1886
- that.drawGeometry = function (type, style, clear, callback, option) {
1887
- type = type || "point";
1888
- style = style || {
1889
- type: "esriSLS",
1890
- style: "esriSLSSolid",
1891
- color: [255, 0, 0, 255],
1892
- width: 2,
1893
- };
1894
- //移除监听
1895
- that.removeEventBind("drawGeometryCallback");
1896
- if (callback != undefined) {
1897
- that.bindEvent("drawGeometryCallback", function (evt) {
1898
- callback(evt.args);
1899
- });
1900
- }
1901
-
1902
- scene.fire(
1903
- msgPrefix + ":drawGeometry",
1904
- { args: [type, style, clear, callback, option] },
1905
- parentScene
1906
- );
1907
- };
1908
-
1909
- /* 热力图*/
1910
- that.addHeatMap = function (data, option) {
1911
- scene.fire(
1912
- msgPrefix + ":addHeatMap",
1913
- { args: [data, option] },
1914
- parentScene
1915
- );
1916
- };
1917
-
1918
- /**
1919
- * 淹没点分析
1920
- */
1921
- that.addDrownPoint = function (option) {
1922
- scene.fire(
1923
- msgPrefix + ":addDrownPoint",
1924
- { args: [option] },
1925
- parentScene
1926
- );
1927
- };
1928
- that.removeDrownPoint = function (id) {
1929
- scene.fire(
1930
- msgPrefix + ":removeDrownPoint",
1931
- { args: [id] },
1932
- parentScene
1933
- );
1934
- };
1935
-
1936
- /* 聚类 */
1937
- that.addClusterLayer = function (data, id) {
1938
- scene.fire(
1939
- msgPrefix + ":addClusterLayer",
1940
- { args: [data, id] },
1941
- parentScene
1942
- );
1943
- };
1944
- /* 添加热区图层 */
1945
- that.addHotLayer = function (
1946
- layerUsageID,
1947
- outFields,
1948
- visiblelevel,
1949
- clickCallback,
1950
- style,
1951
- hstyle
1952
- ) {
1953
- var usageID = layerUsageID || 3007;
1954
- var style = style || {
1955
- type: "esriSFS",
1956
- style: "esriSFSSolid",
1957
- color: [100, 100, 100, 125],
1958
- outline: {
1959
- type: "esriSLS",
1960
- style: "esriSLSSolid",
1961
- color: [255, 0, 0, 255],
1962
- width: 1,
1963
- },
1964
- };
1965
- var hstyle = hstyle || {
1966
- type: "esriSFS",
1967
- style: "esriSFSSolid",
1968
- color: [100, 100, 255, 125],
1969
- outline: {
1970
- type: "esriSLS",
1971
- style: "esriSLSSolid",
1972
- color: [255, 0, 0, 255],
1973
- width: 1,
1974
- },
1975
- };
1976
- var where = null;
1977
- scene.fire(
1978
- msgPrefix + ":addCustomWMSLayer",
1979
- { args: [usageID, style, hstyle, where, outFields, visiblelevel] },
1980
- parentScene
1981
- );
1982
-
1983
- if (clickCallback) {
1984
- that.removeEventBind("CustomWMSLayerMouseClick");
1985
- that.bindEvent("CustomWMSLayerMouseClick", function (evt) {
1986
- clickCallback(evt.args);
1987
- });
1988
- }
1989
- };
1990
-
1991
- /* 添加等值线图 */
1992
- that.addKrigingMap = function (datalist, options) {
1993
- scene.fire(
1994
- msgPrefix + ":addKrigingMap",
1995
- { args: [datalist, options] },
1996
- parentScene
1997
- );
1998
- };
1999
-
2000
- /* 删除热区图层 */
2001
- that.removeHotLayer = function () {
2002
- scene.fire(
2003
- msgPrefix + ":removeLayer",
2004
- { args: ["CustomWMSLayer"] },
2005
- parentScene
2006
- );
2007
- };
2008
-
2009
- /* 图层查询 */
2010
- that.queryPhylayerFeatures = function (params, callback) {
2011
- // 移除监听
2012
- that.removeEventBind("queryPhylayerFeaturesCallback");
2013
-
2014
- if (callback != undefined) {
2015
- that.bindEvent("queryPhylayerFeaturesCallback", function (evt) {
2016
- callback(evt.args);
2017
- });
2018
- }
2019
- scene.fire(
2020
- msgPrefix + ":queryPhylayerFeatures",
2021
- {
2022
- args: [
2023
- params.queryType,
2024
- params.queryValue,
2025
- params.phyLayerIDs,
2026
- params.where,
2027
- params.params,
2028
- params.startIndex,
2029
- params.maxFeatures,
2030
- ],
2031
- },
2032
- parentScene
2033
- );
2034
- };
2035
- // /* 执行查询任务 */
2036
- // that.executeQueryTask = function(params, callback) {
2037
- // var queryTaskContext = {};
2038
- // queryTaskContext.callback = callback;
2039
- // queryTaskContext.gisSuccessFn = queryTaskContext.gisErrorFn = function(data, result) {
2040
- // this.callback(result);
2041
- // }
2042
- // var queryTaskService = http.getInstance("", {type : "post", async: false, "callback": callback }, queryTaskContext.gisSuccessFn, queryTaskContext.gisErrorFn, queryTaskContext);
2043
- // queryTaskService.settings.url = context.gisServerURL + "/home/gis/event/execquerytask.htm";
2044
- // queryTaskService.ajax(params);
2045
- // }
2046
- /* 显示消息框 */
2047
- that.showInfoWindow = function (params) {
2048
- var visible = params.visible;
2049
- var position = {};
2050
- position.x = params.x;
2051
- position.y = params.y;
2052
- var title = params.title;
2053
- var content = params.content;
2054
- scene.fire(
2055
- msgPrefix + ":infoWindow",
2056
- { args: [visible, position, title, content] },
2057
- parentScene
2058
- );
2059
- };
2060
- /* 隐藏消息框 */
2061
- that.hideInfoWindow = function (params) {
2062
- scene.fire(msgPrefix + ":infoWindow", { args: [false] }, parentScene);
2063
- };
2064
-
2065
- /* 显示扩展消息框 */
2066
- that.showInfoWindowEx = function (params) {
2067
- scene.fire(
2068
- msgPrefix + ":showInfoWindow",
2069
- {
2070
- args: [
2071
- params.id || 0,
2072
- params.title,
2073
- params.content,
2074
- params.x,
2075
- params.y,
2076
- params.style,
2077
- params.options,
2078
- ],
2079
- },
2080
- parentScene
2081
- );
2082
- };
2083
- /* 显示扩展消息框 */
2084
- that.hideInfoWindowEx = function (id) {
2085
- scene.fire(
2086
- msgPrefix + ":hideInfoWindow",
2087
- {
2088
- args: [id],
2089
- },
2090
- parentScene
2091
- );
2092
- };
2093
- /** 设置扩展消息框样式
2094
- * option 基础样式选项,格式如:{noTitle:true,close:true,title:{},background:'#FFF'}
2095
- * noTitle: 是否显示标题栏;
2096
- * close: 是否显示关闭按钮;
2097
- * title: 标题栏的css样式对象
2098
- * background : 除标题栏外的其他部分的颜色
2099
- * style 位置和大小的配置,格式如:{width:300,height:300,achor:'auto',offsetY:0}
2100
- * width: 宽度
2101
- * height:高度
2102
- * achor:箭头方向,其中值包含 'top','left','right','bottom','auto'
2103
- * offsetY:Y方向上的偏移
2104
- **/
2105
- that.setInfoWindowStyle = function (option, style, id) {
2106
- scene.fire(
2107
- msgPrefix + ":setInfoWindowStyle",
2108
- {
2109
- args: [option, style, id],
2110
- },
2111
- parentScene
2112
- );
2113
- };
2114
-
2115
- /* 要素查询 */
2116
- that.queryFeature = function (params, callback) {
2117
- if (scene == null) return;
2118
- scene.fire(
2119
- msgPrefix + ":queryFeature",
2120
- {
2121
- args: [
2122
- params.layerID,
2123
- params.where || null,
2124
- params.geometry || null,
2125
- params.outFields,
2126
- params.outGeometry,
2127
- params.pointTolorence || 0,
2128
- params.startIndex,
2129
- params.maxFeatures,
2130
- null,
2131
- callback || null,
2132
- params.sortBy,
2133
- params.filterNullGeometry,
2134
- params.options,
2135
- params.featureIds,
2136
- ],
2137
- },
2138
- parentScene
2139
- );
2140
- };
2141
-
2142
- /* 显示图层
2143
- * layerID:图层ID ,
2144
- * serviceID:服务ID(可选),
2145
- * showAtBottom:是否显示在最底层(true:显示到最底层,false:显示在最顶层),
2146
- * zoomLevel:缩放级别(传入数字为缩放到对应的级别,传入true缩放到最大可视级别)
2147
- */
2148
- that.showVectorLayer = function (
2149
- layerID,
2150
- serviceID,
2151
- showAtBottom,
2152
- zoomLevel
2153
- ) {
2154
- if (scene == null) return;
2155
- scene.fire(
2156
- msgPrefix + ":showVectorLayer",
2157
- { args: [layerID, serviceID, showAtBottom, zoomLevel] },
2158
- parentScene
2159
- );
2160
- };
2161
-
2162
- /* 隐藏图层 */
2163
- that.hideVectorLayer = function (layerID, serviceID) {
2164
- if (scene == null) return;
2165
- scene.fire(
2166
- msgPrefix + ":hideVectorLayer",
2167
- { args: [layerID, serviceID] },
2168
- parentScene
2169
- );
2170
- };
2171
-
2172
- /* 获取当前地图范围 */
2173
- that.getMapExtent = function (callback) {
2174
- // 移除监听
2175
- that.removeEventBind("getMapExtentCallback");
2176
-
2177
- if (callback != undefined) {
2178
- that.bindEvent("getMapExtentCallback", function (evt) {
2179
- callback(evt.args);
2180
- });
2181
- }
2182
- scene.fire(msgPrefix + ":getMapExtent", { args: [] }, parentScene);
2183
- };
2184
-
2185
- /**查询表信息*/
2186
- that.queryObjectInfo = function (
2187
- geoShapes,
2188
- tableName,
2189
- xFieldName,
2190
- yFieldName,
2191
- callback,
2192
- usePage,
2193
- currentPage,
2194
- numPerPage,
2195
- params,
2196
- cacheKey
2197
- ) {
2198
- var queryParam = {
2199
- tableName: tableName,
2200
- xFieldName: xFieldName,
2201
- yFieldName: yFieldName,
2202
- };
2203
- if (params)
2204
- queryParam = MapUtils.deepClones(true, {}, queryParam, params);
2205
-
2206
- that.removeEventBind("queryObjectInfoCallback");
2207
- that.bindEvent("queryObjectInfoCallback", callback);
2208
- scene.fire(
2209
- msgPrefix + ":queryObjectInfo",
2210
- {
2211
- args: [
2212
- JSON.stringify(geoShapes),
2213
- JSON.stringify(queryParam),
2214
- usePage,
2215
- currentPage,
2216
- numPerPage,
2217
- cacheKey,
2218
- ],
2219
- },
2220
- parentScene,
2221
- false
2222
- );
2223
- };
2224
-
2225
- that.enableMapSnap = function (layerID, callback) {
2226
- if (scene == null) return;
2227
- if (!layerID) return;
2228
- that.removeEventBind("enableMapSnapCallback");
2229
- that.bindEvent("enableMapSnapCallback", callback);
2230
- scene.fire(
2231
- msgPrefix + ":enableMapSnap",
2232
- {
2233
- args: [layerID],
2234
- },
2235
- parentScene
2236
- );
2237
- };
2238
-
2239
- that.disableMapSnap = function (layerID) {
2240
- if (scene == null) return;
2241
- if (!layerID) return;
2242
- scene.fire(
2243
- msgPrefix + ":disableMapSnap",
2244
- {
2245
- args: [layerID],
2246
- },
2247
- parentScene
2248
- );
2249
- };
2250
-
2251
- that.addMaskLayer = function (
2252
- layerID,
2253
- keyField,
2254
- values,
2255
- style,
2256
- zoom,
2257
- position
2258
- ) {
2259
- scene.fire(
2260
- msgPrefix + ":addMaskLayer",
2261
- { args: [layerID, keyField, values, style, zoom, position] },
2262
- parentScene
2263
- );
2264
- };
2265
-
2266
- /* 计算线、面长度,支持线、面格式 */
2267
- that.getGeometryLength = function (geometry) {
2268
- return scene.fire(
2269
- msgPrefix + ":getGeometryLength",
2270
- { args: [geometry] },
2271
- parentScene
2272
- );
2273
- };
2274
-
2275
- /* 计算多边形面积 */
2276
- that.getPolygonArea = function (geometry) {
2277
- return scene.fire(
2278
- msgPrefix + ":getPolygonArea",
2279
- { args: [geometry] },
2280
- parentScene
2281
- );
2282
- };
2283
-
2284
- that.intersectGeometry = function (polygon1, polygon2) {
2285
- return scene.fire(
2286
- msgPrefix + ":intersectGeometry",
2287
- { args: [polygon1, polygon2] },
2288
- parentScene
2289
- );
2290
- };
2291
-
2292
- that.getCenterPoint = function (polygon) {
2293
- return scene.fire(
2294
- msgPrefix + ":getCenterPoint",
2295
- { args: [polygon] },
2296
- parentScene
2297
- );
2298
- };
2299
-
2300
- /* 根据PointID定位空中全景 */
2301
- that.mmsAirPanoLocateByID = function (pointID) {
2302
- if (mmsMap && mmsMap.mmsLoaded) {
2303
- scene.fire(
2304
- msgPrefix + ":mmsAirPanoLocateCallback",
2305
- { args: [pointID] },
2306
- parentScene
2307
- );
2308
- }
2309
- };
2310
-
2311
- /* 空中全景历史对比回调 */
2312
- that.mmsAirPanoCompare = function (callback) {
2313
- if (mmsMap && mmsMap.mmsLoaded) {
2314
- scene.fire(
2315
- msgPrefix + ":mmsAirPanoCompareCallback",
2316
- { args: [callback] },
2317
- parentScene
2318
- );
2319
- }
2320
- };
2321
-
2322
- that.setMMSEyePositionTest = function (x, y) {
2323
- var pos = { x: x, y: y };
2324
- var evt = { args: [pos] };
2325
- mmsMap.setMMSEyePosition(evt);
2326
- };
2327
-
2328
- /* 切换地图类型 */
2329
- that.changeControlParam = function (type, param) {
2330
- scene.fire(
2331
- msgPrefix + ":changeControlParam",
2332
- { args: [type, param] },
2333
- parentScene
2334
- );
2335
- };
2336
-
2337
- /* 获取图层信息 */
2338
- that.getPhyLayerInfo = function (phyLayerID, getPhyLayerInfoCallBack) {
2339
- that.removeEventBind("getPhyLayerInfoCallback");
2340
- if (getPhyLayerInfoCallBack != undefined) {
2341
- that.bindEvent("getPhyLayerInfoCallback", function (evt) {
2342
- getPhyLayerInfoCallBack(evt.args);
2343
- });
2344
- }
2345
- scene.fire(
2346
- msgPrefix + ":getPhyLayerInfo",
2347
- { args: [phyLayerID] },
2348
- parentScene,
2349
- true
2350
- );
2351
- };
2352
-
2353
- /* 获取图层字段信息 */
2354
- that.getPhyLayerField = function (phyLayerIDs, getPhyLayerFieldCallback) {
2355
- that.removeEventBind("getPhyLayerFieldCallback");
2356
- if (getPhyLayerFieldCallback != undefined) {
2357
- that.bindEvent("getPhyLayerFieldCallback", function (evt) {
2358
- getPhyLayerFieldCallback(evt.args);
2359
- });
2360
- }
2361
- scene.fire(
2362
- msgPrefix + ":getPhyLayerField",
2363
- { args: [phyLayerIDs] },
2364
- parentScene,
2365
- true
2366
- );
2367
- };
2368
-
2369
- /* 获取图层字段信息 */
2370
- that.getPhyLayerField = function (phyLayerIDs, getPhyLayerFieldCallback) {
2371
- that.removeEventBind("getPhyLayerFieldCallback");
2372
- if (getPhyLayerFieldCallback != undefined) {
2373
- that.bindEvent("getPhyLayerFieldCallback", function (evt) {
2374
- getPhyLayerFieldCallback(evt.args);
2375
- });
2376
- }
2377
- scene.fire(
2378
- msgPrefix + ":getPhyLayerField",
2379
- { args: [phyLayerIDs] },
2380
- parentScene,
2381
- true
2382
- );
2383
- };
2384
-
2385
- /*对几何图形进行缓冲*/
2386
- that.getGeometryBuffer = function (
2387
- geometry,
2388
- radius,
2389
- callback,
2390
- autoTransRadius
2391
- ) {
2392
- that.removeEventBind("getGeometryBufferCallback");
2393
- if (callback != undefined) {
2394
- that.bindEvent("getGeometryBufferCallback", function (evt) {
2395
- callback(evt.args);
2396
- });
2397
- }
2398
- scene.fire(
2399
- msgPrefix + ":getGeometryBuffer",
2400
- { args: [geometry, radius, autoTransRadius] },
2401
- parentScene,
2402
- true
2403
- );
2404
- };
2405
-
2406
- /* 移除图层*/
2407
- that.removeLayer = function (layerName) {
2408
- scene.fire(
2409
- msgPrefix + ":removeLayer",
2410
- { args: [layerName] },
2411
- parentScene,
2412
- true
2413
- );
2414
- };
2415
-
2416
- that.change3dlayerUsageConfig = function () {
2417
- if (scene == null) return;
2418
- var config = scene.layerUsageConfig;
2419
- scene.fire(
2420
- msgPrefix + ":change3dlayerUsageConfig",
2421
- { args: [config] },
2422
- parentScene
2423
- );
2424
- };
2425
- /*显示多轨迹*/
2426
- that.showTraceMultiHisLayer = function (
2427
- objectIDs,
2428
- symbolType,
2429
- beginDate,
2430
- endDate,
2431
- clear,
2432
- zoom,
2433
- hStyle
2434
- ) {
2435
- scene.fire(
2436
- msgPrefix + ":showTraceMultiHisLayer",
2437
- {
2438
- args: [
2439
- objectIDs,
2440
- symbolType,
2441
- beginDate,
2442
- endDate,
2443
- clear,
2444
- zoom,
2445
- hStyle,
2446
- ],
2447
- },
2448
- parentScene
2449
- );
2450
- };
2451
- /*清除多轨迹*/
2452
- that.claerTraceMultiHisLayer = function () {
2453
- scene.fire(
2454
- msgPrefix + ":claerTraceMultiHisLayer",
2455
- { args: [] },
2456
- parentScene
2457
- );
2458
- };
2459
- /*多人员图标通过id高亮*/
2460
- that.multiPointsSelectbyID = function (id) {
2461
- scene.fire(
2462
- msgPrefix + ":multiPointsSelectbyID",
2463
- { args: [id] },
2464
- parentScene
2465
- );
2466
- };
2467
- /*多轨迹通过id高亮*/
2468
- that.traceMultiSelectbyID = function (id) {
2469
- scene.fire(
2470
- msgPrefix + ":traceMultiSelectbyID",
2471
- { args: [id] },
2472
- parentScene
2473
- );
2474
- };
2475
-
2476
- // arcgis格式geometry转wkt格式
2477
- that.agsToWKT = function (geometry, callback) {
2478
- scene.fire(
2479
- msgPrefix + ":agsToWKT",
2480
- { args: [geometry, callback] },
2481
- parentScene
2482
- );
2483
- };
2484
- /*网格化方式绘制管线*/
2485
- that.showCustomGrid = function (jsonInfo, region) {
2486
- scene.fire(
2487
- msgPrefix + ":showCustomGrid",
2488
- { args: [jsonInfo, region] },
2489
- parentScene
2490
- );
2491
- };
2492
-
2493
- /*网格化方式清除管线*/
2494
- that.clearCustomGrid = function () {
2495
- scene.fire(msgPrefix + ":clearCustomGrid", { args: [] }, parentScene);
2496
- };
2497
-
2498
- /**
2499
- * 开始测量
2500
- * @param {*} options {type:'area'|'length'; callBack:绘制完成回调函数;errorCallBack:错误回调函数;}
2501
- */
2502
- that.startMeasure = function (options) {
2503
- if (scene == null) return;
2504
- scene.fire(
2505
- msgPrefix + ":startMeasure",
2506
- { args: [options] },
2507
- parentScene,
2508
- false
2509
- );
2510
- };
2511
-
2512
- // 结束测量
2513
- that.stopMeasure = function () {
2514
- if (scene == null) return;
2515
- scene.fire(
2516
- msgPrefix + ":stopMeasure",
2517
- { args: [] },
2518
- parentScene,
2519
- false
2520
- );
2521
- };
2522
-
2523
- that.mouseMoveEvent = function (callback) {
2524
- if (scene == null) return;
2525
- scene.fire(
2526
- msgPrefix + ":mouseMoveEvent",
2527
- { args: [callback] },
2528
- parentScene,
2529
- false
2530
- );
2531
- };
2532
-
2533
- that.init();
2534
- };
2535
- 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 (
56
+ $container,
57
+ pScene,
58
+ prefix,
59
+ gisParams,
60
+ mapConfig,
61
+ context
62
+ ) {
63
+ var that = this;
64
+ scene = pScene;
65
+ var parentScene = pScene.pageId || "parentScene";
66
+ var msgPrefix = prefix || "gismappage";
67
+ var mmsMap = null;
68
+ that.gisVisible = false;
69
+ that.gisLoaded = false;
70
+ that.isLoading = false;
71
+
72
+ that.$gisMapFrame = null;
73
+ that.gisMapContainer = null;
74
+
75
+ that.gisMapContainer =
76
+ $container.getElementsByClassName("emap-container")[0];
77
+ if (!that.gisMapContainer) {
78
+ var mapHTML = '<iframe class="emap-iframe"></iframe>';
79
+ var element = document.createElement("div");
80
+ element.classList.add("emap-container");
81
+ element.innerHTML = mapHTML;
82
+ $container.appendChild(element);
83
+ that.gisMapContainer = element;
84
+ }
85
+
86
+ that.$gisMapFrame =
87
+ that.gisMapContainer.getElementsByClassName("emap-iframe")[0];
88
+ that.onMapLoadedHandlers = [];
89
+
90
+ that.onMapLoaded = function () {
91
+ that.isLoading = false;
92
+ that.gisLoaded = true;
93
+ if (context.mapCenterFlag) {
94
+ if (context.mapCenterFlag == "1") {
95
+ if (context.coordinateX && context.coordinateY) {
96
+ that.centerAndZoom(
97
+ context.coordinateX,
98
+ context.coordinateY,
99
+ 4
100
+ );
101
+ }
102
+ } else if (context.mapCenterFlag == "2") {
103
+ if (context.coordinateX && context.coordinateY) {
104
+ that.centerAndZoom(
105
+ context.coordinateX,
106
+ context.coordinateY,
107
+ 1
108
+ );
109
+ }
110
+ if (context.humanLayerUsageID && context.regionCode) {
111
+ var zoom = gisParams && gisParams.maskZoom == true;
112
+ var style = {
113
+ type: "esriSFS",
114
+ style: "esriSFSSolid",
115
+ color: [100, 100, 255, 125],
116
+ outline: {
117
+ type: "esriSLS",
118
+ style: "esriSLSSolid",
119
+ color: [255, 0, 0, 255],
120
+ width: 1,
121
+ },
122
+ };
123
+ var pos = { visible: true, top: 95, right: 127 };
124
+ if (mapConfig && mapConfig.maskPos) {
125
+ pos = MapUtils.deepClones({}, pos, mapConfig.maskPos);
126
+ }
127
+ that.addMaskLayer(
128
+ context.humanLayerUsageID,
129
+ context.humanLayerKeyFieldName,
130
+ context.regionCode,
131
+ style,
132
+ zoom,
133
+ pos
134
+ );
135
+ }
136
+ } else if (context.mapCenterFlag == "3") {
137
+ if (context.coordinateX && context.coordinateY) {
138
+ that.centerAndZoom(
139
+ context.coordinateX,
140
+ context.coordinateY,
141
+ 1
142
+ );
143
+ }
144
+ if (context.humanLayerUsageID && context.regionCode) {
145
+ var zoom = gisParams && gisParams.maskZoom == false;
146
+ var style = {
147
+ type: "esriSFS",
148
+ style: "esriSFSSolid",
149
+ color: [100, 100, 255, 0],
150
+ outline: {
151
+ type: "esriSLS",
152
+ style: "esriSLSSolid",
153
+ color: [255, 0, 0, 255],
154
+ width: 3,
155
+ },
156
+ };
157
+ var pos = { visible: true, top: 95, right: 127 };
158
+ if (mapConfig && mapConfig.maskPos) {
159
+ pos = MapUtils.deepClones({}, pos, mapConfig.maskPos);
160
+ }
161
+ that.addMaskLayer(
162
+ context.humanLayerUsageID,
163
+ context.humanLayerKeyFieldName,
164
+ context.regionCode,
165
+ style,
166
+ zoom,
167
+ pos
168
+ );
169
+ }
170
+ }
171
+ }
172
+ for (var i = 0, len = that.onMapLoadedHandlers.length; i < len; i++) {
173
+ that.onMapLoadedHandlers[i]();
174
+ }
175
+ };
176
+
177
+ that.init = function () {
178
+ if (!that.gisLoaded && !that.isLoading) {
179
+ that.isLoading = true;
180
+ checkGisServerURL(context.gisServerURL, function (gisurl) {
181
+ var bust = new Date().getTime();
182
+ var gisServerURL = (context.gisServerURL = gisurl);
183
+ var gisProxyURL = context.gisServerURL + "/home/gis/proxy.htm";
184
+ var misServerURL = context.rootPath;
185
+ var url =
186
+ context.rootPath +
187
+ context.assetsPath +
188
+ "/map.html?parentScene=" +
189
+ parentScene +
190
+ "&msgPrefix=" +
191
+ msgPrefix +
192
+ "&bust=" +
193
+ bust +
194
+ "&serverURL=" +
195
+ gisServerURL +
196
+ "&proxyURL=" +
197
+ gisProxyURL +
198
+ "&misURL=" +
199
+ misServerURL +
200
+ "&humanID=" +
201
+ context.humanID;
202
+ if (mapConfig != undefined && mapConfig.params != undefined) {
203
+ for (var item in mapConfig.params) {
204
+ url +=
205
+ "&" +
206
+ item +
207
+ "=" +
208
+ encodeURIComponent(mapConfig.params[item]);
209
+ }
210
+ }
211
+ if (context.mapZoomRange) {
212
+ var mapZoomRanges = context.mapZoomRange.split(",");
213
+ if (mapZoomRanges.length == 2) {
214
+ url +=
215
+ "&minlevel=" +
216
+ mapZoomRanges[0] +
217
+ "&maxlevel=" +
218
+ mapZoomRanges[1];
219
+ }
220
+ }
221
+ that.$gisMapFrame.src = url;
222
+ that.$gisMapFrame.onload = function () {
223
+ if (
224
+ !this.contentDocument.documentElement
225
+ .getElementsByTagName("head")
226
+ .item(0)
227
+ .outerHTML.includes("/library/egovagis/map/map.js")
228
+ ) {
229
+ var mainScript =
230
+ this.contentDocument.createElement("script");
231
+ mainScript.setAttribute("type", "text/javascript");
232
+ mainScript.setAttribute(
233
+ "src",
234
+ gisServerURL + "/library/egovagis/map/map.js"
235
+ );
236
+ this.contentDocument.documentElement
237
+ .getElementsByTagName("head")
238
+ .item(0)
239
+ .appendChild(mainScript);
240
+ }
241
+ };
242
+ });
243
+ try {
244
+ //如果启用了实景功能需要注册实景监听
245
+ if (context.mmsEnabled != undefined && that.gisMapContainer) {
246
+ var mmsEnabled = Number(context.mmsEnabled);
247
+ if (mmsEnabled > 0) {
248
+ mmsMap = new EGovaMMSMap(
249
+ $container,
250
+ scene,
251
+ msgPrefix,
252
+ context.mmsParams,
253
+ mapConfig,
254
+ mmsEnabled
255
+ );
256
+ }
257
+ }
258
+ } catch (e) {
259
+ console.error(e.message);
260
+ }
261
+ }
262
+
263
+ //初始化时不显示地图
264
+ that.closeMap();
265
+ // 监听地图加载完成的事件
266
+ scene.on(
267
+ msgPrefix + ":mapLoadedCallback",
268
+ that.onMapLoaded,
269
+ parentScene,
270
+ false
271
+ );
272
+ };
273
+
274
+ /**
275
+ * 二维地图显示
276
+ *
277
+ * @param res
278
+ */
279
+ that.openMap = function (evt) {
280
+ if (!that.gisVisible) {
281
+ // 初次定位时调整布局
282
+ if (!that.gisLoaded && !that.isLoading) {
283
+ that.isLoading = true;
284
+ checkGisServerURL(context.gisServerURL, function () {
285
+ var gisServerURL = context.gisServerURL;
286
+ var gisProxyURL =
287
+ context.gisServerURL + "/home/gis/proxy.htm";
288
+ var misServerURL = context.rootPath;
289
+ var url =
290
+ context.rootPath +
291
+ context.assetsPath +
292
+ "/map.html?parentScene=" +
293
+ parentScene +
294
+ "&msgPrefix=" +
295
+ msgPrefix +
296
+ "&serverURL=" +
297
+ gisServerURL +
298
+ "&proxyURL=" +
299
+ gisProxyURL +
300
+ "&misURL=" +
301
+ misServerURL +
302
+ "&humanID=" +
303
+ context.humanID;
304
+ if (
305
+ mapConfig != undefined &&
306
+ mapConfig.params != undefined
307
+ ) {
308
+ for (var item in mapConfig.params) {
309
+ url += "&" + item + "=" + mapConfig.params[item];
310
+ }
311
+ }
312
+ that.$gisMapFrame.src = url;
313
+ that.$gisMapFrame.onload = function () {
314
+ if (
315
+ !this.contentDocument.documentElement
316
+ .getElementsByTagName("head")
317
+ .item(0)
318
+ .outerHTML.includes(
319
+ "/library/egovagis/map/map.js"
320
+ )
321
+ ) {
322
+ var mainScript =
323
+ this.contentDocument.createElement("script");
324
+ mainScript.setAttribute("type", "text/javascript");
325
+ mainScript.setAttribute(
326
+ "src",
327
+ gisServerURL + "/library/egovagis/map/map.js"
328
+ );
329
+ this.contentDocument.documentElement
330
+ .getElementsByTagName("head")
331
+ .item(0)
332
+ .appendChild(mainScript);
333
+ }
334
+ };
335
+ });
336
+ try {
337
+ //如果启用了实景功能需要注册实景监听,msgPrefix+'old',为了兼容以前的GIS实景结合
338
+ if (
339
+ context.mmsEnabled != undefined &&
340
+ context.mmsEnabled == "1" &&
341
+ that.gisMapContainer
342
+ ) {
343
+ mmsMap = new EGovaMMSMap(
344
+ $container,
345
+ scene,
346
+ msgPrefix + "old",
347
+ context.mmsParams,
348
+ mapConfig
349
+ );
350
+ }
351
+ } catch (e) {
352
+ alert(e.message);
353
+ }
354
+ }
355
+
356
+ that.gisMapContainer.style.height = "100%";
357
+ that.gisMapContainer.style.display = "block";
358
+ that.gisVisible = true;
359
+ }
360
+ };
361
+
362
+ /**
363
+ * 二维地图关闭
364
+ */
365
+ that.closeMap = function (evt) {
366
+ that.gisMapContainer.style.display = "block";
367
+ that.gisMapContainer.style.height = "0";
368
+ that.gisVisible = false;
369
+ };
370
+
371
+ /* 绑定事件 */
372
+ that.bindEvent = function (msgId, msgHandler, stopOnTop) {
373
+ if (scene == null) return;
374
+ scene.on(msgPrefix + ":" + msgId, msgHandler, parentScene, stopOnTop);
375
+ };
376
+ /* 触发事件 */
377
+ that.fireEvent = function (msgId, msgData, stopOnTop) {
378
+ if (scene == null) return;
379
+ scene.fire(msgPrefix + ":" + msgId, msgData, parentScene, stopOnTop);
380
+ };
381
+ /* 移除监听 */
382
+ that.removeEventBind = function (msgId, stopOnTop) {
383
+ if (scene == null) return;
384
+ scene.remove(msgPrefix + ":" + msgId, parentScene, stopOnTop);
385
+ };
386
+ /* 设置图层显示顺序 */
387
+ that.reorderLayer = function (id, order, options) {
388
+ if (scene == null) return;
389
+ scene.fire(
390
+ msgPrefix + ":reorderLayer",
391
+ { args: [id, order, options] },
392
+ parentScene
393
+ );
394
+ };
395
+ /* 切换到平移工具 */
396
+ that.panMap = function () {
397
+ if (scene == null) return;
398
+ scene.fire(msgPrefix + ":panMap", parentScene);
399
+ };
400
+ /* 缩放到指定范围 */
401
+ that.zoomToExtent = function (minX, minY, maxX, maxY) {
402
+ if (scene == null) return;
403
+ scene.fire(
404
+ msgPrefix + ":zoomToExtent",
405
+ { args: [Number(minX), Number(minY), Number(maxX), Number(maxY)] },
406
+ parentScene,
407
+ false
408
+ );
409
+ };
410
+ /* 缩放到指定中心点和级别 */
411
+ that.centerAndZoom = function (x, y, level) {
412
+ if (scene == null) return;
413
+ scene.fire(
414
+ msgPrefix + ":centerAndZoom",
415
+ { args: [x, y, level] },
416
+ parentScene,
417
+ false
418
+ );
419
+ };
420
+ /* 缩放到全图范围 */
421
+ that.zoomToFullExtent = function () {
422
+ if (scene == null) return;
423
+ scene.fire(msgPrefix + ":fullExtent", { args: [] }, parentScene, false);
424
+ };
425
+ /* 绘制图形 */
426
+ that.drawGraphic = function (graphic, zoom, clickCallback) {
427
+ if (scene == null) return;
428
+ if (graphic.geometry instanceof Array) {
429
+ scene.fire(
430
+ msgPrefix + ":locateFeatureByCoords",
431
+ {
432
+ args: [
433
+ graphic.geometry,
434
+ graphic.type,
435
+ graphic.id,
436
+ graphic.style,
437
+ graphic.hstyle,
438
+ zoom,
439
+ graphic.keyField,
440
+ graphic.labelField,
441
+ graphic.labelStyle,
442
+ graphic.colorNumber,
443
+ graphic.renderCanvas,
444
+ graphic.singleSelected,
445
+ graphic.options,
446
+ graphic.layerTag,
447
+ ],
448
+ },
449
+ parentScene
450
+ );
451
+ } else {
452
+ // scene.fire(msgPrefix+":locateFeatureByCoord",
453
+ // {args:[{"geometry":graphic.geometry},graphic.type,graphic.id,graphic.style,graphic.hstyle,zoom]},parentScene);
454
+ scene.fire(
455
+ msgPrefix + ":locateFeatureByCoords",
456
+ {
457
+ args: [
458
+ [graphic.geometry],
459
+ graphic.type,
460
+ graphic.id,
461
+ graphic.style,
462
+ graphic.hstyle,
463
+ zoom,
464
+ graphic.keyField,
465
+ graphic.labelField,
466
+ graphic.labelStyle,
467
+ graphic.colorNumber,
468
+ graphic.renderCanvas,
469
+ graphic.singleSelected,
470
+ graphic.options,
471
+ graphic.layerTag,
472
+ ],
473
+ },
474
+ parentScene
475
+ );
476
+ }
477
+ that.removeEventBind("locateFeatureByIDsCallback");
478
+ if (clickCallback != undefined) {
479
+ that.bindEvent("locateFeatureByIDsCallback", function (evt) {
480
+ clickCallback(evt.args);
481
+ });
482
+ }
483
+ };
484
+
485
+ /*添加WMS服务图层*/
486
+ that.showWMSLayer = function (
487
+ layerUsageID,
488
+ IDs,
489
+ keyField,
490
+ geometry,
491
+ where
492
+ ) {
493
+ if (scene == null) return;
494
+ scene.fire(
495
+ msgPrefix + ":showWMSLayer",
496
+ { args: [layerUsageID, IDs, keyField, geometry, where] },
497
+ parentScene,
498
+ false
499
+ );
500
+ };
501
+
502
+ /*清除WMS服务图层*/
503
+ that.removeWMSLayer = function (serviceID) {
504
+ if (scene == null) return;
505
+ scene.fire(
506
+ msgPrefix + ":removeWMSLayer",
507
+ { args: [serviceID] },
508
+ parentScene,
509
+ false
510
+ );
511
+ };
512
+
513
+ /*添加自定义WMS服务图层*/
514
+ that.addCustomWMSLayer = function (
515
+ layerID,
516
+ style,
517
+ hStyle,
518
+ where,
519
+ outFields,
520
+ visibleLevel,
521
+ colorseparField,
522
+ colorseparoptions
523
+ ) {
524
+ if (scene == null) return;
525
+ scene.fire(
526
+ msgPrefix + ":addCustomWMSLayer",
527
+ {
528
+ args: [
529
+ layerID,
530
+ style,
531
+ hStyle,
532
+ where,
533
+ outFields,
534
+ visibleLevel,
535
+ colorseparField,
536
+ colorseparoptions,
537
+ ],
538
+ },
539
+ parentScene,
540
+ false
541
+ );
542
+ };
543
+
544
+ /*根据要素坐标定位显示要素*/
545
+ that.locateFeatureByCoords = function (
546
+ geometries,
547
+ type,
548
+ ID,
549
+ style,
550
+ hStyle,
551
+ zoom,
552
+ keyFiled,
553
+ labelField,
554
+ labelStyle,
555
+ randomColor,
556
+ renderCanvas,
557
+ singleSelected,
558
+ options,
559
+ layerTag
560
+ ) {
561
+ if (scene == null) return;
562
+ scene.fire(
563
+ msgPrefix + ":locateFeatureByCoords",
564
+ {
565
+ args: [
566
+ geometries,
567
+ type,
568
+ ID,
569
+ style,
570
+ hStyle,
571
+ zoom,
572
+ keyFiled,
573
+ labelField,
574
+ labelStyle,
575
+ randomColor,
576
+ renderCanvas,
577
+ singleSelected,
578
+ options,
579
+ layerTag,
580
+ ],
581
+ },
582
+ parentScene,
583
+ false
584
+ );
585
+ };
586
+ /* 清除指定图形 */
587
+ that.clearGraphic = function (id, tag) {
588
+ if (scene == null) return;
589
+ if (typeof id != "string") {
590
+ id = id.join(",");
591
+ }
592
+ if (tag) {
593
+ id = null;
594
+ }
595
+ scene.fire(
596
+ msgPrefix + ":clearGraphic",
597
+ { args: [id, tag] },
598
+ parentScene,
599
+ false
600
+ );
601
+ };
602
+ /* 清除全部图形 */
603
+ that.clearAllGraphics = function (id) {
604
+ if (scene == null) return;
605
+ scene.fire(
606
+ msgPrefix + ":clearAllGraphics",
607
+ { args: [] },
608
+ parentScene,
609
+ false
610
+ );
611
+ };
612
+ /* 在地图上标注 */
613
+ that.pointSelect = function (symbolType, zoomFalg, callback) {
614
+ if (scene == null) return;
615
+
616
+ // 移除监听
617
+ scene.remove(msgPrefix + ":pointSelectCallback", parentScene, false);
618
+
619
+ if (zoomFalg == undefined) zoomFalg = true;
620
+ if (callback) {
621
+ // 定义回调
622
+ scene.on(
623
+ msgPrefix + ":pointSelectCallback",
624
+ function (evt) {
625
+ // 移除监听
626
+ scene.remove(
627
+ msgPrefix + ":pointSelectCallback",
628
+ parentScene,
629
+ false
630
+ );
631
+ callback(evt.args);
632
+ },
633
+ parentScene,
634
+ false
635
+ );
636
+ }
637
+ scene.fire(
638
+ msgPrefix + ":pointSelect",
639
+ { args: [symbolType, zoomFalg] },
640
+ parentScene,
641
+ false
642
+ );
643
+ };
644
+ /* 获取图形外部矩形 */
645
+ that.getFeaturesExtent = function (features, callback) {
646
+ if (scene == null) return;
647
+
648
+ // 移除监听
649
+ scene.remove(
650
+ msgPrefix + ":getFeaturesExtentCallback",
651
+ parentScene,
652
+ false
653
+ );
654
+
655
+ scene.on(
656
+ msgPrefix + ":getFeaturesExtentCallback",
657
+ function (evt) {
658
+ // 移除监听
659
+ scene.remove(
660
+ msgPrefix + ":getFeaturesExtentCallback",
661
+ parentScene,
662
+ false
663
+ );
664
+ callback(evt.args);
665
+ },
666
+ parentScene,
667
+ false
668
+ );
669
+ scene.fire(
670
+ msgPrefix + ":getFeaturesExtent",
671
+ { args: features },
672
+ parentScene,
673
+ false
674
+ );
675
+ };
676
+
677
+ /* 获取可见图层 */
678
+ that.getVisibleLayerIds = function (callback) {
679
+ // 移除监听
680
+ scene.remove(
681
+ msgPrefix + ":getVisibleLayerIdsCallback",
682
+ parentScene,
683
+ false
684
+ );
685
+
686
+ scene.on(
687
+ msgPrefix + ":getVisibleLayerIdsCallback",
688
+ function (evt) {
689
+ // 移除监听
690
+ scene.remove(
691
+ msgPrefix + ":getVisibleLayerIdsCallback",
692
+ parentScene,
693
+ false
694
+ );
695
+ callback(evt.args);
696
+ },
697
+ parentScene,
698
+ false
699
+ );
700
+ scene.fire(
701
+ msgPrefix + ":getVisibleLayerIds",
702
+ { args: [] },
703
+ parentScene,
704
+ false
705
+ );
706
+ };
707
+
708
+ that.identifyInfoWindow = function (usageID, keyValue, content, size) {
709
+ if (scene == null) return;
710
+ scene.fire(
711
+ msgPrefix + ":identifyInfoWindow",
712
+ { args: [usageID, keyValue, content, size] },
713
+ parentScene,
714
+ false
715
+ );
716
+ };
717
+ /* 更改工具条参数 */
718
+ that.changeControlParam = function (id, param) {
719
+ if (scene == null) return;
720
+ scene.fire(
721
+ msgPrefix + ":changeControlParam",
722
+ { args: [id, param] },
723
+ parentScene,
724
+ false
725
+ );
726
+ };
727
+ /* 图层过滤显示 */
728
+ that.setLayerDef = function (phyLayerID, layerDef) {
729
+ if (scene == null) return;
730
+ scene.fire(
731
+ msgPrefix + ":setLayerDef",
732
+ { args: [phyLayerID, layerDef] },
733
+ parentScene,
734
+ false
735
+ );
736
+ };
737
+ that.setLayerColorDef = function (phyLayerIDs, colorDefs) {
738
+ if (scene == null) return;
739
+ scene.fire(
740
+ msgPrefix + ":setLayerColorDef",
741
+ { args: [phyLayerIDs, colorDefs] },
742
+ parentScene,
743
+ false
744
+ );
745
+ };
746
+
747
+ /* 显示图层树 */
748
+ that.showLayerTree = function (/* humanID, mapID */ openTree) {
749
+ if (scene == null) return;
750
+ /*
751
+ * var data = null; scene.fire(msgPrefix + ":showLayerTree", {args :
752
+ * [data, humanID, mapID]}, parentScene);
753
+ */
754
+ if (openTree == undefined || arguments.length > 1) openTree = true;
755
+ scene.fire(
756
+ msgPrefix + ":showLayerTree",
757
+ { args: [openTree] },
758
+ parentScene
759
+ );
760
+ };
761
+ /* I查询 */
762
+ that.identify = function (type, humanID, mapID, options) {
763
+ if (scene == null) return;
764
+ scene.fire(
765
+ msgPrefix + ":identify",
766
+ { args: [type, humanID, mapID] },
767
+ parentScene
768
+ );
769
+
770
+ // By hth 2021/4/6: 如果传入了回调函数,则绑定执行回调函数的监听事件
771
+ var cb = options && options.cb;
772
+ if (cb) {
773
+ // 移除监听
774
+ that.removeEventBind("identifySelectCallback");
775
+ if (cb !== undefined && typeof cb === "function") {
776
+ that.bindEvent("identifySelectCallback", function (evt) {
777
+ cb(evt.args);
778
+ });
779
+ }
780
+ }
781
+ };
782
+ /* 地理编码查询 */
783
+ that.geoCode = function (searchStr, callback) {
784
+ if (scene == null) return;
785
+ if (callback) {
786
+ // 移除监听
787
+ that.removeEventBind("geoCodeCallback");
788
+ if (callback != undefined) {
789
+ that.bindEvent("geoCodeCallback", function (evt) {
790
+ callback(evt.args);
791
+ });
792
+ }
793
+ }
794
+ scene.fire(msgPrefix + ":geoCode", { args: [searchStr] }, parentScene);
795
+ };
796
+ /* 逆地理编码查询 */
797
+ that.getAddressByXY = function (x, y, searchStr, radius, callback) {
798
+ if (scene == null) return;
799
+ if (callback) {
800
+ that.removeEventBind("getAddressByXYCallback");
801
+ that.bindEvent("getAddressByXYCallback", function (evt) {
802
+ callback(evt.args);
803
+ });
804
+ }
805
+ scene.fire(
806
+ msgPrefix + ":getAddressByXY",
807
+ { args: [x, y, searchStr, radius] },
808
+ parentScene
809
+ );
810
+ };
811
+ that.getGaAddressByXY = function (x, y, options, callback) {
812
+ if (scene == null) return;
813
+ if (callback) {
814
+ that.removeEventBind("getGaAddressByXYCallback");
815
+ that.bindEvent("getGaAddressByXYCallback", function (evt) {
816
+ callback(evt.args);
817
+ });
818
+ }
819
+ scene.fire(
820
+ msgPrefix + ":getGaAddressByXY",
821
+ { args: [x, y, options] },
822
+ parentScene
823
+ );
824
+ };
825
+ that.getGaStandardAddress = function (params, callback) {
826
+ if (scene == null) return;
827
+ if (callback) {
828
+ that.removeEventBind("getGaStandardAddressCallbackCallback");
829
+ that.bindEvent(
830
+ "getGaStandardAddressCallbackCallback",
831
+ function (evt) {
832
+ callback(evt.args);
833
+ }
834
+ );
835
+ }
836
+ scene.fire(
837
+ msgPrefix + ":getGaStandardAddress",
838
+ { args: [params] },
839
+ parentScene
840
+ );
841
+ };
842
+ /* 根据坐标获取单元网格 */
843
+ that.getCellNameByPosXY = function (x, y, gridType) {
844
+ if (scene == null) return;
845
+ var args = [];
846
+ var callback = null;
847
+ for (var i = 0; i < arguments.length; i++) {
848
+ var arg = arguments[i];
849
+ if (i == arguments.length - 1 && typeof arg == "function") {
850
+ callback = arg;
851
+ continue;
852
+ }
853
+ args.push(arg);
854
+ }
855
+ if (callback != null) {
856
+ // 移除监听
857
+ that.removeEventBind("getCellNameByPosXYCallback");
858
+
859
+ function _getCellNameByPosXYCallback(evt) {
860
+ that.removeEventBind("getCellNameByPosXYCallback");
861
+ callback(evt.args);
862
+ }
863
+ that.bindEvent(
864
+ "getCellNameByPosXYCallback",
865
+ _getCellNameByPosXYCallback
866
+ );
867
+ }
868
+ that.fireEvent("getCellNameByPosXY", { args: args });
869
+ };
870
+ /* 根据图层字段定位显示 */
871
+ that.locateFeatureByIDs = function (
872
+ layerID,
873
+ keyFiled,
874
+ keyValue,
875
+ clearMap,
876
+ style,
877
+ hStyle,
878
+ bZoom,
879
+ randomColor,
880
+ labelfield,
881
+ labelstyle,
882
+ geometry,
883
+ where,
884
+ renderCanvas,
885
+ singleSelected,
886
+ options,
887
+ extendProperty,
888
+ layerTag,
889
+ outFieldStr,
890
+ animiteStep,
891
+ index,
892
+ clipGeom
893
+ ) {
894
+ if (scene == null) return;
895
+ if (bZoom == undefined) bZoom = false;
896
+ scene.fire(
897
+ msgPrefix + ":locateFeatureByIDs",
898
+ {
899
+ args: [
900
+ layerID,
901
+ keyValue,
902
+ keyFiled,
903
+ clearMap,
904
+ style,
905
+ hStyle,
906
+ bZoom,
907
+ randomColor,
908
+ labelfield,
909
+ labelstyle,
910
+ geometry,
911
+ where,
912
+ renderCanvas,
913
+ singleSelected,
914
+ options,
915
+ extendProperty,
916
+ layerTag,
917
+ outFieldStr,
918
+ animiteStep,
919
+ index,
920
+ clipGeom,
921
+ ],
922
+ },
923
+ parentScene
924
+ );
925
+ };
926
+ /* 显示案件分布 */
927
+ that.showRecListDistribution = function (
928
+ infoJson,
929
+ zoom,
930
+ clickCallback,
931
+ labelInfo,
932
+ isShowLegend,
933
+ symbolUrl,
934
+ options
935
+ ) {
936
+ if (scene == null || infoJson.length == 0) return;
937
+ //如果xy坐标没有值不处理
938
+ for (var i = 0, len = infoJson.length; i < len; i++) {
939
+ if (
940
+ !infoJson[i].coordinateX ||
941
+ infoJson[i].coordinateX == "" ||
942
+ !infoJson[i].coordinateY ||
943
+ infoJson[i].coordinateY == ""
944
+ ) {
945
+ return;
946
+ }
947
+ }
948
+
949
+ // 移除监听
950
+ that.removeEventBind("showRecListDistributionCallback");
951
+
952
+ if (clickCallback != undefined) {
953
+ that.bindEvent("showRecListDistributionCallback", function (evt) {
954
+ clickCallback(evt.args);
955
+ });
956
+ }
957
+ scene.fire(
958
+ msgPrefix + ":showRecListDistribution",
959
+ {
960
+ args: [
961
+ infoJson,
962
+ zoom,
963
+ labelInfo,
964
+ isShowLegend,
965
+ symbolUrl,
966
+ clickCallback,
967
+ options,
968
+ ],
969
+ },
970
+ parentScene,
971
+ false
972
+ );
973
+
974
+ //如果启用了实景功能,同时进行实景定位
975
+ if (mmsMap && infoJson.length == 1) {
976
+ var recInfo = infoJson[0];
977
+ if (mmsMap.mmsLoaded) {
978
+ if (!mmsMap.mmsVisible) {
979
+ // var pos = {x:recInfo.coordinateX, y:recInfo.coordinateY};
980
+ // var evt = {args:[pos]};
981
+ // mmsMap.setMMSEyePosition(evt);
982
+ } else {
983
+ mmsMap.locateEvent(
984
+ recInfo.recID,
985
+ recInfo.coordinateX,
986
+ recInfo.coordinateY
987
+ );
988
+ }
989
+ }
990
+ }
991
+ };
992
+ that.highLightMultiObjectCurrentPosition = function (
993
+ objectID,
994
+ zoom,
995
+ cluster,
996
+ showPopup,
997
+ layerID
998
+ ) {
999
+ if (scene == null) return;
1000
+ scene.fire(
1001
+ msgPrefix + ":highLightMultiObjectCurrentPosition",
1002
+ { args: [objectID, zoom, cluster, showPopup, layerID] },
1003
+ parentScene,
1004
+ false
1005
+ );
1006
+ };
1007
+ /* 显示多个自定义图标 */
1008
+ that.showMultiObjectCurrentPosition = function (
1009
+ jsonInfo,
1010
+ zoom,
1011
+ bClear,
1012
+ hStyleID,
1013
+ infoStyle,
1014
+ bCanvas,
1015
+ tagName,
1016
+ clickCallback,
1017
+ mouseOverCallBack,
1018
+ clusterOption,
1019
+ hasHover,
1020
+ layerID,
1021
+ mouseOutCallback,
1022
+ options
1023
+ ) {
1024
+ if (scene == null) return;
1025
+ // 移除监听
1026
+ var clickBackName = "showMultiObjectCurrentPositionClick";
1027
+ var mouseOverBackName = "showMultiObjectCurrentPositionMouseover";
1028
+ var mouseOutBackName = "showMultiObjectCurrentPositionMouseout";
1029
+ if (options && options.callbacksuffix) {
1030
+ clickBackName += options.callbacksuffix;
1031
+ mouseOverBackName += options.callbacksuffix;
1032
+ mouseOutBackName += options.callbacksuffix;
1033
+ }
1034
+ that.removeEventBind(clickBackName);
1035
+ that.removeEventBind(mouseOverBackName);
1036
+ that.removeEventBind(mouseOutBackName);
1037
+ if (clickCallback instanceof Function) {
1038
+ that.bindEvent(clickBackName, function (evt) {
1039
+ clickCallback(evt.args);
1040
+ });
1041
+ }
1042
+ if (mouseOverCallBack instanceof Function) {
1043
+ that.bindEvent(mouseOverBackName, function (evt) {
1044
+ mouseOverCallBack(evt.args);
1045
+ });
1046
+ }
1047
+ if (mouseOutCallback instanceof Function) {
1048
+ that.bindEvent(mouseOutBackName, function (evt) {
1049
+ mouseOutCallback(evt.args);
1050
+ });
1051
+ }
1052
+ if (options && options.getgeohashCallback && options.getgeohashCallback instanceof Function) {
1053
+ that.removeEventBind("getGeoHashesCallback");
1054
+ scene.on(msgPrefix + ":getGeoHashesCallback", options.getgeohashCallback, parentScene, false);
1055
+ }
1056
+
1057
+ scene.fire(
1058
+ msgPrefix + ":showMultiObjectCurrentPosition",
1059
+ {
1060
+ args: [
1061
+ jsonInfo,
1062
+ zoom,
1063
+ bClear,
1064
+ hStyleID,
1065
+ infoStyle,
1066
+ bCanvas,
1067
+ tagName,
1068
+ clusterOption,
1069
+ hasHover,
1070
+ layerID,
1071
+ options,
1072
+ ],
1073
+ },
1074
+ parentScene,
1075
+ false
1076
+ );
1077
+ };
1078
+ /**
1079
+ * 新聚类传入数据的接口
1080
+ */
1081
+ that.showMultiObjectCurrentPositionWithData = function (jsonInfo) {
1082
+ if (scene == null) return;
1083
+ scene.fire(
1084
+ msgPrefix + ":showMultiObjectCurrentPositionWithData",
1085
+ {
1086
+ args: [jsonInfo],
1087
+ },
1088
+ parentScene,
1089
+ false
1090
+ );
1091
+ };
1092
+ /* 显示监督员 */
1093
+ that.showPatrolCurrentPosition = function (
1094
+ jsonInfo,
1095
+ zoom,
1096
+ bClear,
1097
+ hStyleID,
1098
+ clickCallback
1099
+ ) {
1100
+ if (scene == null) return;
1101
+
1102
+ var args = Array.prototype.slice.call(arguments);
1103
+ if (arguments[arguments.length - 1] instanceof Function) {
1104
+ clickCallback = arguments[arguments.length - 1];
1105
+ args = args.slice(0, args.length - 1);
1106
+ }
1107
+
1108
+ if (clickCallback) {
1109
+ that.removeEventBind("showPatrolCurrentPositionCallback");
1110
+ that.bindEvent("showPatrolCurrentPositionCallback", function (evt) {
1111
+ clickCallback(evt.args);
1112
+ });
1113
+ }
1114
+ scene.fire(
1115
+ msgPrefix + ":showPatrolCurrentPosition",
1116
+ { args: args },
1117
+ parentScene,
1118
+ false
1119
+ );
1120
+ };
1121
+ /* 获取缓冲区 */
1122
+ that.getBuffer = function (layerID, x, y, radius, getBufferCallback) {
1123
+ if (scene == null) return;
1124
+
1125
+ var args = Array.prototype.slice.call(arguments);
1126
+ if (arguments[arguments.length - 1] instanceof Function) {
1127
+ getBufferCallback = arguments[arguments.length - 1];
1128
+ args = args.slice(0, args.length - 1);
1129
+ }
1130
+
1131
+ if (getBufferCallback) {
1132
+ that.removeEventBind("getBufferCallback");
1133
+ that.bindEvent("getBufferCallback", function (evt) {
1134
+ getBufferCallback(evt.args);
1135
+ });
1136
+ }
1137
+ scene.fire(msgPrefix + ":getBuffer", { args: args }, parentScene, true);
1138
+ };
1139
+ /* 获取多点的缓冲区 */
1140
+ that.getMultiPointBuffer = function (points, radius, callback, options) {
1141
+ if (scene == null) return;
1142
+ scene.fire(
1143
+ msgPrefix + ":getMultiPointBuffer",
1144
+ { args: [points, radius, callback, options] },
1145
+ parentScene,
1146
+ true
1147
+ );
1148
+ };
1149
+ /**
1150
+ * 设置指定图层的样式
1151
+ * @param id 元素的id
1152
+ * @param tag 图层的标签
1153
+ * @param style 图层样式
1154
+ * @returns
1155
+ */
1156
+ that.setGraphicStyle = function (id, tag, style) {
1157
+ if (scene == null) return;
1158
+ scene.fire(
1159
+ msgPrefix + ":setGraphicStyle",
1160
+ { args: [id, tag, style] },
1161
+ parentScene,
1162
+ true
1163
+ );
1164
+ };
1165
+ /* 显示监督员责任网格 */
1166
+ that.showPatrolDutygridCells = function (infoJson, zoom, clickCallback) {
1167
+ if (scene == null) return;
1168
+
1169
+ var layerID = infoJson.layerID;
1170
+ var layerKeyFieldName = infoJson.keyFieldName;
1171
+ var cellID = infoJson.grids;
1172
+ var bClearMap = false;
1173
+ var gridCellStyle = {};
1174
+ gridCellStyle.style = {
1175
+ type: "esriSFS",
1176
+ style: "esriSFSSolid",
1177
+ color: [0, 0, 100, 76],
1178
+ outline: {
1179
+ type: "esriSLS",
1180
+ style: "esriSLSSolid",
1181
+ color: [255, 130, 47, 255],
1182
+ width: 2,
1183
+ },
1184
+ };
1185
+ gridCellStyle.hStyle = MapUtils.deepClones(
1186
+ true,
1187
+ {},
1188
+ gridCellStyle.style
1189
+ );
1190
+ that.locateFeatureByIDs(
1191
+ layerID,
1192
+ layerKeyFieldName,
1193
+ cellID,
1194
+ bClearMap,
1195
+ gridCellStyle.style,
1196
+ gridCellStyle.hStyle,
1197
+ zoom
1198
+ );
1199
+ };
1200
+ /* 标识位置 */
1201
+ that.markMap = function (
1202
+ projectTypeID,
1203
+ eventTypeID,
1204
+ actPropertyID,
1205
+ displayStyleID,
1206
+ layerID,
1207
+ clickCallback,
1208
+ cellIndexName,
1209
+ point,
1210
+ symbolUrl,
1211
+ bdGridCodeOpt
1212
+ ) {
1213
+ if (scene == null) return;
1214
+
1215
+ // 移除监听
1216
+ that.removeEventBind("markMapCallback");
1217
+
1218
+ //新增了layerID,因此需要兼容原来的4个参数
1219
+ if (arguments.length == 5 && typeof layerID == "function") {
1220
+ clickCallback = layerID;
1221
+ layerID == null;
1222
+ }
1223
+
1224
+ if (clickCallback != undefined) {
1225
+ that.bindEvent("markMapCallback", function (evt) {
1226
+ clickCallback(evt.args);
1227
+ });
1228
+ }
1229
+ scene.fire(
1230
+ msgPrefix + ":markMap",
1231
+ {
1232
+ args: [
1233
+ projectTypeID,
1234
+ eventTypeID,
1235
+ actPropertyID,
1236
+ displayStyleID,
1237
+ layerID,
1238
+ cellIndexName,
1239
+ point,
1240
+ symbolUrl,
1241
+ bdGridCodeOpt,
1242
+ ],
1243
+ },
1244
+ parentScene,
1245
+ false
1246
+ );
1247
+ };
1248
+ /* 案件定位 */
1249
+ that.eventLocate = that.recLocate = function (eventID, defaultMapRange) {
1250
+ if (scene == null) return;
1251
+
1252
+ if (defaultMapRange == undefined) defaultMapRange = 200;
1253
+ scene.fire(
1254
+ msgPrefix + ":eventLocate",
1255
+ { args: [eventID, defaultMapRange] },
1256
+ parentScene,
1257
+ false
1258
+ );
1259
+ };
1260
+ /* 显示特定图层 */
1261
+ that.showMapLayers = function (
1262
+ layerTag,
1263
+ showLevel,
1264
+ mode,
1265
+ styles,
1266
+ layerDefs
1267
+ ) {
1268
+ if (scene == null) return;
1269
+ scene.fire(
1270
+ msgPrefix + ":showMapLayers",
1271
+ { args: [layerTag, showLevel, mode, styles, layerDefs] },
1272
+ parentScene,
1273
+ false
1274
+ );
1275
+ };
1276
+ /**
1277
+ * 刷新地图图层
1278
+ */
1279
+ that.refreshMapLayers = function () {
1280
+ if (scene) {
1281
+ scene.fire(
1282
+ msgPrefix + ":refreshMapLayers",
1283
+ { args: [] },
1284
+ parentScene,
1285
+ false
1286
+ );
1287
+ }
1288
+ };
1289
+ /* 显示车辆人员轨迹 */
1290
+ that.showObjectTrace = function (
1291
+ objectID,
1292
+ symbolType,
1293
+ dateTime,
1294
+ queryCondition,
1295
+ hideControlPanel,
1296
+ symbolPic,
1297
+ optimizeParams,
1298
+ infoCallback,
1299
+ updatePositionCallback,
1300
+ closeCallback,
1301
+ traceDigCallback
1302
+ ) {
1303
+ if (scene == null) return;
1304
+
1305
+ if (closeCallback) {
1306
+ that.removeEventBind("TraceManagerCloseCallback");
1307
+ that.bindEvent("TraceManagerCloseCallback", function () {
1308
+ closeCallback();
1309
+ });
1310
+ }
1311
+ if (infoCallback) {
1312
+ that.removeEventBind("showObjectTraceCallback");
1313
+ that.bindEvent("showObjectTraceCallback", function (evt) {
1314
+ infoCallback(evt && evt.args);
1315
+ });
1316
+ }
1317
+ if (updatePositionCallback) {
1318
+ that.removeEventBind("updatePositionCallback");
1319
+ that.bindEvent("updatePositionCallback", function (evt) {
1320
+ updatePositionCallback(evt && evt.args);
1321
+ });
1322
+ }
1323
+ if (traceDigCallback) {
1324
+ that.removeEventBind("getPatrolTraceDigCallback");
1325
+ that.bindEvent("getPatrolTraceDigCallback", function (evt) {
1326
+ traceDigCallback(evt && evt.args);
1327
+ });
1328
+ }
1329
+ /*if (context.sysConfig['PATROL_POS_WRITE_TO_FILE']) {
1330
+ if (queryCondition) {
1331
+ queryCondition = $.extend({}, queryCondition, { 'resourcetype': 2 });
1332
+ } else {
1333
+ queryCondition = { 'resourcetype': 2 };
1334
+ }
1335
+ }*/
1336
+ scene.fire(
1337
+ msgPrefix + ":showObjectTrace",
1338
+ {
1339
+ args: [
1340
+ objectID,
1341
+ symbolType,
1342
+ dateTime,
1343
+ queryCondition,
1344
+ hideControlPanel,
1345
+ symbolPic,
1346
+ optimizeParams,
1347
+ ],
1348
+ },
1349
+ parentScene
1350
+ );
1351
+ };
1352
+
1353
+ /*跳转轨迹位置*/
1354
+ that.updatePositionByTime = function (time) {
1355
+ if (scene == null) return;
1356
+ scene.fire(
1357
+ msgPrefix + ":updatePositionByTime",
1358
+ { args: [time] },
1359
+ parentScene
1360
+ );
1361
+ };
1362
+
1363
+ /**
1364
+ *轨迹开始播放/暂停
1365
+ **/
1366
+ that.playObjectTrace = function (speed, doNotChangeState) {
1367
+ scene.fire(
1368
+ msgPrefix + ":playObjectTrace",
1369
+ { args: [speed, doNotChangeState] },
1370
+ parentScene
1371
+ );
1372
+ };
1373
+
1374
+ /**
1375
+ *轨迹停止
1376
+ **/
1377
+ that.stopObjectTrace = function () {
1378
+ scene.fire(msgPrefix + ":stopObjectTrace", { args: [] }, parentScene);
1379
+ };
1380
+
1381
+ /**
1382
+ *更新轨迹播放速度
1383
+ **/
1384
+ that.updatePlaySpeed = function (value) {
1385
+ scene.fire(
1386
+ msgPrefix + ":updatePlaySpeed",
1387
+ { args: [value] },
1388
+ parentScene
1389
+ );
1390
+ };
1391
+
1392
+ that.startRealtimeTrace = function (
1393
+ groupIDs,
1394
+ objectIDs,
1395
+ objectType,
1396
+ resourceType,
1397
+ uiOption,
1398
+ traceOption,
1399
+ jobOption,
1400
+ options
1401
+ ) {
1402
+ if (scene == null) return;
1403
+
1404
+ var groupIDStrs = "";
1405
+ if (groupIDs instanceof Array && groupIDs.length > 0) {
1406
+ for (var i = 0; i < groupIDs.length; i++) {
1407
+ if (i != groupIDs.length - 1) {
1408
+ groupIDStrs += "comp_" + groupIDs[i] + ",";
1409
+ } else {
1410
+ groupIDStrs += "comp_" + groupIDs[i];
1411
+ }
1412
+ }
1413
+ }
1414
+
1415
+ var objectIDStrs = "";
1416
+ if (
1417
+ objectIDs instanceof Array &&
1418
+ objectIDs.length > 0 &&
1419
+ groupIDs instanceof Array &&
1420
+ groupIDs.length > 0
1421
+ ) {
1422
+ for (var i = 0; i < groupIDs.length; i++) {
1423
+ for (var j = 0; j < objectIDs.length; j++) {
1424
+ if (j != objectIDs.length - 1) {
1425
+ objectIDStrs += groupIDs[i] + "_" + objectIDs[j] + ",";
1426
+ } else {
1427
+ objectIDStrs += groupIDs[i] + "_" + objectIDs[j];
1428
+ }
1429
+ }
1430
+ }
1431
+ }
1432
+ // 监听
1433
+ if (!options) options = {};
1434
+ if (typeof options.MultiTraceDataCallback === "function") {
1435
+ that.removeEventBind("MultiTraceDataCallback");
1436
+ that.bindEvent("MultiTraceDataCallback", function (evt) {
1437
+ options.MultiTraceDataCallback(evt && evt.args);
1438
+ });
1439
+ }
1440
+
1441
+ if (typeof options.mouseOverCallback === "function") {
1442
+ that.removeEventBind("MultiTraceMouseOver");
1443
+ that.bindEvent("MultiTraceMouseOver", function (evt) {
1444
+ options.mouseOverCallback(evt && evt.args);
1445
+ });
1446
+ }
1447
+ if (typeof options.mouseOutCallback === "function") {
1448
+ that.removeEventBind("MultiTraceMouseOut");
1449
+ that.bindEvent("MultiTraceMouseOut", function (evt) {
1450
+ options.mouseOutCallback(evt && evt.args);
1451
+ });
1452
+ }
1453
+ if (typeof options.clickCallback === "function") {
1454
+ that.removeEventBind("MultiTraceClick");
1455
+ that.bindEvent("MultiTraceClick", function (evt) {
1456
+ options.clickCallback(evt && evt.args);
1457
+ });
1458
+ }
1459
+ scene.fire(
1460
+ msgPrefix + ":startRealtimeTrace",
1461
+ {
1462
+ args: [
1463
+ groupIDStrs,
1464
+ objectIDStrs,
1465
+ objectType,
1466
+ resourceType,
1467
+ uiOption,
1468
+ traceOption,
1469
+ jobOption,
1470
+ ],
1471
+ },
1472
+ parentScene
1473
+ );
1474
+ };
1475
+
1476
+ that.stopRealtimeTrace = function (objectType, resourceType) {
1477
+ if (scene == null) return;
1478
+
1479
+ scene.fire(msgPrefix + ":stopRealtimeTrace", { args: [objectType, resourceType] }, parentScene);
1480
+ };
1481
+ /**
1482
+ *停止绘制要素
1483
+ **/
1484
+ that.stopDraw = function () {
1485
+ scene.fire(msgPrefix + ":stopDraw", { args: [] }, parentScene);
1486
+ };
1487
+
1488
+ /**
1489
+ *等值面生成
1490
+ **/
1491
+ that.isobands = function (
1492
+ attrarry,
1493
+ xarry,
1494
+ yarry,
1495
+ breaks,
1496
+ breakcolors,
1497
+ cellwidth,
1498
+ boundary,
1499
+ hascelllabel,
1500
+ labelcolor,
1501
+ callback,
1502
+ options
1503
+ ) {
1504
+ scene.fire(
1505
+ msgPrefix + ":isobands",
1506
+ {
1507
+ args: [
1508
+ attrarry,
1509
+ xarry,
1510
+ yarry,
1511
+ breaks,
1512
+ breakcolors,
1513
+ cellwidth,
1514
+ boundary,
1515
+ hascelllabel,
1516
+ labelcolor,
1517
+ callback,
1518
+ options,
1519
+ ],
1520
+ },
1521
+ parentScene
1522
+ );
1523
+ };
1524
+
1525
+ //by ysj,2020-06-02
1526
+ that.checkObjectTraceItem = function (type, boolean) {
1527
+ scene.fire(
1528
+ msgPrefix + ":checkObjectTraceItem",
1529
+ { args: [type, boolean] },
1530
+ parentScene
1531
+ );
1532
+ };
1533
+
1534
+ /* 显示车辆人员轨迹热力的接口*/
1535
+ that.showTraceHeatMap = function (
1536
+ objectID,
1537
+ symbolType,
1538
+ starttime,
1539
+ endtime,
1540
+ queryCondition,
1541
+ hidePanel
1542
+ ) {
1543
+ if (scene == null) return;
1544
+ scene.fire(
1545
+ msgPrefix + ":showTraceHeatMap",
1546
+ {
1547
+ args: [
1548
+ objectID,
1549
+ symbolType,
1550
+ starttime,
1551
+ endtime,
1552
+ queryCondition,
1553
+ hidePanel,
1554
+ ],
1555
+ },
1556
+ parentScene
1557
+ );
1558
+ };
1559
+
1560
+ /*添加车辆或人员轨迹*/
1561
+ that.addObjectTrace = function (
1562
+ jsonInfo,
1563
+ symbolType,
1564
+ clear,
1565
+ showControlPanel
1566
+ ) {
1567
+ if (scene == null) return;
1568
+ scene.fire(
1569
+ msgPrefix + ":addObjectTrace",
1570
+ { args: [jsonInfo, symbolType, clear, showControlPanel] },
1571
+ parentScene
1572
+ );
1573
+ };
1574
+ /* 显示第三方上报人员轨迹 */
1575
+ that.showZzTaskTrace = function (
1576
+ objectID,
1577
+ symbolType,
1578
+ dataTime,
1579
+ queryCondition
1580
+ ) {
1581
+ if (scene == null) return;
1582
+ scene.fire(
1583
+ msgPrefix + ":showObjectTrace",
1584
+ { args: [objectID, symbolType, dataTime, queryCondition] },
1585
+ parentScene
1586
+ );
1587
+ };
1588
+ /* 绘制巡更路线 */
1589
+ that.showPatrolRoute = function (
1590
+ routeList,
1591
+ type,
1592
+ bClear,
1593
+ editable,
1594
+ zoom,
1595
+ options
1596
+ ) {
1597
+ if (scene == null) return;
1598
+ if (!(routeList instanceof Array)) routeList = [routeList];
1599
+ if (bClear == undefined) bClear = false;
1600
+ if (editable == undefined) editable = false;
1601
+
1602
+ var graphics = [];
1603
+ for (var i = 0; i < routeList.length; i++) {
1604
+ var route = routeList[i];
1605
+ var line = [];
1606
+ var attributes = [];
1607
+ var graphic = {
1608
+ id: route.routeID + "",
1609
+ geometry: { paths: [line] },
1610
+ attributes: attributes,
1611
+ };
1612
+ for (var j = 0; j < route.pointList.length; j++) {
1613
+ var point = route.pointList[j];
1614
+ line.push([point.coordinateX, point.coordinateY]);
1615
+ attributes.push(point.pointID);
1616
+ }
1617
+ graphics.push(graphic);
1618
+ }
1619
+ options = options || {};
1620
+ var lineStyle = options.lineStyle || {};
1621
+ var arrowStyle = options.arrowStyle || {};
1622
+ var style = { color: [255, 0, 0, 150], width: 6 };
1623
+ if (type == "dutyGridRoute") {
1624
+ style.color = [0, 0, 255, 150];
1625
+ }
1626
+ if (type == "patrolRoute") {
1627
+ style.color = [0, 255, 0, 150];
1628
+ }
1629
+ var lineSymbol = Object.assign(style, lineStyle);
1630
+ var arrowSymbol = Object.assign({ size: 6 }, arrowStyle);
1631
+ var option = {};
1632
+ option.arrowStyle = arrowSymbol;
1633
+ option.visible =
1634
+ options.visible == null || options.visible == "undefined"
1635
+ ? true
1636
+ : options.visible;
1637
+ scene.fire(
1638
+ msgPrefix + ":showPatrolRoute",
1639
+ { args: [graphics, bClear, lineSymbol, editable, zoom, option] },
1640
+ parentScene
1641
+ );
1642
+ };
1643
+ /* 添加巡更路线 */
1644
+ that.addPatrolRoute = function (addCallback, editCallback) {
1645
+ if (scene == null) return;
1646
+
1647
+ // 移除监听
1648
+ that.removeEventBind("drawPatrolRouteNewCallback");
1649
+ that.removeEventBind("drawPatrolRouteEditCallback");
1650
+
1651
+ if (addCallback != undefined) {
1652
+ that.bindEvent("drawPatrolRouteNewCallback", function (evt) {
1653
+ addCallback(evt.args);
1654
+ });
1655
+ }
1656
+ if (editCallback != undefined) {
1657
+ that.bindEvent("drawPatrolRouteEditCallback", function (evt) {
1658
+ editCallback(evt.args);
1659
+ });
1660
+ }
1661
+ var style = { color: [255, 0, 0, 150], width: 2 };
1662
+ scene.fire(
1663
+ msgPrefix + ":drawPatrolRoute",
1664
+ { args: [style] },
1665
+ parentScene
1666
+ );
1667
+ };
1668
+ /* 删除巡更路线 */
1669
+ that.deletePatrolRoute = function (callback, withConfirm) {
1670
+ if (scene == null) return;
1671
+
1672
+ // 移除监听
1673
+ that.removeEventBind("deletePatrolRouteCallback");
1674
+
1675
+ if (callback != undefined) {
1676
+ that.bindEvent("deletePatrolRouteCallback", function (evt) {
1677
+ callback(evt.args);
1678
+ });
1679
+ }
1680
+ if (withConfirm) {
1681
+ scene.fire(
1682
+ msgPrefix + ":deletePatrolRoute",
1683
+ { args: [false] },
1684
+ parentScene
1685
+ );
1686
+ } else {
1687
+ scene.fire(
1688
+ msgPrefix + ":deletePatrolRoute",
1689
+ { args: [] },
1690
+ parentScene
1691
+ );
1692
+ }
1693
+ };
1694
+ /* 获取正在编辑的路线 */
1695
+ that.getPatrolRouteEdit = function (callback) {
1696
+ if (scene == null) return;
1697
+
1698
+ // 移除监听
1699
+ that.removeEventBind("getPatrolRouteEditCallback");
1700
+
1701
+ if (callback != undefined) {
1702
+ that.bindEvent("getPatrolRouteEditCallback", function (evt) {
1703
+ callback(evt.args);
1704
+ });
1705
+ }
1706
+ scene.fire(
1707
+ msgPrefix + ":getPatrolRouteEdit",
1708
+ { args: [] },
1709
+ parentScene
1710
+ );
1711
+ };
1712
+
1713
+ /* 添加图形 */
1714
+ var pointStyle = {};
1715
+ pointStyle.style = {
1716
+ type: "esriSMS",
1717
+ style: "esriSMSCircle",
1718
+ color: [255, 0, 0, 150],
1719
+ size: 8,
1720
+ angle: 0,
1721
+ xoffset: 0,
1722
+ yoffset: 0,
1723
+ outline: { color: [255, 0, 0, 150], width: 1 },
1724
+ };
1725
+ pointStyle.hStyle = MapUtils.deepClones(true, {}, pointStyle.style);
1726
+ var polylineStyle = {};
1727
+ polylineStyle.style = {
1728
+ type: "esriSFS",
1729
+ style: "esriSFSSolid",
1730
+ color: [255, 0, 0, 150],
1731
+ outline: {
1732
+ type: "esriSLS",
1733
+ style: "esriSLSSolid",
1734
+ color: [0, 0, 255, 150],
1735
+ width: 1,
1736
+ },
1737
+ };
1738
+ polylineStyle.hStyle = MapUtils.deepClones(true, {}, polylineStyle.style);
1739
+ var polygonStyle = {};
1740
+ polygonStyle.style = {
1741
+ type: "esriSFS",
1742
+ style: "esriSFSSolid",
1743
+ color: [255, 0, 0, 150],
1744
+ outline: {
1745
+ type: "esriSLS",
1746
+ style: "esriSLSSolid",
1747
+ color: [0, 0, 255, 150],
1748
+ width: 1,
1749
+ },
1750
+ };
1751
+ polygonStyle.hStyle = MapUtils.deepClones(true, {}, polygonStyle.style);
1752
+ var styles = {
1753
+ point: pointStyle,
1754
+ polyline: polylineStyle,
1755
+ polygon: polygonStyle,
1756
+ };
1757
+
1758
+ that.getStyles = function (type, styleType) {
1759
+ var result = MapUtils.deepClones(true, {}, styles[type]);
1760
+ if (styleType == "esriSFSDiagonalCross") {
1761
+ result.style.type = "esriPFS";
1762
+ result.style.width = 10;
1763
+ result.style.height = 10;
1764
+ result.style.url = "images/diagonalcross_red.png";
1765
+ } else if (styleType == "esriPolygonHalfYellowTransparent") {
1766
+ result.style = {
1767
+ type: "esriSFS",
1768
+ style: "esriSFSSolid",
1769
+ color: [215, 214, 111, 100],
1770
+ outline: {
1771
+ type: "esriSLS",
1772
+ style: "esriSLSSolid",
1773
+ color: [0, 0, 255, 150],
1774
+ width: 1,
1775
+ },
1776
+ };
1777
+ } else if (styleType == "esriPointHalfYellowTransparent") {
1778
+ result.style = {
1779
+ type: "esriSMS",
1780
+ style: "esriSMSCircle",
1781
+ color: [215, 214, 111, 100],
1782
+ size: 8,
1783
+ angle: 0,
1784
+ xoffset: 0,
1785
+ yoffset: 0,
1786
+ outline: { color: [255, 0, 0, 150], width: 1 },
1787
+ };
1788
+ result.hStyle = MapUtils.deepClones(true, {}, pointStyle.style);
1789
+ } else if (styleType == "esriLineHalfYellowTransparent") {
1790
+ result.style = {
1791
+ type: "esriSFS",
1792
+ style: "esriSFSSolid",
1793
+ color: [215, 214, 111, 100],
1794
+ outline: {
1795
+ type: "esriSLS",
1796
+ style: "esriSLSSolid",
1797
+ color: [0, 0, 255, 150],
1798
+ width: 1,
1799
+ },
1800
+ };
1801
+ result.hStyle = MapUtils.deepClones(true, {}, pointStyle.style);
1802
+ }
1803
+ return result;
1804
+ };
1805
+ that.addGraphic = function (params, addCallback, editCallback) {
1806
+ if (scene == null) return;
1807
+
1808
+ // 移除监听
1809
+ that.removeEventBind("drawGeometryCallback");
1810
+ that.removeEventBind("drawGeometryEditCallback");
1811
+
1812
+ if (addCallback != undefined) {
1813
+ that.bindEvent("drawGeometryCallback", function (evt) {
1814
+ addCallback(evt.args);
1815
+ });
1816
+ }
1817
+ if (editCallback != undefined) {
1818
+ that.bindEvent("drawGeometryEditCallback", function (evt) {
1819
+ editCallback(evt.args);
1820
+ });
1821
+ }
1822
+ if (params[1] == null && styles[params[0]]) {
1823
+ params[1] = styles[params[0]].style;
1824
+ }
1825
+ scene.fire(msgPrefix + ":drawGeometry", { args: params }, parentScene);
1826
+ };
1827
+
1828
+ /* 编辑图形 */
1829
+ that.editGraphic = function (params, editCallback, deleteCallback) {
1830
+ if (scene == null) return;
1831
+
1832
+ // 移除监听
1833
+ that.removeEventBind("editGeometryCallback");
1834
+ that.removeEventBind("deleteGeometryCallback");
1835
+
1836
+ if (editCallback != undefined) {
1837
+ that.bindEvent("editGeometryCallback", function (evt) {
1838
+ editCallback(evt.args);
1839
+ });
1840
+ }
1841
+ if (deleteCallback != undefined) {
1842
+ that.bindEvent("deleteGeometryCallback", function (evt) {
1843
+ deleteCallback(evt.args);
1844
+ });
1845
+ }
1846
+ if (params[3] == null) {
1847
+ params[3] = styles.polygon.style;
1848
+ }
1849
+ scene.fire(msgPrefix + ":editGeometry", { args: params }, parentScene);
1850
+ };
1851
+
1852
+ /* 圆饼图 */
1853
+ that.addCircleChart = function (name, data, color, param) {
1854
+ color = color || "#1B5771";
1855
+ param = param || { minRadius: 20, rangeRadius: 20 };
1856
+ scene.fire(
1857
+ msgPrefix + ":addCircleChart",
1858
+ { args: [name, data, color, param] },
1859
+ parentScene
1860
+ );
1861
+ };
1862
+
1863
+ /* 饼图 */
1864
+ //by ysj,2020-06-03
1865
+ that.addChart = function (
1866
+ option,
1867
+ zoom,
1868
+ clickCallback,
1869
+ id,
1870
+ minZoom,
1871
+ maxZoom
1872
+ ) {
1873
+ that.removeEventBind("chartsLayerClickCallback");
1874
+ if (clickCallback != undefined) {
1875
+ that.bindEvent("chartsLayerClickCallback", function (evt) {
1876
+ clickCallback(evt.args);
1877
+ });
1878
+ }
1879
+ scene.fire(
1880
+ msgPrefix + ":addChart",
1881
+ { args: [option, zoom, id, minZoom, maxZoom] },
1882
+ parentScene
1883
+ );
1884
+ };
1885
+
1886
+ that.drawGeometry = function (type, style, clear, callback, option) {
1887
+ type = type || "point";
1888
+ style = style || {
1889
+ type: "esriSLS",
1890
+ style: "esriSLSSolid",
1891
+ color: [255, 0, 0, 255],
1892
+ width: 2,
1893
+ };
1894
+ //移除监听
1895
+ that.removeEventBind("drawGeometryCallback");
1896
+ if (callback != undefined) {
1897
+ that.bindEvent("drawGeometryCallback", function (evt) {
1898
+ callback(evt.args);
1899
+ });
1900
+ }
1901
+
1902
+ scene.fire(
1903
+ msgPrefix + ":drawGeometry",
1904
+ { args: [type, style, clear, callback, option] },
1905
+ parentScene
1906
+ );
1907
+ };
1908
+
1909
+ /* 热力图*/
1910
+ that.addHeatMap = function (data, option) {
1911
+ scene.fire(
1912
+ msgPrefix + ":addHeatMap",
1913
+ { args: [data, option] },
1914
+ parentScene
1915
+ );
1916
+ };
1917
+
1918
+ /**
1919
+ * 淹没点分析
1920
+ */
1921
+ that.addDrownPoint = function (option) {
1922
+ scene.fire(
1923
+ msgPrefix + ":addDrownPoint",
1924
+ { args: [option] },
1925
+ parentScene
1926
+ );
1927
+ };
1928
+ that.removeDrownPoint = function (id) {
1929
+ scene.fire(
1930
+ msgPrefix + ":removeDrownPoint",
1931
+ { args: [id] },
1932
+ parentScene
1933
+ );
1934
+ };
1935
+
1936
+ /* 聚类 */
1937
+ that.addClusterLayer = function (data, id) {
1938
+ scene.fire(
1939
+ msgPrefix + ":addClusterLayer",
1940
+ { args: [data, id] },
1941
+ parentScene
1942
+ );
1943
+ };
1944
+ /* 添加热区图层 */
1945
+ that.addHotLayer = function (
1946
+ layerUsageID,
1947
+ outFields,
1948
+ visiblelevel,
1949
+ clickCallback,
1950
+ style,
1951
+ hstyle
1952
+ ) {
1953
+ var usageID = layerUsageID || 3007;
1954
+ var style = style || {
1955
+ type: "esriSFS",
1956
+ style: "esriSFSSolid",
1957
+ color: [100, 100, 100, 125],
1958
+ outline: {
1959
+ type: "esriSLS",
1960
+ style: "esriSLSSolid",
1961
+ color: [255, 0, 0, 255],
1962
+ width: 1,
1963
+ },
1964
+ };
1965
+ var hstyle = hstyle || {
1966
+ type: "esriSFS",
1967
+ style: "esriSFSSolid",
1968
+ color: [100, 100, 255, 125],
1969
+ outline: {
1970
+ type: "esriSLS",
1971
+ style: "esriSLSSolid",
1972
+ color: [255, 0, 0, 255],
1973
+ width: 1,
1974
+ },
1975
+ };
1976
+ var where = null;
1977
+ scene.fire(
1978
+ msgPrefix + ":addCustomWMSLayer",
1979
+ { args: [usageID, style, hstyle, where, outFields, visiblelevel] },
1980
+ parentScene
1981
+ );
1982
+
1983
+ if (clickCallback) {
1984
+ that.removeEventBind("CustomWMSLayerMouseClick");
1985
+ that.bindEvent("CustomWMSLayerMouseClick", function (evt) {
1986
+ clickCallback(evt.args);
1987
+ });
1988
+ }
1989
+ };
1990
+
1991
+ /* 添加等值线图 */
1992
+ that.addKrigingMap = function (datalist, options) {
1993
+ scene.fire(
1994
+ msgPrefix + ":addKrigingMap",
1995
+ { args: [datalist, options] },
1996
+ parentScene
1997
+ );
1998
+ };
1999
+
2000
+ /* 删除热区图层 */
2001
+ that.removeHotLayer = function () {
2002
+ scene.fire(
2003
+ msgPrefix + ":removeLayer",
2004
+ { args: ["CustomWMSLayer"] },
2005
+ parentScene
2006
+ );
2007
+ };
2008
+
2009
+ /* 图层查询 */
2010
+ that.queryPhylayerFeatures = function (params, callback) {
2011
+ // 移除监听
2012
+ that.removeEventBind("queryPhylayerFeaturesCallback");
2013
+
2014
+ if (callback != undefined) {
2015
+ that.bindEvent("queryPhylayerFeaturesCallback", function (evt) {
2016
+ callback(evt.args);
2017
+ });
2018
+ }
2019
+ scene.fire(
2020
+ msgPrefix + ":queryPhylayerFeatures",
2021
+ {
2022
+ args: [
2023
+ params.queryType,
2024
+ params.queryValue,
2025
+ params.phyLayerIDs,
2026
+ params.where,
2027
+ params.params,
2028
+ params.startIndex,
2029
+ params.maxFeatures,
2030
+ ],
2031
+ },
2032
+ parentScene
2033
+ );
2034
+ };
2035
+ // /* 执行查询任务 */
2036
+ // that.executeQueryTask = function(params, callback) {
2037
+ // var queryTaskContext = {};
2038
+ // queryTaskContext.callback = callback;
2039
+ // queryTaskContext.gisSuccessFn = queryTaskContext.gisErrorFn = function(data, result) {
2040
+ // this.callback(result);
2041
+ // }
2042
+ // var queryTaskService = http.getInstance("", {type : "post", async: false, "callback": callback }, queryTaskContext.gisSuccessFn, queryTaskContext.gisErrorFn, queryTaskContext);
2043
+ // queryTaskService.settings.url = context.gisServerURL + "/home/gis/event/execquerytask.htm";
2044
+ // queryTaskService.ajax(params);
2045
+ // }
2046
+ /* 显示消息框 */
2047
+ that.showInfoWindow = function (params) {
2048
+ var visible = params.visible;
2049
+ var position = {};
2050
+ position.x = params.x;
2051
+ position.y = params.y;
2052
+ var title = params.title;
2053
+ var content = params.content;
2054
+ scene.fire(
2055
+ msgPrefix + ":infoWindow",
2056
+ { args: [visible, position, title, content] },
2057
+ parentScene
2058
+ );
2059
+ };
2060
+ /* 隐藏消息框 */
2061
+ that.hideInfoWindow = function (params) {
2062
+ scene.fire(msgPrefix + ":infoWindow", { args: [false] }, parentScene);
2063
+ };
2064
+
2065
+ /* 显示扩展消息框 */
2066
+ that.showInfoWindowEx = function (params) {
2067
+ scene.fire(
2068
+ msgPrefix + ":showInfoWindow",
2069
+ {
2070
+ args: [
2071
+ params.id || 0,
2072
+ params.title,
2073
+ params.content,
2074
+ params.x,
2075
+ params.y,
2076
+ params.style,
2077
+ params.options,
2078
+ ],
2079
+ },
2080
+ parentScene
2081
+ );
2082
+ };
2083
+ /* 显示扩展消息框 */
2084
+ that.hideInfoWindowEx = function (id) {
2085
+ scene.fire(
2086
+ msgPrefix + ":hideInfoWindow",
2087
+ {
2088
+ args: [id],
2089
+ },
2090
+ parentScene
2091
+ );
2092
+ };
2093
+ /** 设置扩展消息框样式
2094
+ * option 基础样式选项,格式如:{noTitle:true,close:true,title:{},background:'#FFF'}
2095
+ * noTitle: 是否显示标题栏;
2096
+ * close: 是否显示关闭按钮;
2097
+ * title: 标题栏的css样式对象
2098
+ * background : 除标题栏外的其他部分的颜色
2099
+ * style 位置和大小的配置,格式如:{width:300,height:300,achor:'auto',offsetY:0}
2100
+ * width: 宽度
2101
+ * height:高度
2102
+ * achor:箭头方向,其中值包含 'top','left','right','bottom','auto'
2103
+ * offsetY:Y方向上的偏移
2104
+ **/
2105
+ that.setInfoWindowStyle = function (option, style, id) {
2106
+ scene.fire(
2107
+ msgPrefix + ":setInfoWindowStyle",
2108
+ {
2109
+ args: [option, style, id],
2110
+ },
2111
+ parentScene
2112
+ );
2113
+ };
2114
+
2115
+ /* 要素查询 */
2116
+ that.queryFeature = function (params, callback) {
2117
+ if (scene == null) return;
2118
+ scene.fire(
2119
+ msgPrefix + ":queryFeature",
2120
+ {
2121
+ args: [
2122
+ params.layerID,
2123
+ params.where || null,
2124
+ params.geometry || null,
2125
+ params.outFields,
2126
+ params.outGeometry,
2127
+ params.pointTolorence || 0,
2128
+ params.startIndex,
2129
+ params.maxFeatures,
2130
+ null,
2131
+ callback || null,
2132
+ params.sortBy,
2133
+ params.filterNullGeometry,
2134
+ params.options,
2135
+ params.featureIds,
2136
+ ],
2137
+ },
2138
+ parentScene
2139
+ );
2140
+ };
2141
+
2142
+ /* 显示图层
2143
+ * layerID:图层ID ,
2144
+ * serviceID:服务ID(可选),
2145
+ * showAtBottom:是否显示在最底层(true:显示到最底层,false:显示在最顶层),
2146
+ * zoomLevel:缩放级别(传入数字为缩放到对应的级别,传入true缩放到最大可视级别)
2147
+ */
2148
+ that.showVectorLayer = function (
2149
+ layerID,
2150
+ serviceID,
2151
+ showAtBottom,
2152
+ zoomLevel
2153
+ ) {
2154
+ if (scene == null) return;
2155
+ scene.fire(
2156
+ msgPrefix + ":showVectorLayer",
2157
+ { args: [layerID, serviceID, showAtBottom, zoomLevel] },
2158
+ parentScene
2159
+ );
2160
+ };
2161
+
2162
+ /* 隐藏图层 */
2163
+ that.hideVectorLayer = function (layerID, serviceID) {
2164
+ if (scene == null) return;
2165
+ scene.fire(
2166
+ msgPrefix + ":hideVectorLayer",
2167
+ { args: [layerID, serviceID] },
2168
+ parentScene
2169
+ );
2170
+ };
2171
+
2172
+ /* 获取当前地图范围 */
2173
+ that.getMapExtent = function (callback) {
2174
+ // 移除监听
2175
+ that.removeEventBind("getMapExtentCallback");
2176
+
2177
+ if (callback != undefined) {
2178
+ that.bindEvent("getMapExtentCallback", function (evt) {
2179
+ callback(evt.args);
2180
+ });
2181
+ }
2182
+ scene.fire(msgPrefix + ":getMapExtent", { args: [] }, parentScene);
2183
+ };
2184
+
2185
+ /**查询表信息*/
2186
+ that.queryObjectInfo = function (
2187
+ geoShapes,
2188
+ tableName,
2189
+ xFieldName,
2190
+ yFieldName,
2191
+ callback,
2192
+ usePage,
2193
+ currentPage,
2194
+ numPerPage,
2195
+ params,
2196
+ cacheKey
2197
+ ) {
2198
+ var queryParam = {
2199
+ tableName: tableName,
2200
+ xFieldName: xFieldName,
2201
+ yFieldName: yFieldName,
2202
+ };
2203
+ if (params)
2204
+ queryParam = MapUtils.deepClones(true, {}, queryParam, params);
2205
+
2206
+ that.removeEventBind("queryObjectInfoCallback");
2207
+ that.bindEvent("queryObjectInfoCallback", callback);
2208
+ scene.fire(
2209
+ msgPrefix + ":queryObjectInfo",
2210
+ {
2211
+ args: [
2212
+ JSON.stringify(geoShapes),
2213
+ JSON.stringify(queryParam),
2214
+ usePage,
2215
+ currentPage,
2216
+ numPerPage,
2217
+ cacheKey,
2218
+ ],
2219
+ },
2220
+ parentScene,
2221
+ false
2222
+ );
2223
+ };
2224
+
2225
+ that.enableMapSnap = function (layerID, callback) {
2226
+ if (scene == null) return;
2227
+ if (!layerID) return;
2228
+ that.removeEventBind("enableMapSnapCallback");
2229
+ that.bindEvent("enableMapSnapCallback", callback);
2230
+ scene.fire(
2231
+ msgPrefix + ":enableMapSnap",
2232
+ {
2233
+ args: [layerID],
2234
+ },
2235
+ parentScene
2236
+ );
2237
+ };
2238
+
2239
+ that.disableMapSnap = function (layerID) {
2240
+ if (scene == null) return;
2241
+ if (!layerID) return;
2242
+ scene.fire(
2243
+ msgPrefix + ":disableMapSnap",
2244
+ {
2245
+ args: [layerID],
2246
+ },
2247
+ parentScene
2248
+ );
2249
+ };
2250
+
2251
+ that.addMaskLayer = function (
2252
+ layerID,
2253
+ keyField,
2254
+ values,
2255
+ style,
2256
+ zoom,
2257
+ position
2258
+ ) {
2259
+ scene.fire(
2260
+ msgPrefix + ":addMaskLayer",
2261
+ { args: [layerID, keyField, values, style, zoom, position] },
2262
+ parentScene
2263
+ );
2264
+ };
2265
+
2266
+ /* 计算线、面长度,支持线、面格式 */
2267
+ that.getGeometryLength = function (geometry) {
2268
+ return scene.fire(
2269
+ msgPrefix + ":getGeometryLength",
2270
+ { args: [geometry] },
2271
+ parentScene
2272
+ );
2273
+ };
2274
+
2275
+ /* 计算多边形面积 */
2276
+ that.getPolygonArea = function (geometry) {
2277
+ return scene.fire(
2278
+ msgPrefix + ":getPolygonArea",
2279
+ { args: [geometry] },
2280
+ parentScene
2281
+ );
2282
+ };
2283
+
2284
+ that.intersectGeometry = function (polygon1, polygon2) {
2285
+ return scene.fire(
2286
+ msgPrefix + ":intersectGeometry",
2287
+ { args: [polygon1, polygon2] },
2288
+ parentScene
2289
+ );
2290
+ };
2291
+
2292
+ that.getCenterPoint = function (polygon) {
2293
+ return scene.fire(
2294
+ msgPrefix + ":getCenterPoint",
2295
+ { args: [polygon] },
2296
+ parentScene
2297
+ );
2298
+ };
2299
+
2300
+ /* 根据PointID定位空中全景 */
2301
+ that.mmsAirPanoLocateByID = function (pointID) {
2302
+ if (mmsMap && mmsMap.mmsLoaded) {
2303
+ scene.fire(
2304
+ msgPrefix + ":mmsAirPanoLocateCallback",
2305
+ { args: [pointID] },
2306
+ parentScene
2307
+ );
2308
+ }
2309
+ };
2310
+
2311
+ /* 空中全景历史对比回调 */
2312
+ that.mmsAirPanoCompare = function (callback) {
2313
+ if (mmsMap && mmsMap.mmsLoaded) {
2314
+ scene.fire(
2315
+ msgPrefix + ":mmsAirPanoCompareCallback",
2316
+ { args: [callback] },
2317
+ parentScene
2318
+ );
2319
+ }
2320
+ };
2321
+
2322
+ that.setMMSEyePositionTest = function (x, y) {
2323
+ var pos = { x: x, y: y };
2324
+ var evt = { args: [pos] };
2325
+ mmsMap.setMMSEyePosition(evt);
2326
+ };
2327
+
2328
+ /* 切换地图类型 */
2329
+ that.changeControlParam = function (type, param) {
2330
+ scene.fire(
2331
+ msgPrefix + ":changeControlParam",
2332
+ { args: [type, param] },
2333
+ parentScene
2334
+ );
2335
+ };
2336
+
2337
+ /* 获取图层信息 */
2338
+ that.getPhyLayerInfo = function (phyLayerID, getPhyLayerInfoCallBack) {
2339
+ that.removeEventBind("getPhyLayerInfoCallback");
2340
+ if (getPhyLayerInfoCallBack != undefined) {
2341
+ that.bindEvent("getPhyLayerInfoCallback", function (evt) {
2342
+ getPhyLayerInfoCallBack(evt.args);
2343
+ });
2344
+ }
2345
+ scene.fire(
2346
+ msgPrefix + ":getPhyLayerInfo",
2347
+ { args: [phyLayerID] },
2348
+ parentScene,
2349
+ true
2350
+ );
2351
+ };
2352
+
2353
+ /* 获取图层字段信息 */
2354
+ that.getPhyLayerField = function (phyLayerIDs, getPhyLayerFieldCallback) {
2355
+ that.removeEventBind("getPhyLayerFieldCallback");
2356
+ if (getPhyLayerFieldCallback != undefined) {
2357
+ that.bindEvent("getPhyLayerFieldCallback", function (evt) {
2358
+ getPhyLayerFieldCallback(evt.args);
2359
+ });
2360
+ }
2361
+ scene.fire(
2362
+ msgPrefix + ":getPhyLayerField",
2363
+ { args: [phyLayerIDs] },
2364
+ parentScene,
2365
+ true
2366
+ );
2367
+ };
2368
+
2369
+ /* 获取图层字段信息 */
2370
+ that.getPhyLayerField = function (phyLayerIDs, getPhyLayerFieldCallback) {
2371
+ that.removeEventBind("getPhyLayerFieldCallback");
2372
+ if (getPhyLayerFieldCallback != undefined) {
2373
+ that.bindEvent("getPhyLayerFieldCallback", function (evt) {
2374
+ getPhyLayerFieldCallback(evt.args);
2375
+ });
2376
+ }
2377
+ scene.fire(
2378
+ msgPrefix + ":getPhyLayerField",
2379
+ { args: [phyLayerIDs] },
2380
+ parentScene,
2381
+ true
2382
+ );
2383
+ };
2384
+
2385
+ /*对几何图形进行缓冲*/
2386
+ that.getGeometryBuffer = function (
2387
+ geometry,
2388
+ radius,
2389
+ callback,
2390
+ autoTransRadius
2391
+ ) {
2392
+ that.removeEventBind("getGeometryBufferCallback");
2393
+ if (callback != undefined) {
2394
+ that.bindEvent("getGeometryBufferCallback", function (evt) {
2395
+ callback(evt.args);
2396
+ });
2397
+ }
2398
+ scene.fire(
2399
+ msgPrefix + ":getGeometryBuffer",
2400
+ { args: [geometry, radius, autoTransRadius] },
2401
+ parentScene,
2402
+ true
2403
+ );
2404
+ };
2405
+
2406
+ /* 移除图层*/
2407
+ that.removeLayer = function (layerName) {
2408
+ scene.fire(
2409
+ msgPrefix + ":removeLayer",
2410
+ { args: [layerName] },
2411
+ parentScene,
2412
+ true
2413
+ );
2414
+ };
2415
+
2416
+ that.change3dlayerUsageConfig = function () {
2417
+ if (scene == null) return;
2418
+ var config = scene.layerUsageConfig;
2419
+ scene.fire(
2420
+ msgPrefix + ":change3dlayerUsageConfig",
2421
+ { args: [config] },
2422
+ parentScene
2423
+ );
2424
+ };
2425
+ /*显示多轨迹*/
2426
+ that.showTraceMultiHisLayer = function (
2427
+ objectIDs,
2428
+ symbolType,
2429
+ beginDate,
2430
+ endDate,
2431
+ clear,
2432
+ zoom,
2433
+ hStyle
2434
+ ) {
2435
+ scene.fire(
2436
+ msgPrefix + ":showTraceMultiHisLayer",
2437
+ {
2438
+ args: [
2439
+ objectIDs,
2440
+ symbolType,
2441
+ beginDate,
2442
+ endDate,
2443
+ clear,
2444
+ zoom,
2445
+ hStyle,
2446
+ ],
2447
+ },
2448
+ parentScene
2449
+ );
2450
+ };
2451
+ /*清除多轨迹*/
2452
+ that.claerTraceMultiHisLayer = function () {
2453
+ scene.fire(
2454
+ msgPrefix + ":claerTraceMultiHisLayer",
2455
+ { args: [] },
2456
+ parentScene
2457
+ );
2458
+ };
2459
+ /*多人员图标通过id高亮*/
2460
+ that.multiPointsSelectbyID = function (id) {
2461
+ scene.fire(
2462
+ msgPrefix + ":multiPointsSelectbyID",
2463
+ { args: [id] },
2464
+ parentScene
2465
+ );
2466
+ };
2467
+ /*多轨迹通过id高亮*/
2468
+ that.traceMultiSelectbyID = function (id) {
2469
+ scene.fire(
2470
+ msgPrefix + ":traceMultiSelectbyID",
2471
+ { args: [id] },
2472
+ parentScene
2473
+ );
2474
+ };
2475
+
2476
+ // arcgis格式geometry转wkt格式
2477
+ that.agsToWKT = function (geometry, callback) {
2478
+ scene.fire(
2479
+ msgPrefix + ":agsToWKT",
2480
+ { args: [geometry, callback] },
2481
+ parentScene
2482
+ );
2483
+ };
2484
+ /*网格化方式绘制管线*/
2485
+ that.showCustomGrid = function (jsonInfo, region) {
2486
+ scene.fire(
2487
+ msgPrefix + ":showCustomGrid",
2488
+ { args: [jsonInfo, region] },
2489
+ parentScene
2490
+ );
2491
+ };
2492
+
2493
+ /*网格化方式清除管线*/
2494
+ that.clearCustomGrid = function () {
2495
+ scene.fire(msgPrefix + ":clearCustomGrid", { args: [] }, parentScene);
2496
+ };
2497
+
2498
+ /**
2499
+ * 开始测量
2500
+ * @param {*} options {type:'area'|'length'; callBack:绘制完成回调函数;errorCallBack:错误回调函数;}
2501
+ */
2502
+ that.startMeasure = function (options) {
2503
+ if (scene == null) return;
2504
+ scene.fire(
2505
+ msgPrefix + ":startMeasure",
2506
+ { args: [options] },
2507
+ parentScene,
2508
+ false
2509
+ );
2510
+ };
2511
+
2512
+ // 结束测量
2513
+ that.stopMeasure = function () {
2514
+ if (scene == null) return;
2515
+ scene.fire(
2516
+ msgPrefix + ":stopMeasure",
2517
+ { args: [] },
2518
+ parentScene,
2519
+ false
2520
+ );
2521
+ };
2522
+
2523
+ that.mouseMoveEvent = function (callback) {
2524
+ if (scene == null) return;
2525
+ scene.fire(
2526
+ msgPrefix + ":mouseMoveEvent",
2527
+ { args: [callback] },
2528
+ parentScene,
2529
+ false
2530
+ );
2531
+ };
2532
+
2533
+ that.init();
2534
+ };
2535
+ export default EGovaGISMap;