egovamap 0.35.12 → 0.35.13

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,2516 +1,2516 @@
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
- scene.fire(
1053
- msgPrefix + ":showMultiObjectCurrentPosition",
1054
- {
1055
- args: [
1056
- jsonInfo,
1057
- zoom,
1058
- bClear,
1059
- hStyleID,
1060
- infoStyle,
1061
- bCanvas,
1062
- tagName,
1063
- clusterOption,
1064
- hasHover,
1065
- layerID,
1066
- options,
1067
- ],
1068
- },
1069
- parentScene,
1070
- false
1071
- );
1072
- };
1073
- /* 显示监督员 */
1074
- that.showPatrolCurrentPosition = function (
1075
- jsonInfo,
1076
- zoom,
1077
- bClear,
1078
- hStyleID,
1079
- clickCallback
1080
- ) {
1081
- if (scene == null) return;
1082
-
1083
- var args = Array.prototype.slice.call(arguments);
1084
- if (arguments[arguments.length - 1] instanceof Function) {
1085
- clickCallback = arguments[arguments.length - 1];
1086
- args = args.slice(0, args.length - 1);
1087
- }
1088
-
1089
- if (clickCallback) {
1090
- that.removeEventBind("showPatrolCurrentPositionCallback");
1091
- that.bindEvent("showPatrolCurrentPositionCallback", function (evt) {
1092
- clickCallback(evt.args);
1093
- });
1094
- }
1095
- scene.fire(
1096
- msgPrefix + ":showPatrolCurrentPosition",
1097
- { args: args },
1098
- parentScene,
1099
- false
1100
- );
1101
- };
1102
- /* 获取缓冲区 */
1103
- that.getBuffer = function (layerID, x, y, radius, getBufferCallback) {
1104
- if (scene == null) return;
1105
-
1106
- var args = Array.prototype.slice.call(arguments);
1107
- if (arguments[arguments.length - 1] instanceof Function) {
1108
- getBufferCallback = arguments[arguments.length - 1];
1109
- args = args.slice(0, args.length - 1);
1110
- }
1111
-
1112
- if (getBufferCallback) {
1113
- that.removeEventBind("getBufferCallback");
1114
- that.bindEvent("getBufferCallback", function (evt) {
1115
- getBufferCallback(evt.args);
1116
- });
1117
- }
1118
- scene.fire(msgPrefix + ":getBuffer", { args: args }, parentScene, true);
1119
- };
1120
- /* 获取多点的缓冲区 */
1121
- that.getMultiPointBuffer = function (points, radius, callback, options) {
1122
- if (scene == null) return;
1123
- scene.fire(
1124
- msgPrefix + ":getMultiPointBuffer",
1125
- { args: [points, radius, callback, options] },
1126
- parentScene,
1127
- true
1128
- );
1129
- };
1130
- /**
1131
- * 设置指定图层的样式
1132
- * @param id 元素的id
1133
- * @param tag 图层的标签
1134
- * @param style 图层样式
1135
- * @returns
1136
- */
1137
- that.setGraphicStyle = function (id, tag, style) {
1138
- if (scene == null) return;
1139
- scene.fire(
1140
- msgPrefix + ":setGraphicStyle",
1141
- { args: [id, tag, style] },
1142
- parentScene,
1143
- true
1144
- );
1145
- };
1146
- /* 显示监督员责任网格 */
1147
- that.showPatrolDutygridCells = function (infoJson, zoom, clickCallback) {
1148
- if (scene == null) return;
1149
-
1150
- var layerID = infoJson.layerID;
1151
- var layerKeyFieldName = infoJson.keyFieldName;
1152
- var cellID = infoJson.grids;
1153
- var bClearMap = false;
1154
- var gridCellStyle = {};
1155
- gridCellStyle.style = {
1156
- type: "esriSFS",
1157
- style: "esriSFSSolid",
1158
- color: [0, 0, 100, 76],
1159
- outline: {
1160
- type: "esriSLS",
1161
- style: "esriSLSSolid",
1162
- color: [255, 130, 47, 255],
1163
- width: 2,
1164
- },
1165
- };
1166
- gridCellStyle.hStyle = MapUtils.deepClones(
1167
- true,
1168
- {},
1169
- gridCellStyle.style
1170
- );
1171
- that.locateFeatureByIDs(
1172
- layerID,
1173
- layerKeyFieldName,
1174
- cellID,
1175
- bClearMap,
1176
- gridCellStyle.style,
1177
- gridCellStyle.hStyle,
1178
- zoom
1179
- );
1180
- };
1181
- /* 标识位置 */
1182
- that.markMap = function (
1183
- projectTypeID,
1184
- eventTypeID,
1185
- actPropertyID,
1186
- displayStyleID,
1187
- layerID,
1188
- clickCallback,
1189
- cellIndexName,
1190
- point,
1191
- symbolUrl,
1192
- bdGridCodeOpt
1193
- ) {
1194
- if (scene == null) return;
1195
-
1196
- // 移除监听
1197
- that.removeEventBind("markMapCallback");
1198
-
1199
- //新增了layerID,因此需要兼容原来的4个参数
1200
- if (arguments.length == 5 && typeof layerID == "function") {
1201
- clickCallback = layerID;
1202
- layerID == null;
1203
- }
1204
-
1205
- if (clickCallback != undefined) {
1206
- that.bindEvent("markMapCallback", function (evt) {
1207
- clickCallback(evt.args);
1208
- });
1209
- }
1210
- scene.fire(
1211
- msgPrefix + ":markMap",
1212
- {
1213
- args: [
1214
- projectTypeID,
1215
- eventTypeID,
1216
- actPropertyID,
1217
- displayStyleID,
1218
- layerID,
1219
- cellIndexName,
1220
- point,
1221
- symbolUrl,
1222
- bdGridCodeOpt,
1223
- ],
1224
- },
1225
- parentScene,
1226
- false
1227
- );
1228
- };
1229
- /* 案件定位 */
1230
- that.eventLocate = that.recLocate = function (eventID, defaultMapRange) {
1231
- if (scene == null) return;
1232
-
1233
- if (defaultMapRange == undefined) defaultMapRange = 200;
1234
- scene.fire(
1235
- msgPrefix + ":eventLocate",
1236
- { args: [eventID, defaultMapRange] },
1237
- parentScene,
1238
- false
1239
- );
1240
- };
1241
- /* 显示特定图层 */
1242
- that.showMapLayers = function (
1243
- layerTag,
1244
- showLevel,
1245
- mode,
1246
- styles,
1247
- layerDefs
1248
- ) {
1249
- if (scene == null) return;
1250
- scene.fire(
1251
- msgPrefix + ":showMapLayers",
1252
- { args: [layerTag, showLevel, mode, styles, layerDefs] },
1253
- parentScene,
1254
- false
1255
- );
1256
- };
1257
- /**
1258
- * 刷新地图图层
1259
- */
1260
- that.refreshMapLayers = function () {
1261
- if (scene) {
1262
- scene.fire(
1263
- msgPrefix + ":refreshMapLayers",
1264
- { args: [] },
1265
- parentScene,
1266
- false
1267
- );
1268
- }
1269
- };
1270
- /* 显示车辆人员轨迹 */
1271
- that.showObjectTrace = function (
1272
- objectID,
1273
- symbolType,
1274
- dateTime,
1275
- queryCondition,
1276
- hideControlPanel,
1277
- symbolPic,
1278
- optimizeParams,
1279
- infoCallback,
1280
- updatePositionCallback,
1281
- closeCallback,
1282
- traceDigCallback
1283
- ) {
1284
- if (scene == null) return;
1285
-
1286
- if (closeCallback) {
1287
- that.removeEventBind("TraceManagerCloseCallback");
1288
- that.bindEvent("TraceManagerCloseCallback", function () {
1289
- closeCallback();
1290
- });
1291
- }
1292
- if (infoCallback) {
1293
- that.removeEventBind("showObjectTraceCallback");
1294
- that.bindEvent("showObjectTraceCallback", function (evt) {
1295
- infoCallback(evt && evt.args);
1296
- });
1297
- }
1298
- if (updatePositionCallback) {
1299
- that.removeEventBind("updatePositionCallback");
1300
- that.bindEvent("updatePositionCallback", function (evt) {
1301
- updatePositionCallback(evt && evt.args);
1302
- });
1303
- }
1304
- if (traceDigCallback) {
1305
- that.removeEventBind("getPatrolTraceDigCallback");
1306
- that.bindEvent("getPatrolTraceDigCallback", function (evt) {
1307
- traceDigCallback(evt && evt.args);
1308
- });
1309
- }
1310
- /*if (context.sysConfig['PATROL_POS_WRITE_TO_FILE']) {
1311
- if (queryCondition) {
1312
- queryCondition = $.extend({}, queryCondition, { 'resourcetype': 2 });
1313
- } else {
1314
- queryCondition = { 'resourcetype': 2 };
1315
- }
1316
- }*/
1317
- scene.fire(
1318
- msgPrefix + ":showObjectTrace",
1319
- {
1320
- args: [
1321
- objectID,
1322
- symbolType,
1323
- dateTime,
1324
- queryCondition,
1325
- hideControlPanel,
1326
- symbolPic,
1327
- optimizeParams,
1328
- ],
1329
- },
1330
- parentScene
1331
- );
1332
- };
1333
-
1334
- /*跳转轨迹位置*/
1335
- that.updatePositionByTime = function (time) {
1336
- if (scene == null) return;
1337
- scene.fire(
1338
- msgPrefix + ":updatePositionByTime",
1339
- { args: [time] },
1340
- parentScene
1341
- );
1342
- };
1343
-
1344
- /**
1345
- *轨迹开始播放/暂停
1346
- **/
1347
- that.playObjectTrace = function (speed, doNotChangeState) {
1348
- scene.fire(
1349
- msgPrefix + ":playObjectTrace",
1350
- { args: [speed, doNotChangeState] },
1351
- parentScene
1352
- );
1353
- };
1354
-
1355
- /**
1356
- *轨迹停止
1357
- **/
1358
- that.stopObjectTrace = function () {
1359
- scene.fire(msgPrefix + ":stopObjectTrace", { args: [] }, parentScene);
1360
- };
1361
-
1362
- /**
1363
- *更新轨迹播放速度
1364
- **/
1365
- that.updatePlaySpeed = function (value) {
1366
- scene.fire(
1367
- msgPrefix + ":updatePlaySpeed",
1368
- { args: [value] },
1369
- parentScene
1370
- );
1371
- };
1372
-
1373
- that.startRealtimeTrace = function (
1374
- groupIDs,
1375
- objectIDs,
1376
- objectType,
1377
- resourceType,
1378
- uiOption,
1379
- traceOption,
1380
- jobOption,
1381
- options
1382
- ) {
1383
- if (scene == null) return;
1384
-
1385
- var groupIDStrs = "";
1386
- if (groupIDs instanceof Array && groupIDs.length > 0) {
1387
- for (var i = 0; i < groupIDs.length; i++) {
1388
- if (i != groupIDs.length - 1) {
1389
- groupIDStrs += "comp_" + groupIDs[i] + ",";
1390
- } else {
1391
- groupIDStrs += "comp_" + groupIDs[i];
1392
- }
1393
- }
1394
- }
1395
-
1396
- var objectIDStrs = "";
1397
- if (
1398
- objectIDs instanceof Array &&
1399
- objectIDs.length > 0 &&
1400
- groupIDs instanceof Array &&
1401
- groupIDs.length > 0
1402
- ) {
1403
- for (var i = 0; i < groupIDs.length; i++) {
1404
- for (var j = 0; j < objectIDs.length; j++) {
1405
- if (j != objectIDs.length - 1) {
1406
- objectIDStrs += groupIDs[i] + "_" + objectIDs[j] + ",";
1407
- } else {
1408
- objectIDStrs += groupIDs[i] + "_" + objectIDs[j];
1409
- }
1410
- }
1411
- }
1412
- }
1413
- // 监听
1414
- if (!options) options = {};
1415
- if (typeof options.MultiTraceDataCallback === "function") {
1416
- that.removeEventBind("MultiTraceDataCallback");
1417
- that.bindEvent("MultiTraceDataCallback", function (evt) {
1418
- options.MultiTraceDataCallback(evt && evt.args);
1419
- });
1420
- }
1421
-
1422
- if (typeof options.mouseOverCallback === "function") {
1423
- that.removeEventBind("MultiTraceMouseOver");
1424
- that.bindEvent("MultiTraceMouseOver", function (evt) {
1425
- options.mouseOverCallback(evt && evt.args);
1426
- });
1427
- }
1428
- if (typeof options.mouseOutCallback === "function") {
1429
- that.removeEventBind("MultiTraceMouseOut");
1430
- that.bindEvent("MultiTraceMouseOut", function (evt) {
1431
- options.mouseOutCallback(evt && evt.args);
1432
- });
1433
- }
1434
- if (typeof options.clickCallback === "function") {
1435
- that.removeEventBind("MultiTraceClick");
1436
- that.bindEvent("MultiTraceClick", function (evt) {
1437
- options.clickCallback(evt && evt.args);
1438
- });
1439
- }
1440
- scene.fire(
1441
- msgPrefix + ":startRealtimeTrace",
1442
- {
1443
- args: [
1444
- groupIDStrs,
1445
- objectIDStrs,
1446
- objectType,
1447
- resourceType,
1448
- uiOption,
1449
- traceOption,
1450
- jobOption,
1451
- ],
1452
- },
1453
- parentScene
1454
- );
1455
- };
1456
-
1457
- that.stopRealtimeTrace = function (objectType, resourceType) {
1458
- if (scene == null) return;
1459
-
1460
- scene.fire(msgPrefix + ":stopRealtimeTrace", { args: [objectType, resourceType] }, parentScene);
1461
- };
1462
- /**
1463
- *停止绘制要素
1464
- **/
1465
- that.stopDraw = function () {
1466
- scene.fire(msgPrefix + ":stopDraw", { args: [] }, parentScene);
1467
- };
1468
-
1469
- /**
1470
- *等值面生成
1471
- **/
1472
- that.isobands = function (
1473
- attrarry,
1474
- xarry,
1475
- yarry,
1476
- breaks,
1477
- breakcolors,
1478
- cellwidth,
1479
- boundary,
1480
- hascelllabel,
1481
- labelcolor,
1482
- callback,
1483
- options
1484
- ) {
1485
- scene.fire(
1486
- msgPrefix + ":isobands",
1487
- {
1488
- args: [
1489
- attrarry,
1490
- xarry,
1491
- yarry,
1492
- breaks,
1493
- breakcolors,
1494
- cellwidth,
1495
- boundary,
1496
- hascelllabel,
1497
- labelcolor,
1498
- callback,
1499
- options,
1500
- ],
1501
- },
1502
- parentScene
1503
- );
1504
- };
1505
-
1506
- //by ysj,2020-06-02
1507
- that.checkObjectTraceItem = function (type, boolean) {
1508
- scene.fire(
1509
- msgPrefix + ":checkObjectTraceItem",
1510
- { args: [type, boolean] },
1511
- parentScene
1512
- );
1513
- };
1514
-
1515
- /* 显示车辆人员轨迹热力的接口*/
1516
- that.showTraceHeatMap = function (
1517
- objectID,
1518
- symbolType,
1519
- starttime,
1520
- endtime,
1521
- queryCondition,
1522
- hidePanel
1523
- ) {
1524
- if (scene == null) return;
1525
- scene.fire(
1526
- msgPrefix + ":showTraceHeatMap",
1527
- {
1528
- args: [
1529
- objectID,
1530
- symbolType,
1531
- starttime,
1532
- endtime,
1533
- queryCondition,
1534
- hidePanel,
1535
- ],
1536
- },
1537
- parentScene
1538
- );
1539
- };
1540
-
1541
- /*添加车辆或人员轨迹*/
1542
- that.addObjectTrace = function (
1543
- jsonInfo,
1544
- symbolType,
1545
- clear,
1546
- showControlPanel
1547
- ) {
1548
- if (scene == null) return;
1549
- scene.fire(
1550
- msgPrefix + ":addObjectTrace",
1551
- { args: [jsonInfo, symbolType, clear, showControlPanel] },
1552
- parentScene
1553
- );
1554
- };
1555
- /* 显示第三方上报人员轨迹 */
1556
- that.showZzTaskTrace = function (
1557
- objectID,
1558
- symbolType,
1559
- dataTime,
1560
- queryCondition
1561
- ) {
1562
- if (scene == null) return;
1563
- scene.fire(
1564
- msgPrefix + ":showObjectTrace",
1565
- { args: [objectID, symbolType, dataTime, queryCondition] },
1566
- parentScene
1567
- );
1568
- };
1569
- /* 绘制巡更路线 */
1570
- that.showPatrolRoute = function (
1571
- routeList,
1572
- type,
1573
- bClear,
1574
- editable,
1575
- zoom,
1576
- options
1577
- ) {
1578
- if (scene == null) return;
1579
- if (!(routeList instanceof Array)) routeList = [routeList];
1580
- if (bClear == undefined) bClear = false;
1581
- if (editable == undefined) editable = false;
1582
-
1583
- var graphics = [];
1584
- for (var i = 0; i < routeList.length; i++) {
1585
- var route = routeList[i];
1586
- var line = [];
1587
- var attributes = [];
1588
- var graphic = {
1589
- id: route.routeID + "",
1590
- geometry: { paths: [line] },
1591
- attributes: attributes,
1592
- };
1593
- for (var j = 0; j < route.pointList.length; j++) {
1594
- var point = route.pointList[j];
1595
- line.push([point.coordinateX, point.coordinateY]);
1596
- attributes.push(point.pointID);
1597
- }
1598
- graphics.push(graphic);
1599
- }
1600
- options = options || {};
1601
- var lineStyle = options.lineStyle || {};
1602
- var arrowStyle = options.arrowStyle || {};
1603
- var style = { color: [255, 0, 0, 150], width: 6 };
1604
- if (type == "dutyGridRoute") {
1605
- style.color = [0, 0, 255, 150];
1606
- }
1607
- if (type == "patrolRoute") {
1608
- style.color = [0, 255, 0, 150];
1609
- }
1610
- var lineSymbol = Object.assign(style, lineStyle);
1611
- var arrowSymbol = Object.assign({ size: 6 }, arrowStyle);
1612
- var option = {};
1613
- option.arrowStyle = arrowSymbol;
1614
- option.visible =
1615
- options.visible == null || options.visible == "undefined"
1616
- ? true
1617
- : options.visible;
1618
- scene.fire(
1619
- msgPrefix + ":showPatrolRoute",
1620
- { args: [graphics, bClear, lineSymbol, editable, zoom, option] },
1621
- parentScene
1622
- );
1623
- };
1624
- /* 添加巡更路线 */
1625
- that.addPatrolRoute = function (addCallback, editCallback) {
1626
- if (scene == null) return;
1627
-
1628
- // 移除监听
1629
- that.removeEventBind("drawPatrolRouteNewCallback");
1630
- that.removeEventBind("drawPatrolRouteEditCallback");
1631
-
1632
- if (addCallback != undefined) {
1633
- that.bindEvent("drawPatrolRouteNewCallback", function (evt) {
1634
- addCallback(evt.args);
1635
- });
1636
- }
1637
- if (editCallback != undefined) {
1638
- that.bindEvent("drawPatrolRouteEditCallback", function (evt) {
1639
- editCallback(evt.args);
1640
- });
1641
- }
1642
- var style = { color: [255, 0, 0, 150], width: 2 };
1643
- scene.fire(
1644
- msgPrefix + ":drawPatrolRoute",
1645
- { args: [style] },
1646
- parentScene
1647
- );
1648
- };
1649
- /* 删除巡更路线 */
1650
- that.deletePatrolRoute = function (callback, withConfirm) {
1651
- if (scene == null) return;
1652
-
1653
- // 移除监听
1654
- that.removeEventBind("deletePatrolRouteCallback");
1655
-
1656
- if (callback != undefined) {
1657
- that.bindEvent("deletePatrolRouteCallback", function (evt) {
1658
- callback(evt.args);
1659
- });
1660
- }
1661
- if (withConfirm) {
1662
- scene.fire(
1663
- msgPrefix + ":deletePatrolRoute",
1664
- { args: [false] },
1665
- parentScene
1666
- );
1667
- } else {
1668
- scene.fire(
1669
- msgPrefix + ":deletePatrolRoute",
1670
- { args: [] },
1671
- parentScene
1672
- );
1673
- }
1674
- };
1675
- /* 获取正在编辑的路线 */
1676
- that.getPatrolRouteEdit = function (callback) {
1677
- if (scene == null) return;
1678
-
1679
- // 移除监听
1680
- that.removeEventBind("getPatrolRouteEditCallback");
1681
-
1682
- if (callback != undefined) {
1683
- that.bindEvent("getPatrolRouteEditCallback", function (evt) {
1684
- callback(evt.args);
1685
- });
1686
- }
1687
- scene.fire(
1688
- msgPrefix + ":getPatrolRouteEdit",
1689
- { args: [] },
1690
- parentScene
1691
- );
1692
- };
1693
-
1694
- /* 添加图形 */
1695
- var pointStyle = {};
1696
- pointStyle.style = {
1697
- type: "esriSMS",
1698
- style: "esriSMSCircle",
1699
- color: [255, 0, 0, 150],
1700
- size: 8,
1701
- angle: 0,
1702
- xoffset: 0,
1703
- yoffset: 0,
1704
- outline: { color: [255, 0, 0, 150], width: 1 },
1705
- };
1706
- pointStyle.hStyle = MapUtils.deepClones(true, {}, pointStyle.style);
1707
- var polylineStyle = {};
1708
- polylineStyle.style = {
1709
- type: "esriSFS",
1710
- style: "esriSFSSolid",
1711
- color: [255, 0, 0, 150],
1712
- outline: {
1713
- type: "esriSLS",
1714
- style: "esriSLSSolid",
1715
- color: [0, 0, 255, 150],
1716
- width: 1,
1717
- },
1718
- };
1719
- polylineStyle.hStyle = MapUtils.deepClones(true, {}, polylineStyle.style);
1720
- var polygonStyle = {};
1721
- polygonStyle.style = {
1722
- type: "esriSFS",
1723
- style: "esriSFSSolid",
1724
- color: [255, 0, 0, 150],
1725
- outline: {
1726
- type: "esriSLS",
1727
- style: "esriSLSSolid",
1728
- color: [0, 0, 255, 150],
1729
- width: 1,
1730
- },
1731
- };
1732
- polygonStyle.hStyle = MapUtils.deepClones(true, {}, polygonStyle.style);
1733
- var styles = {
1734
- point: pointStyle,
1735
- polyline: polylineStyle,
1736
- polygon: polygonStyle,
1737
- };
1738
-
1739
- that.getStyles = function (type, styleType) {
1740
- var result = MapUtils.deepClones(true, {}, styles[type]);
1741
- if (styleType == "esriSFSDiagonalCross") {
1742
- result.style.type = "esriPFS";
1743
- result.style.width = 10;
1744
- result.style.height = 10;
1745
- result.style.url = "images/diagonalcross_red.png";
1746
- } else if (styleType == "esriPolygonHalfYellowTransparent") {
1747
- result.style = {
1748
- type: "esriSFS",
1749
- style: "esriSFSSolid",
1750
- color: [215, 214, 111, 100],
1751
- outline: {
1752
- type: "esriSLS",
1753
- style: "esriSLSSolid",
1754
- color: [0, 0, 255, 150],
1755
- width: 1,
1756
- },
1757
- };
1758
- } else if (styleType == "esriPointHalfYellowTransparent") {
1759
- result.style = {
1760
- type: "esriSMS",
1761
- style: "esriSMSCircle",
1762
- color: [215, 214, 111, 100],
1763
- size: 8,
1764
- angle: 0,
1765
- xoffset: 0,
1766
- yoffset: 0,
1767
- outline: { color: [255, 0, 0, 150], width: 1 },
1768
- };
1769
- result.hStyle = MapUtils.deepClones(true, {}, pointStyle.style);
1770
- } else if (styleType == "esriLineHalfYellowTransparent") {
1771
- result.style = {
1772
- type: "esriSFS",
1773
- style: "esriSFSSolid",
1774
- color: [215, 214, 111, 100],
1775
- outline: {
1776
- type: "esriSLS",
1777
- style: "esriSLSSolid",
1778
- color: [0, 0, 255, 150],
1779
- width: 1,
1780
- },
1781
- };
1782
- result.hStyle = MapUtils.deepClones(true, {}, pointStyle.style);
1783
- }
1784
- return result;
1785
- };
1786
- that.addGraphic = function (params, addCallback, editCallback) {
1787
- if (scene == null) return;
1788
-
1789
- // 移除监听
1790
- that.removeEventBind("drawGeometryCallback");
1791
- that.removeEventBind("drawGeometryEditCallback");
1792
-
1793
- if (addCallback != undefined) {
1794
- that.bindEvent("drawGeometryCallback", function (evt) {
1795
- addCallback(evt.args);
1796
- });
1797
- }
1798
- if (editCallback != undefined) {
1799
- that.bindEvent("drawGeometryEditCallback", function (evt) {
1800
- editCallback(evt.args);
1801
- });
1802
- }
1803
- if (params[1] == null && styles[params[0]]) {
1804
- params[1] = styles[params[0]].style;
1805
- }
1806
- scene.fire(msgPrefix + ":drawGeometry", { args: params }, parentScene);
1807
- };
1808
-
1809
- /* 编辑图形 */
1810
- that.editGraphic = function (params, editCallback, deleteCallback) {
1811
- if (scene == null) return;
1812
-
1813
- // 移除监听
1814
- that.removeEventBind("editGeometryCallback");
1815
- that.removeEventBind("deleteGeometryCallback");
1816
-
1817
- if (editCallback != undefined) {
1818
- that.bindEvent("editGeometryCallback", function (evt) {
1819
- editCallback(evt.args);
1820
- });
1821
- }
1822
- if (deleteCallback != undefined) {
1823
- that.bindEvent("deleteGeometryCallback", function (evt) {
1824
- deleteCallback(evt.args);
1825
- });
1826
- }
1827
- if (params[3] == null) {
1828
- params[3] = styles.polygon.style;
1829
- }
1830
- scene.fire(msgPrefix + ":editGeometry", { args: params }, parentScene);
1831
- };
1832
-
1833
- /* 圆饼图 */
1834
- that.addCircleChart = function (name, data, color, param) {
1835
- color = color || "#1B5771";
1836
- param = param || { minRadius: 20, rangeRadius: 20 };
1837
- scene.fire(
1838
- msgPrefix + ":addCircleChart",
1839
- { args: [name, data, color, param] },
1840
- parentScene
1841
- );
1842
- };
1843
-
1844
- /* 饼图 */
1845
- //by ysj,2020-06-03
1846
- that.addChart = function (
1847
- option,
1848
- zoom,
1849
- clickCallback,
1850
- id,
1851
- minZoom,
1852
- maxZoom
1853
- ) {
1854
- that.removeEventBind("chartsLayerClickCallback");
1855
- if (clickCallback != undefined) {
1856
- that.bindEvent("chartsLayerClickCallback", function (evt) {
1857
- clickCallback(evt.args);
1858
- });
1859
- }
1860
- scene.fire(
1861
- msgPrefix + ":addChart",
1862
- { args: [option, zoom, id, minZoom, maxZoom] },
1863
- parentScene
1864
- );
1865
- };
1866
-
1867
- that.drawGeometry = function (type, style, clear, callback, option) {
1868
- type = type || "point";
1869
- style = style || {
1870
- type: "esriSLS",
1871
- style: "esriSLSSolid",
1872
- color: [255, 0, 0, 255],
1873
- width: 2,
1874
- };
1875
- //移除监听
1876
- that.removeEventBind("drawGeometryCallback");
1877
- if (callback != undefined) {
1878
- that.bindEvent("drawGeometryCallback", function (evt) {
1879
- callback(evt.args);
1880
- });
1881
- }
1882
-
1883
- scene.fire(
1884
- msgPrefix + ":drawGeometry",
1885
- { args: [type, style, clear, callback, option] },
1886
- parentScene
1887
- );
1888
- };
1889
-
1890
- /* 热力图*/
1891
- that.addHeatMap = function (data, option) {
1892
- scene.fire(
1893
- msgPrefix + ":addHeatMap",
1894
- { args: [data, option] },
1895
- parentScene
1896
- );
1897
- };
1898
-
1899
- /**
1900
- * 淹没点分析
1901
- */
1902
- that.addDrownPoint = function (option) {
1903
- scene.fire(
1904
- msgPrefix + ":addDrownPoint",
1905
- { args: [option] },
1906
- parentScene
1907
- );
1908
- };
1909
- that.removeDrownPoint = function (id) {
1910
- scene.fire(
1911
- msgPrefix + ":removeDrownPoint",
1912
- { args: [id] },
1913
- parentScene
1914
- );
1915
- };
1916
-
1917
- /* 聚类 */
1918
- that.addClusterLayer = function (data, id) {
1919
- scene.fire(
1920
- msgPrefix + ":addClusterLayer",
1921
- { args: [data, id] },
1922
- parentScene
1923
- );
1924
- };
1925
- /* 添加热区图层 */
1926
- that.addHotLayer = function (
1927
- layerUsageID,
1928
- outFields,
1929
- visiblelevel,
1930
- clickCallback,
1931
- style,
1932
- hstyle
1933
- ) {
1934
- var usageID = layerUsageID || 3007;
1935
- var style = style || {
1936
- type: "esriSFS",
1937
- style: "esriSFSSolid",
1938
- color: [100, 100, 100, 125],
1939
- outline: {
1940
- type: "esriSLS",
1941
- style: "esriSLSSolid",
1942
- color: [255, 0, 0, 255],
1943
- width: 1,
1944
- },
1945
- };
1946
- var hstyle = hstyle || {
1947
- type: "esriSFS",
1948
- style: "esriSFSSolid",
1949
- color: [100, 100, 255, 125],
1950
- outline: {
1951
- type: "esriSLS",
1952
- style: "esriSLSSolid",
1953
- color: [255, 0, 0, 255],
1954
- width: 1,
1955
- },
1956
- };
1957
- var where = null;
1958
- scene.fire(
1959
- msgPrefix + ":addCustomWMSLayer",
1960
- { args: [usageID, style, hstyle, where, outFields, visiblelevel] },
1961
- parentScene
1962
- );
1963
-
1964
- if (clickCallback) {
1965
- that.removeEventBind("CustomWMSLayerMouseClick");
1966
- that.bindEvent("CustomWMSLayerMouseClick", function (evt) {
1967
- clickCallback(evt.args);
1968
- });
1969
- }
1970
- };
1971
-
1972
- /* 添加等值线图 */
1973
- that.addKrigingMap = function (datalist, options) {
1974
- scene.fire(
1975
- msgPrefix + ":addKrigingMap",
1976
- { args: [datalist, options] },
1977
- parentScene
1978
- );
1979
- };
1980
-
1981
- /* 删除热区图层 */
1982
- that.removeHotLayer = function () {
1983
- scene.fire(
1984
- msgPrefix + ":removeLayer",
1985
- { args: ["CustomWMSLayer"] },
1986
- parentScene
1987
- );
1988
- };
1989
-
1990
- /* 图层查询 */
1991
- that.queryPhylayerFeatures = function (params, callback) {
1992
- // 移除监听
1993
- that.removeEventBind("queryPhylayerFeaturesCallback");
1994
-
1995
- if (callback != undefined) {
1996
- that.bindEvent("queryPhylayerFeaturesCallback", function (evt) {
1997
- callback(evt.args);
1998
- });
1999
- }
2000
- scene.fire(
2001
- msgPrefix + ":queryPhylayerFeatures",
2002
- {
2003
- args: [
2004
- params.queryType,
2005
- params.queryValue,
2006
- params.phyLayerIDs,
2007
- params.where,
2008
- params.params,
2009
- params.startIndex,
2010
- params.maxFeatures,
2011
- ],
2012
- },
2013
- parentScene
2014
- );
2015
- };
2016
- // /* 执行查询任务 */
2017
- // that.executeQueryTask = function(params, callback) {
2018
- // var queryTaskContext = {};
2019
- // queryTaskContext.callback = callback;
2020
- // queryTaskContext.gisSuccessFn = queryTaskContext.gisErrorFn = function(data, result) {
2021
- // this.callback(result);
2022
- // }
2023
- // var queryTaskService = http.getInstance("", {type : "post", async: false, "callback": callback }, queryTaskContext.gisSuccessFn, queryTaskContext.gisErrorFn, queryTaskContext);
2024
- // queryTaskService.settings.url = context.gisServerURL + "/home/gis/event/execquerytask.htm";
2025
- // queryTaskService.ajax(params);
2026
- // }
2027
- /* 显示消息框 */
2028
- that.showInfoWindow = function (params) {
2029
- var visible = params.visible;
2030
- var position = {};
2031
- position.x = params.x;
2032
- position.y = params.y;
2033
- var title = params.title;
2034
- var content = params.content;
2035
- scene.fire(
2036
- msgPrefix + ":infoWindow",
2037
- { args: [visible, position, title, content] },
2038
- parentScene
2039
- );
2040
- };
2041
- /* 隐藏消息框 */
2042
- that.hideInfoWindow = function (params) {
2043
- scene.fire(msgPrefix + ":infoWindow", { args: [false] }, parentScene);
2044
- };
2045
-
2046
- /* 显示扩展消息框 */
2047
- that.showInfoWindowEx = function (params) {
2048
- scene.fire(
2049
- msgPrefix + ":showInfoWindow",
2050
- {
2051
- args: [
2052
- params.id || 0,
2053
- params.title,
2054
- params.content,
2055
- params.x,
2056
- params.y,
2057
- params.style,
2058
- params.options,
2059
- ],
2060
- },
2061
- parentScene
2062
- );
2063
- };
2064
- /* 显示扩展消息框 */
2065
- that.hideInfoWindowEx = function (id) {
2066
- scene.fire(
2067
- msgPrefix + ":hideInfoWindow",
2068
- {
2069
- args: [id],
2070
- },
2071
- parentScene
2072
- );
2073
- };
2074
- /** 设置扩展消息框样式
2075
- * option 基础样式选项,格式如:{noTitle:true,close:true,title:{},background:'#FFF'}
2076
- * noTitle: 是否显示标题栏;
2077
- * close: 是否显示关闭按钮;
2078
- * title: 标题栏的css样式对象
2079
- * background : 除标题栏外的其他部分的颜色
2080
- * style 位置和大小的配置,格式如:{width:300,height:300,achor:'auto',offsetY:0}
2081
- * width: 宽度
2082
- * height:高度
2083
- * achor:箭头方向,其中值包含 'top','left','right','bottom','auto'
2084
- * offsetY:Y方向上的偏移
2085
- **/
2086
- that.setInfoWindowStyle = function (option, style, id) {
2087
- scene.fire(
2088
- msgPrefix + ":setInfoWindowStyle",
2089
- {
2090
- args: [option, style, id],
2091
- },
2092
- parentScene
2093
- );
2094
- };
2095
-
2096
- /* 要素查询 */
2097
- that.queryFeature = function (params, callback) {
2098
- if (scene == null) return;
2099
- scene.fire(
2100
- msgPrefix + ":queryFeature",
2101
- {
2102
- args: [
2103
- params.layerID,
2104
- params.where || null,
2105
- params.geometry || null,
2106
- params.outFields,
2107
- params.outGeometry,
2108
- params.pointTolorence || 0,
2109
- params.startIndex,
2110
- params.maxFeatures,
2111
- null,
2112
- callback || null,
2113
- params.sortBy,
2114
- params.filterNullGeometry,
2115
- params.options,
2116
- params.featureIds,
2117
- ],
2118
- },
2119
- parentScene
2120
- );
2121
- };
2122
-
2123
- /* 显示图层
2124
- * layerID:图层ID ,
2125
- * serviceID:服务ID(可选),
2126
- * showAtBottom:是否显示在最底层(true:显示到最底层,false:显示在最顶层),
2127
- * zoomLevel:缩放级别(传入数字为缩放到对应的级别,传入true缩放到最大可视级别)
2128
- */
2129
- that.showVectorLayer = function (
2130
- layerID,
2131
- serviceID,
2132
- showAtBottom,
2133
- zoomLevel
2134
- ) {
2135
- if (scene == null) return;
2136
- scene.fire(
2137
- msgPrefix + ":showVectorLayer",
2138
- { args: [layerID, serviceID, showAtBottom, zoomLevel] },
2139
- parentScene
2140
- );
2141
- };
2142
-
2143
- /* 隐藏图层 */
2144
- that.hideVectorLayer = function (layerID, serviceID) {
2145
- if (scene == null) return;
2146
- scene.fire(
2147
- msgPrefix + ":hideVectorLayer",
2148
- { args: [layerID, serviceID] },
2149
- parentScene
2150
- );
2151
- };
2152
-
2153
- /* 获取当前地图范围 */
2154
- that.getMapExtent = function (callback) {
2155
- // 移除监听
2156
- that.removeEventBind("getMapExtentCallback");
2157
-
2158
- if (callback != undefined) {
2159
- that.bindEvent("getMapExtentCallback", function (evt) {
2160
- callback(evt.args);
2161
- });
2162
- }
2163
- scene.fire(msgPrefix + ":getMapExtent", { args: [] }, parentScene);
2164
- };
2165
-
2166
- /**查询表信息*/
2167
- that.queryObjectInfo = function (
2168
- geoShapes,
2169
- tableName,
2170
- xFieldName,
2171
- yFieldName,
2172
- callback,
2173
- usePage,
2174
- currentPage,
2175
- numPerPage,
2176
- params,
2177
- cacheKey
2178
- ) {
2179
- var queryParam = {
2180
- tableName: tableName,
2181
- xFieldName: xFieldName,
2182
- yFieldName: yFieldName,
2183
- };
2184
- if (params)
2185
- queryParam = MapUtils.deepClones(true, {}, queryParam, params);
2186
-
2187
- that.removeEventBind("queryObjectInfoCallback");
2188
- that.bindEvent("queryObjectInfoCallback", callback);
2189
- scene.fire(
2190
- msgPrefix + ":queryObjectInfo",
2191
- {
2192
- args: [
2193
- JSON.stringify(geoShapes),
2194
- JSON.stringify(queryParam),
2195
- usePage,
2196
- currentPage,
2197
- numPerPage,
2198
- cacheKey,
2199
- ],
2200
- },
2201
- parentScene,
2202
- false
2203
- );
2204
- };
2205
-
2206
- that.enableMapSnap = function (layerID, callback) {
2207
- if (scene == null) return;
2208
- if (!layerID) return;
2209
- that.removeEventBind("enableMapSnapCallback");
2210
- that.bindEvent("enableMapSnapCallback", callback);
2211
- scene.fire(
2212
- msgPrefix + ":enableMapSnap",
2213
- {
2214
- args: [layerID],
2215
- },
2216
- parentScene
2217
- );
2218
- };
2219
-
2220
- that.disableMapSnap = function (layerID) {
2221
- if (scene == null) return;
2222
- if (!layerID) return;
2223
- scene.fire(
2224
- msgPrefix + ":disableMapSnap",
2225
- {
2226
- args: [layerID],
2227
- },
2228
- parentScene
2229
- );
2230
- };
2231
-
2232
- that.addMaskLayer = function (
2233
- layerID,
2234
- keyField,
2235
- values,
2236
- style,
2237
- zoom,
2238
- position
2239
- ) {
2240
- scene.fire(
2241
- msgPrefix + ":addMaskLayer",
2242
- { args: [layerID, keyField, values, style, zoom, position] },
2243
- parentScene
2244
- );
2245
- };
2246
-
2247
- /* 计算线、面长度,支持线、面格式 */
2248
- that.getGeometryLength = function (geometry) {
2249
- return scene.fire(
2250
- msgPrefix + ":getGeometryLength",
2251
- { args: [geometry] },
2252
- parentScene
2253
- );
2254
- };
2255
-
2256
- /* 计算多边形面积 */
2257
- that.getPolygonArea = function (geometry) {
2258
- return scene.fire(
2259
- msgPrefix + ":getPolygonArea",
2260
- { args: [geometry] },
2261
- parentScene
2262
- );
2263
- };
2264
-
2265
- that.intersectGeometry = function (polygon1, polygon2) {
2266
- return scene.fire(
2267
- msgPrefix + ":intersectGeometry",
2268
- { args: [polygon1, polygon2] },
2269
- parentScene
2270
- );
2271
- };
2272
-
2273
- that.getCenterPoint = function (polygon) {
2274
- return scene.fire(
2275
- msgPrefix + ":getCenterPoint",
2276
- { args: [polygon] },
2277
- parentScene
2278
- );
2279
- };
2280
-
2281
- /* 根据PointID定位空中全景 */
2282
- that.mmsAirPanoLocateByID = function (pointID) {
2283
- if (mmsMap && mmsMap.mmsLoaded) {
2284
- scene.fire(
2285
- msgPrefix + ":mmsAirPanoLocateCallback",
2286
- { args: [pointID] },
2287
- parentScene
2288
- );
2289
- }
2290
- };
2291
-
2292
- /* 空中全景历史对比回调 */
2293
- that.mmsAirPanoCompare = function (callback) {
2294
- if (mmsMap && mmsMap.mmsLoaded) {
2295
- scene.fire(
2296
- msgPrefix + ":mmsAirPanoCompareCallback",
2297
- { args: [callback] },
2298
- parentScene
2299
- );
2300
- }
2301
- };
2302
-
2303
- that.setMMSEyePositionTest = function (x, y) {
2304
- var pos = { x: x, y: y };
2305
- var evt = { args: [pos] };
2306
- mmsMap.setMMSEyePosition(evt);
2307
- };
2308
-
2309
- /* 切换地图类型 */
2310
- that.changeControlParam = function (type, param) {
2311
- scene.fire(
2312
- msgPrefix + ":changeControlParam",
2313
- { args: [type, param] },
2314
- parentScene
2315
- );
2316
- };
2317
-
2318
- /* 获取图层信息 */
2319
- that.getPhyLayerInfo = function (phyLayerID, getPhyLayerInfoCallBack) {
2320
- that.removeEventBind("getPhyLayerInfoCallback");
2321
- if (getPhyLayerInfoCallBack != undefined) {
2322
- that.bindEvent("getPhyLayerInfoCallback", function (evt) {
2323
- getPhyLayerInfoCallBack(evt.args);
2324
- });
2325
- }
2326
- scene.fire(
2327
- msgPrefix + ":getPhyLayerInfo",
2328
- { args: [phyLayerID] },
2329
- parentScene,
2330
- true
2331
- );
2332
- };
2333
-
2334
- /* 获取图层字段信息 */
2335
- that.getPhyLayerField = function (phyLayerIDs, getPhyLayerFieldCallback) {
2336
- that.removeEventBind("getPhyLayerFieldCallback");
2337
- if (getPhyLayerFieldCallback != undefined) {
2338
- that.bindEvent("getPhyLayerFieldCallback", function (evt) {
2339
- getPhyLayerFieldCallback(evt.args);
2340
- });
2341
- }
2342
- scene.fire(
2343
- msgPrefix + ":getPhyLayerField",
2344
- { args: [phyLayerIDs] },
2345
- parentScene,
2346
- true
2347
- );
2348
- };
2349
-
2350
- /* 获取图层字段信息 */
2351
- that.getPhyLayerField = function (phyLayerIDs, getPhyLayerFieldCallback) {
2352
- that.removeEventBind("getPhyLayerFieldCallback");
2353
- if (getPhyLayerFieldCallback != undefined) {
2354
- that.bindEvent("getPhyLayerFieldCallback", function (evt) {
2355
- getPhyLayerFieldCallback(evt.args);
2356
- });
2357
- }
2358
- scene.fire(
2359
- msgPrefix + ":getPhyLayerField",
2360
- { args: [phyLayerIDs] },
2361
- parentScene,
2362
- true
2363
- );
2364
- };
2365
-
2366
- /*对几何图形进行缓冲*/
2367
- that.getGeometryBuffer = function (
2368
- geometry,
2369
- radius,
2370
- callback,
2371
- autoTransRadius
2372
- ) {
2373
- that.removeEventBind("getGeometryBufferCallback");
2374
- if (callback != undefined) {
2375
- that.bindEvent("getGeometryBufferCallback", function (evt) {
2376
- callback(evt.args);
2377
- });
2378
- }
2379
- scene.fire(
2380
- msgPrefix + ":getGeometryBuffer",
2381
- { args: [geometry, radius, autoTransRadius] },
2382
- parentScene,
2383
- true
2384
- );
2385
- };
2386
-
2387
- /* 移除图层*/
2388
- that.removeLayer = function (layerName) {
2389
- scene.fire(
2390
- msgPrefix + ":removeLayer",
2391
- { args: [layerName] },
2392
- parentScene,
2393
- true
2394
- );
2395
- };
2396
-
2397
- that.change3dlayerUsageConfig = function () {
2398
- if (scene == null) return;
2399
- var config = scene.layerUsageConfig;
2400
- scene.fire(
2401
- msgPrefix + ":change3dlayerUsageConfig",
2402
- { args: [config] },
2403
- parentScene
2404
- );
2405
- };
2406
- /*显示多轨迹*/
2407
- that.showTraceMultiHisLayer = function (
2408
- objectIDs,
2409
- symbolType,
2410
- beginDate,
2411
- endDate,
2412
- clear,
2413
- zoom,
2414
- hStyle
2415
- ) {
2416
- scene.fire(
2417
- msgPrefix + ":showTraceMultiHisLayer",
2418
- {
2419
- args: [
2420
- objectIDs,
2421
- symbolType,
2422
- beginDate,
2423
- endDate,
2424
- clear,
2425
- zoom,
2426
- hStyle,
2427
- ],
2428
- },
2429
- parentScene
2430
- );
2431
- };
2432
- /*清除多轨迹*/
2433
- that.claerTraceMultiHisLayer = function () {
2434
- scene.fire(
2435
- msgPrefix + ":claerTraceMultiHisLayer",
2436
- { args: [] },
2437
- parentScene
2438
- );
2439
- };
2440
- /*多人员图标通过id高亮*/
2441
- that.multiPointsSelectbyID = function (id) {
2442
- scene.fire(
2443
- msgPrefix + ":multiPointsSelectbyID",
2444
- { args: [id] },
2445
- parentScene
2446
- );
2447
- };
2448
- /*多轨迹通过id高亮*/
2449
- that.traceMultiSelectbyID = function (id) {
2450
- scene.fire(
2451
- msgPrefix + ":traceMultiSelectbyID",
2452
- { args: [id] },
2453
- parentScene
2454
- );
2455
- };
2456
-
2457
- // arcgis格式geometry转wkt格式
2458
- that.agsToWKT = function (geometry, callback) {
2459
- scene.fire(
2460
- msgPrefix + ":agsToWKT",
2461
- { args: [geometry, callback] },
2462
- parentScene
2463
- );
2464
- };
2465
- /*网格化方式绘制管线*/
2466
- that.showCustomGrid = function (jsonInfo, region) {
2467
- scene.fire(
2468
- msgPrefix + ":showCustomGrid",
2469
- { args: [jsonInfo, region] },
2470
- parentScene
2471
- );
2472
- };
2473
-
2474
- /*网格化方式清除管线*/
2475
- that.clearCustomGrid = function () {
2476
- scene.fire(msgPrefix + ":clearCustomGrid", { args: [] }, parentScene);
2477
- };
2478
-
2479
- /**
2480
- * 开始测量
2481
- * @param {*} options {type:'area'|'length'; callBack:绘制完成回调函数;errorCallBack:错误回调函数;}
2482
- */
2483
- that.startMeasure = function (options) {
2484
- if (scene == null) return;
2485
- scene.fire(
2486
- msgPrefix + ":startMeasure",
2487
- { args: [options] },
2488
- parentScene,
2489
- false
2490
- );
2491
- };
2492
-
2493
- // 结束测量
2494
- that.stopMeasure = function () {
2495
- if (scene == null) return;
2496
- scene.fire(
2497
- msgPrefix + ":stopMeasure",
2498
- { args: [] },
2499
- parentScene,
2500
- false
2501
- );
2502
- };
2503
-
2504
- that.mouseMoveEvent = function (callback) {
2505
- if (scene == null) return;
2506
- scene.fire(
2507
- msgPrefix + ":mouseMoveEvent",
2508
- { args: [callback] },
2509
- parentScene,
2510
- false
2511
- );
2512
- };
2513
-
2514
- that.init();
2515
- };
2516
- 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
+ scene.fire(
1053
+ msgPrefix + ":showMultiObjectCurrentPosition",
1054
+ {
1055
+ args: [
1056
+ jsonInfo,
1057
+ zoom,
1058
+ bClear,
1059
+ hStyleID,
1060
+ infoStyle,
1061
+ bCanvas,
1062
+ tagName,
1063
+ clusterOption,
1064
+ hasHover,
1065
+ layerID,
1066
+ options,
1067
+ ],
1068
+ },
1069
+ parentScene,
1070
+ false
1071
+ );
1072
+ };
1073
+ /* 显示监督员 */
1074
+ that.showPatrolCurrentPosition = function (
1075
+ jsonInfo,
1076
+ zoom,
1077
+ bClear,
1078
+ hStyleID,
1079
+ clickCallback
1080
+ ) {
1081
+ if (scene == null) return;
1082
+
1083
+ var args = Array.prototype.slice.call(arguments);
1084
+ if (arguments[arguments.length - 1] instanceof Function) {
1085
+ clickCallback = arguments[arguments.length - 1];
1086
+ args = args.slice(0, args.length - 1);
1087
+ }
1088
+
1089
+ if (clickCallback) {
1090
+ that.removeEventBind("showPatrolCurrentPositionCallback");
1091
+ that.bindEvent("showPatrolCurrentPositionCallback", function (evt) {
1092
+ clickCallback(evt.args);
1093
+ });
1094
+ }
1095
+ scene.fire(
1096
+ msgPrefix + ":showPatrolCurrentPosition",
1097
+ { args: args },
1098
+ parentScene,
1099
+ false
1100
+ );
1101
+ };
1102
+ /* 获取缓冲区 */
1103
+ that.getBuffer = function (layerID, x, y, radius, getBufferCallback) {
1104
+ if (scene == null) return;
1105
+
1106
+ var args = Array.prototype.slice.call(arguments);
1107
+ if (arguments[arguments.length - 1] instanceof Function) {
1108
+ getBufferCallback = arguments[arguments.length - 1];
1109
+ args = args.slice(0, args.length - 1);
1110
+ }
1111
+
1112
+ if (getBufferCallback) {
1113
+ that.removeEventBind("getBufferCallback");
1114
+ that.bindEvent("getBufferCallback", function (evt) {
1115
+ getBufferCallback(evt.args);
1116
+ });
1117
+ }
1118
+ scene.fire(msgPrefix + ":getBuffer", { args: args }, parentScene, true);
1119
+ };
1120
+ /* 获取多点的缓冲区 */
1121
+ that.getMultiPointBuffer = function (points, radius, callback, options) {
1122
+ if (scene == null) return;
1123
+ scene.fire(
1124
+ msgPrefix + ":getMultiPointBuffer",
1125
+ { args: [points, radius, callback, options] },
1126
+ parentScene,
1127
+ true
1128
+ );
1129
+ };
1130
+ /**
1131
+ * 设置指定图层的样式
1132
+ * @param id 元素的id
1133
+ * @param tag 图层的标签
1134
+ * @param style 图层样式
1135
+ * @returns
1136
+ */
1137
+ that.setGraphicStyle = function (id, tag, style) {
1138
+ if (scene == null) return;
1139
+ scene.fire(
1140
+ msgPrefix + ":setGraphicStyle",
1141
+ { args: [id, tag, style] },
1142
+ parentScene,
1143
+ true
1144
+ );
1145
+ };
1146
+ /* 显示监督员责任网格 */
1147
+ that.showPatrolDutygridCells = function (infoJson, zoom, clickCallback) {
1148
+ if (scene == null) return;
1149
+
1150
+ var layerID = infoJson.layerID;
1151
+ var layerKeyFieldName = infoJson.keyFieldName;
1152
+ var cellID = infoJson.grids;
1153
+ var bClearMap = false;
1154
+ var gridCellStyle = {};
1155
+ gridCellStyle.style = {
1156
+ type: "esriSFS",
1157
+ style: "esriSFSSolid",
1158
+ color: [0, 0, 100, 76],
1159
+ outline: {
1160
+ type: "esriSLS",
1161
+ style: "esriSLSSolid",
1162
+ color: [255, 130, 47, 255],
1163
+ width: 2,
1164
+ },
1165
+ };
1166
+ gridCellStyle.hStyle = MapUtils.deepClones(
1167
+ true,
1168
+ {},
1169
+ gridCellStyle.style
1170
+ );
1171
+ that.locateFeatureByIDs(
1172
+ layerID,
1173
+ layerKeyFieldName,
1174
+ cellID,
1175
+ bClearMap,
1176
+ gridCellStyle.style,
1177
+ gridCellStyle.hStyle,
1178
+ zoom
1179
+ );
1180
+ };
1181
+ /* 标识位置 */
1182
+ that.markMap = function (
1183
+ projectTypeID,
1184
+ eventTypeID,
1185
+ actPropertyID,
1186
+ displayStyleID,
1187
+ layerID,
1188
+ clickCallback,
1189
+ cellIndexName,
1190
+ point,
1191
+ symbolUrl,
1192
+ bdGridCodeOpt
1193
+ ) {
1194
+ if (scene == null) return;
1195
+
1196
+ // 移除监听
1197
+ that.removeEventBind("markMapCallback");
1198
+
1199
+ //新增了layerID,因此需要兼容原来的4个参数
1200
+ if (arguments.length == 5 && typeof layerID == "function") {
1201
+ clickCallback = layerID;
1202
+ layerID == null;
1203
+ }
1204
+
1205
+ if (clickCallback != undefined) {
1206
+ that.bindEvent("markMapCallback", function (evt) {
1207
+ clickCallback(evt.args);
1208
+ });
1209
+ }
1210
+ scene.fire(
1211
+ msgPrefix + ":markMap",
1212
+ {
1213
+ args: [
1214
+ projectTypeID,
1215
+ eventTypeID,
1216
+ actPropertyID,
1217
+ displayStyleID,
1218
+ layerID,
1219
+ cellIndexName,
1220
+ point,
1221
+ symbolUrl,
1222
+ bdGridCodeOpt,
1223
+ ],
1224
+ },
1225
+ parentScene,
1226
+ false
1227
+ );
1228
+ };
1229
+ /* 案件定位 */
1230
+ that.eventLocate = that.recLocate = function (eventID, defaultMapRange) {
1231
+ if (scene == null) return;
1232
+
1233
+ if (defaultMapRange == undefined) defaultMapRange = 200;
1234
+ scene.fire(
1235
+ msgPrefix + ":eventLocate",
1236
+ { args: [eventID, defaultMapRange] },
1237
+ parentScene,
1238
+ false
1239
+ );
1240
+ };
1241
+ /* 显示特定图层 */
1242
+ that.showMapLayers = function (
1243
+ layerTag,
1244
+ showLevel,
1245
+ mode,
1246
+ styles,
1247
+ layerDefs
1248
+ ) {
1249
+ if (scene == null) return;
1250
+ scene.fire(
1251
+ msgPrefix + ":showMapLayers",
1252
+ { args: [layerTag, showLevel, mode, styles, layerDefs] },
1253
+ parentScene,
1254
+ false
1255
+ );
1256
+ };
1257
+ /**
1258
+ * 刷新地图图层
1259
+ */
1260
+ that.refreshMapLayers = function () {
1261
+ if (scene) {
1262
+ scene.fire(
1263
+ msgPrefix + ":refreshMapLayers",
1264
+ { args: [] },
1265
+ parentScene,
1266
+ false
1267
+ );
1268
+ }
1269
+ };
1270
+ /* 显示车辆人员轨迹 */
1271
+ that.showObjectTrace = function (
1272
+ objectID,
1273
+ symbolType,
1274
+ dateTime,
1275
+ queryCondition,
1276
+ hideControlPanel,
1277
+ symbolPic,
1278
+ optimizeParams,
1279
+ infoCallback,
1280
+ updatePositionCallback,
1281
+ closeCallback,
1282
+ traceDigCallback
1283
+ ) {
1284
+ if (scene == null) return;
1285
+
1286
+ if (closeCallback) {
1287
+ that.removeEventBind("TraceManagerCloseCallback");
1288
+ that.bindEvent("TraceManagerCloseCallback", function () {
1289
+ closeCallback();
1290
+ });
1291
+ }
1292
+ if (infoCallback) {
1293
+ that.removeEventBind("showObjectTraceCallback");
1294
+ that.bindEvent("showObjectTraceCallback", function (evt) {
1295
+ infoCallback(evt && evt.args);
1296
+ });
1297
+ }
1298
+ if (updatePositionCallback) {
1299
+ that.removeEventBind("updatePositionCallback");
1300
+ that.bindEvent("updatePositionCallback", function (evt) {
1301
+ updatePositionCallback(evt && evt.args);
1302
+ });
1303
+ }
1304
+ if (traceDigCallback) {
1305
+ that.removeEventBind("getPatrolTraceDigCallback");
1306
+ that.bindEvent("getPatrolTraceDigCallback", function (evt) {
1307
+ traceDigCallback(evt && evt.args);
1308
+ });
1309
+ }
1310
+ /*if (context.sysConfig['PATROL_POS_WRITE_TO_FILE']) {
1311
+ if (queryCondition) {
1312
+ queryCondition = $.extend({}, queryCondition, { 'resourcetype': 2 });
1313
+ } else {
1314
+ queryCondition = { 'resourcetype': 2 };
1315
+ }
1316
+ }*/
1317
+ scene.fire(
1318
+ msgPrefix + ":showObjectTrace",
1319
+ {
1320
+ args: [
1321
+ objectID,
1322
+ symbolType,
1323
+ dateTime,
1324
+ queryCondition,
1325
+ hideControlPanel,
1326
+ symbolPic,
1327
+ optimizeParams,
1328
+ ],
1329
+ },
1330
+ parentScene
1331
+ );
1332
+ };
1333
+
1334
+ /*跳转轨迹位置*/
1335
+ that.updatePositionByTime = function (time) {
1336
+ if (scene == null) return;
1337
+ scene.fire(
1338
+ msgPrefix + ":updatePositionByTime",
1339
+ { args: [time] },
1340
+ parentScene
1341
+ );
1342
+ };
1343
+
1344
+ /**
1345
+ *轨迹开始播放/暂停
1346
+ **/
1347
+ that.playObjectTrace = function (speed, doNotChangeState) {
1348
+ scene.fire(
1349
+ msgPrefix + ":playObjectTrace",
1350
+ { args: [speed, doNotChangeState] },
1351
+ parentScene
1352
+ );
1353
+ };
1354
+
1355
+ /**
1356
+ *轨迹停止
1357
+ **/
1358
+ that.stopObjectTrace = function () {
1359
+ scene.fire(msgPrefix + ":stopObjectTrace", { args: [] }, parentScene);
1360
+ };
1361
+
1362
+ /**
1363
+ *更新轨迹播放速度
1364
+ **/
1365
+ that.updatePlaySpeed = function (value) {
1366
+ scene.fire(
1367
+ msgPrefix + ":updatePlaySpeed",
1368
+ { args: [value] },
1369
+ parentScene
1370
+ );
1371
+ };
1372
+
1373
+ that.startRealtimeTrace = function (
1374
+ groupIDs,
1375
+ objectIDs,
1376
+ objectType,
1377
+ resourceType,
1378
+ uiOption,
1379
+ traceOption,
1380
+ jobOption,
1381
+ options
1382
+ ) {
1383
+ if (scene == null) return;
1384
+
1385
+ var groupIDStrs = "";
1386
+ if (groupIDs instanceof Array && groupIDs.length > 0) {
1387
+ for (var i = 0; i < groupIDs.length; i++) {
1388
+ if (i != groupIDs.length - 1) {
1389
+ groupIDStrs += "comp_" + groupIDs[i] + ",";
1390
+ } else {
1391
+ groupIDStrs += "comp_" + groupIDs[i];
1392
+ }
1393
+ }
1394
+ }
1395
+
1396
+ var objectIDStrs = "";
1397
+ if (
1398
+ objectIDs instanceof Array &&
1399
+ objectIDs.length > 0 &&
1400
+ groupIDs instanceof Array &&
1401
+ groupIDs.length > 0
1402
+ ) {
1403
+ for (var i = 0; i < groupIDs.length; i++) {
1404
+ for (var j = 0; j < objectIDs.length; j++) {
1405
+ if (j != objectIDs.length - 1) {
1406
+ objectIDStrs += groupIDs[i] + "_" + objectIDs[j] + ",";
1407
+ } else {
1408
+ objectIDStrs += groupIDs[i] + "_" + objectIDs[j];
1409
+ }
1410
+ }
1411
+ }
1412
+ }
1413
+ // 监听
1414
+ if (!options) options = {};
1415
+ if (typeof options.MultiTraceDataCallback === "function") {
1416
+ that.removeEventBind("MultiTraceDataCallback");
1417
+ that.bindEvent("MultiTraceDataCallback", function (evt) {
1418
+ options.MultiTraceDataCallback(evt && evt.args);
1419
+ });
1420
+ }
1421
+
1422
+ if (typeof options.mouseOverCallback === "function") {
1423
+ that.removeEventBind("MultiTraceMouseOver");
1424
+ that.bindEvent("MultiTraceMouseOver", function (evt) {
1425
+ options.mouseOverCallback(evt && evt.args);
1426
+ });
1427
+ }
1428
+ if (typeof options.mouseOutCallback === "function") {
1429
+ that.removeEventBind("MultiTraceMouseOut");
1430
+ that.bindEvent("MultiTraceMouseOut", function (evt) {
1431
+ options.mouseOutCallback(evt && evt.args);
1432
+ });
1433
+ }
1434
+ if (typeof options.clickCallback === "function") {
1435
+ that.removeEventBind("MultiTraceClick");
1436
+ that.bindEvent("MultiTraceClick", function (evt) {
1437
+ options.clickCallback(evt && evt.args);
1438
+ });
1439
+ }
1440
+ scene.fire(
1441
+ msgPrefix + ":startRealtimeTrace",
1442
+ {
1443
+ args: [
1444
+ groupIDStrs,
1445
+ objectIDStrs,
1446
+ objectType,
1447
+ resourceType,
1448
+ uiOption,
1449
+ traceOption,
1450
+ jobOption,
1451
+ ],
1452
+ },
1453
+ parentScene
1454
+ );
1455
+ };
1456
+
1457
+ that.stopRealtimeTrace = function (objectType, resourceType) {
1458
+ if (scene == null) return;
1459
+
1460
+ scene.fire(msgPrefix + ":stopRealtimeTrace", { args: [objectType, resourceType] }, parentScene);
1461
+ };
1462
+ /**
1463
+ *停止绘制要素
1464
+ **/
1465
+ that.stopDraw = function () {
1466
+ scene.fire(msgPrefix + ":stopDraw", { args: [] }, parentScene);
1467
+ };
1468
+
1469
+ /**
1470
+ *等值面生成
1471
+ **/
1472
+ that.isobands = function (
1473
+ attrarry,
1474
+ xarry,
1475
+ yarry,
1476
+ breaks,
1477
+ breakcolors,
1478
+ cellwidth,
1479
+ boundary,
1480
+ hascelllabel,
1481
+ labelcolor,
1482
+ callback,
1483
+ options
1484
+ ) {
1485
+ scene.fire(
1486
+ msgPrefix + ":isobands",
1487
+ {
1488
+ args: [
1489
+ attrarry,
1490
+ xarry,
1491
+ yarry,
1492
+ breaks,
1493
+ breakcolors,
1494
+ cellwidth,
1495
+ boundary,
1496
+ hascelllabel,
1497
+ labelcolor,
1498
+ callback,
1499
+ options,
1500
+ ],
1501
+ },
1502
+ parentScene
1503
+ );
1504
+ };
1505
+
1506
+ //by ysj,2020-06-02
1507
+ that.checkObjectTraceItem = function (type, boolean) {
1508
+ scene.fire(
1509
+ msgPrefix + ":checkObjectTraceItem",
1510
+ { args: [type, boolean] },
1511
+ parentScene
1512
+ );
1513
+ };
1514
+
1515
+ /* 显示车辆人员轨迹热力的接口*/
1516
+ that.showTraceHeatMap = function (
1517
+ objectID,
1518
+ symbolType,
1519
+ starttime,
1520
+ endtime,
1521
+ queryCondition,
1522
+ hidePanel
1523
+ ) {
1524
+ if (scene == null) return;
1525
+ scene.fire(
1526
+ msgPrefix + ":showTraceHeatMap",
1527
+ {
1528
+ args: [
1529
+ objectID,
1530
+ symbolType,
1531
+ starttime,
1532
+ endtime,
1533
+ queryCondition,
1534
+ hidePanel,
1535
+ ],
1536
+ },
1537
+ parentScene
1538
+ );
1539
+ };
1540
+
1541
+ /*添加车辆或人员轨迹*/
1542
+ that.addObjectTrace = function (
1543
+ jsonInfo,
1544
+ symbolType,
1545
+ clear,
1546
+ showControlPanel
1547
+ ) {
1548
+ if (scene == null) return;
1549
+ scene.fire(
1550
+ msgPrefix + ":addObjectTrace",
1551
+ { args: [jsonInfo, symbolType, clear, showControlPanel] },
1552
+ parentScene
1553
+ );
1554
+ };
1555
+ /* 显示第三方上报人员轨迹 */
1556
+ that.showZzTaskTrace = function (
1557
+ objectID,
1558
+ symbolType,
1559
+ dataTime,
1560
+ queryCondition
1561
+ ) {
1562
+ if (scene == null) return;
1563
+ scene.fire(
1564
+ msgPrefix + ":showObjectTrace",
1565
+ { args: [objectID, symbolType, dataTime, queryCondition] },
1566
+ parentScene
1567
+ );
1568
+ };
1569
+ /* 绘制巡更路线 */
1570
+ that.showPatrolRoute = function (
1571
+ routeList,
1572
+ type,
1573
+ bClear,
1574
+ editable,
1575
+ zoom,
1576
+ options
1577
+ ) {
1578
+ if (scene == null) return;
1579
+ if (!(routeList instanceof Array)) routeList = [routeList];
1580
+ if (bClear == undefined) bClear = false;
1581
+ if (editable == undefined) editable = false;
1582
+
1583
+ var graphics = [];
1584
+ for (var i = 0; i < routeList.length; i++) {
1585
+ var route = routeList[i];
1586
+ var line = [];
1587
+ var attributes = [];
1588
+ var graphic = {
1589
+ id: route.routeID + "",
1590
+ geometry: { paths: [line] },
1591
+ attributes: attributes,
1592
+ };
1593
+ for (var j = 0; j < route.pointList.length; j++) {
1594
+ var point = route.pointList[j];
1595
+ line.push([point.coordinateX, point.coordinateY]);
1596
+ attributes.push(point.pointID);
1597
+ }
1598
+ graphics.push(graphic);
1599
+ }
1600
+ options = options || {};
1601
+ var lineStyle = options.lineStyle || {};
1602
+ var arrowStyle = options.arrowStyle || {};
1603
+ var style = { color: [255, 0, 0, 150], width: 6 };
1604
+ if (type == "dutyGridRoute") {
1605
+ style.color = [0, 0, 255, 150];
1606
+ }
1607
+ if (type == "patrolRoute") {
1608
+ style.color = [0, 255, 0, 150];
1609
+ }
1610
+ var lineSymbol = Object.assign(style, lineStyle);
1611
+ var arrowSymbol = Object.assign({ size: 6 }, arrowStyle);
1612
+ var option = {};
1613
+ option.arrowStyle = arrowSymbol;
1614
+ option.visible =
1615
+ options.visible == null || options.visible == "undefined"
1616
+ ? true
1617
+ : options.visible;
1618
+ scene.fire(
1619
+ msgPrefix + ":showPatrolRoute",
1620
+ { args: [graphics, bClear, lineSymbol, editable, zoom, option] },
1621
+ parentScene
1622
+ );
1623
+ };
1624
+ /* 添加巡更路线 */
1625
+ that.addPatrolRoute = function (addCallback, editCallback) {
1626
+ if (scene == null) return;
1627
+
1628
+ // 移除监听
1629
+ that.removeEventBind("drawPatrolRouteNewCallback");
1630
+ that.removeEventBind("drawPatrolRouteEditCallback");
1631
+
1632
+ if (addCallback != undefined) {
1633
+ that.bindEvent("drawPatrolRouteNewCallback", function (evt) {
1634
+ addCallback(evt.args);
1635
+ });
1636
+ }
1637
+ if (editCallback != undefined) {
1638
+ that.bindEvent("drawPatrolRouteEditCallback", function (evt) {
1639
+ editCallback(evt.args);
1640
+ });
1641
+ }
1642
+ var style = { color: [255, 0, 0, 150], width: 2 };
1643
+ scene.fire(
1644
+ msgPrefix + ":drawPatrolRoute",
1645
+ { args: [style] },
1646
+ parentScene
1647
+ );
1648
+ };
1649
+ /* 删除巡更路线 */
1650
+ that.deletePatrolRoute = function (callback, withConfirm) {
1651
+ if (scene == null) return;
1652
+
1653
+ // 移除监听
1654
+ that.removeEventBind("deletePatrolRouteCallback");
1655
+
1656
+ if (callback != undefined) {
1657
+ that.bindEvent("deletePatrolRouteCallback", function (evt) {
1658
+ callback(evt.args);
1659
+ });
1660
+ }
1661
+ if (withConfirm) {
1662
+ scene.fire(
1663
+ msgPrefix + ":deletePatrolRoute",
1664
+ { args: [false] },
1665
+ parentScene
1666
+ );
1667
+ } else {
1668
+ scene.fire(
1669
+ msgPrefix + ":deletePatrolRoute",
1670
+ { args: [] },
1671
+ parentScene
1672
+ );
1673
+ }
1674
+ };
1675
+ /* 获取正在编辑的路线 */
1676
+ that.getPatrolRouteEdit = function (callback) {
1677
+ if (scene == null) return;
1678
+
1679
+ // 移除监听
1680
+ that.removeEventBind("getPatrolRouteEditCallback");
1681
+
1682
+ if (callback != undefined) {
1683
+ that.bindEvent("getPatrolRouteEditCallback", function (evt) {
1684
+ callback(evt.args);
1685
+ });
1686
+ }
1687
+ scene.fire(
1688
+ msgPrefix + ":getPatrolRouteEdit",
1689
+ { args: [] },
1690
+ parentScene
1691
+ );
1692
+ };
1693
+
1694
+ /* 添加图形 */
1695
+ var pointStyle = {};
1696
+ pointStyle.style = {
1697
+ type: "esriSMS",
1698
+ style: "esriSMSCircle",
1699
+ color: [255, 0, 0, 150],
1700
+ size: 8,
1701
+ angle: 0,
1702
+ xoffset: 0,
1703
+ yoffset: 0,
1704
+ outline: { color: [255, 0, 0, 150], width: 1 },
1705
+ };
1706
+ pointStyle.hStyle = MapUtils.deepClones(true, {}, pointStyle.style);
1707
+ var polylineStyle = {};
1708
+ polylineStyle.style = {
1709
+ type: "esriSFS",
1710
+ style: "esriSFSSolid",
1711
+ color: [255, 0, 0, 150],
1712
+ outline: {
1713
+ type: "esriSLS",
1714
+ style: "esriSLSSolid",
1715
+ color: [0, 0, 255, 150],
1716
+ width: 1,
1717
+ },
1718
+ };
1719
+ polylineStyle.hStyle = MapUtils.deepClones(true, {}, polylineStyle.style);
1720
+ var polygonStyle = {};
1721
+ polygonStyle.style = {
1722
+ type: "esriSFS",
1723
+ style: "esriSFSSolid",
1724
+ color: [255, 0, 0, 150],
1725
+ outline: {
1726
+ type: "esriSLS",
1727
+ style: "esriSLSSolid",
1728
+ color: [0, 0, 255, 150],
1729
+ width: 1,
1730
+ },
1731
+ };
1732
+ polygonStyle.hStyle = MapUtils.deepClones(true, {}, polygonStyle.style);
1733
+ var styles = {
1734
+ point: pointStyle,
1735
+ polyline: polylineStyle,
1736
+ polygon: polygonStyle,
1737
+ };
1738
+
1739
+ that.getStyles = function (type, styleType) {
1740
+ var result = MapUtils.deepClones(true, {}, styles[type]);
1741
+ if (styleType == "esriSFSDiagonalCross") {
1742
+ result.style.type = "esriPFS";
1743
+ result.style.width = 10;
1744
+ result.style.height = 10;
1745
+ result.style.url = "images/diagonalcross_red.png";
1746
+ } else if (styleType == "esriPolygonHalfYellowTransparent") {
1747
+ result.style = {
1748
+ type: "esriSFS",
1749
+ style: "esriSFSSolid",
1750
+ color: [215, 214, 111, 100],
1751
+ outline: {
1752
+ type: "esriSLS",
1753
+ style: "esriSLSSolid",
1754
+ color: [0, 0, 255, 150],
1755
+ width: 1,
1756
+ },
1757
+ };
1758
+ } else if (styleType == "esriPointHalfYellowTransparent") {
1759
+ result.style = {
1760
+ type: "esriSMS",
1761
+ style: "esriSMSCircle",
1762
+ color: [215, 214, 111, 100],
1763
+ size: 8,
1764
+ angle: 0,
1765
+ xoffset: 0,
1766
+ yoffset: 0,
1767
+ outline: { color: [255, 0, 0, 150], width: 1 },
1768
+ };
1769
+ result.hStyle = MapUtils.deepClones(true, {}, pointStyle.style);
1770
+ } else if (styleType == "esriLineHalfYellowTransparent") {
1771
+ result.style = {
1772
+ type: "esriSFS",
1773
+ style: "esriSFSSolid",
1774
+ color: [215, 214, 111, 100],
1775
+ outline: {
1776
+ type: "esriSLS",
1777
+ style: "esriSLSSolid",
1778
+ color: [0, 0, 255, 150],
1779
+ width: 1,
1780
+ },
1781
+ };
1782
+ result.hStyle = MapUtils.deepClones(true, {}, pointStyle.style);
1783
+ }
1784
+ return result;
1785
+ };
1786
+ that.addGraphic = function (params, addCallback, editCallback) {
1787
+ if (scene == null) return;
1788
+
1789
+ // 移除监听
1790
+ that.removeEventBind("drawGeometryCallback");
1791
+ that.removeEventBind("drawGeometryEditCallback");
1792
+
1793
+ if (addCallback != undefined) {
1794
+ that.bindEvent("drawGeometryCallback", function (evt) {
1795
+ addCallback(evt.args);
1796
+ });
1797
+ }
1798
+ if (editCallback != undefined) {
1799
+ that.bindEvent("drawGeometryEditCallback", function (evt) {
1800
+ editCallback(evt.args);
1801
+ });
1802
+ }
1803
+ if (params[1] == null && styles[params[0]]) {
1804
+ params[1] = styles[params[0]].style;
1805
+ }
1806
+ scene.fire(msgPrefix + ":drawGeometry", { args: params }, parentScene);
1807
+ };
1808
+
1809
+ /* 编辑图形 */
1810
+ that.editGraphic = function (params, editCallback, deleteCallback) {
1811
+ if (scene == null) return;
1812
+
1813
+ // 移除监听
1814
+ that.removeEventBind("editGeometryCallback");
1815
+ that.removeEventBind("deleteGeometryCallback");
1816
+
1817
+ if (editCallback != undefined) {
1818
+ that.bindEvent("editGeometryCallback", function (evt) {
1819
+ editCallback(evt.args);
1820
+ });
1821
+ }
1822
+ if (deleteCallback != undefined) {
1823
+ that.bindEvent("deleteGeometryCallback", function (evt) {
1824
+ deleteCallback(evt.args);
1825
+ });
1826
+ }
1827
+ if (params[3] == null) {
1828
+ params[3] = styles.polygon.style;
1829
+ }
1830
+ scene.fire(msgPrefix + ":editGeometry", { args: params }, parentScene);
1831
+ };
1832
+
1833
+ /* 圆饼图 */
1834
+ that.addCircleChart = function (name, data, color, param) {
1835
+ color = color || "#1B5771";
1836
+ param = param || { minRadius: 20, rangeRadius: 20 };
1837
+ scene.fire(
1838
+ msgPrefix + ":addCircleChart",
1839
+ { args: [name, data, color, param] },
1840
+ parentScene
1841
+ );
1842
+ };
1843
+
1844
+ /* 饼图 */
1845
+ //by ysj,2020-06-03
1846
+ that.addChart = function (
1847
+ option,
1848
+ zoom,
1849
+ clickCallback,
1850
+ id,
1851
+ minZoom,
1852
+ maxZoom
1853
+ ) {
1854
+ that.removeEventBind("chartsLayerClickCallback");
1855
+ if (clickCallback != undefined) {
1856
+ that.bindEvent("chartsLayerClickCallback", function (evt) {
1857
+ clickCallback(evt.args);
1858
+ });
1859
+ }
1860
+ scene.fire(
1861
+ msgPrefix + ":addChart",
1862
+ { args: [option, zoom, id, minZoom, maxZoom] },
1863
+ parentScene
1864
+ );
1865
+ };
1866
+
1867
+ that.drawGeometry = function (type, style, clear, callback, option) {
1868
+ type = type || "point";
1869
+ style = style || {
1870
+ type: "esriSLS",
1871
+ style: "esriSLSSolid",
1872
+ color: [255, 0, 0, 255],
1873
+ width: 2,
1874
+ };
1875
+ //移除监听
1876
+ that.removeEventBind("drawGeometryCallback");
1877
+ if (callback != undefined) {
1878
+ that.bindEvent("drawGeometryCallback", function (evt) {
1879
+ callback(evt.args);
1880
+ });
1881
+ }
1882
+
1883
+ scene.fire(
1884
+ msgPrefix + ":drawGeometry",
1885
+ { args: [type, style, clear, callback, option] },
1886
+ parentScene
1887
+ );
1888
+ };
1889
+
1890
+ /* 热力图*/
1891
+ that.addHeatMap = function (data, option) {
1892
+ scene.fire(
1893
+ msgPrefix + ":addHeatMap",
1894
+ { args: [data, option] },
1895
+ parentScene
1896
+ );
1897
+ };
1898
+
1899
+ /**
1900
+ * 淹没点分析
1901
+ */
1902
+ that.addDrownPoint = function (option) {
1903
+ scene.fire(
1904
+ msgPrefix + ":addDrownPoint",
1905
+ { args: [option] },
1906
+ parentScene
1907
+ );
1908
+ };
1909
+ that.removeDrownPoint = function (id) {
1910
+ scene.fire(
1911
+ msgPrefix + ":removeDrownPoint",
1912
+ { args: [id] },
1913
+ parentScene
1914
+ );
1915
+ };
1916
+
1917
+ /* 聚类 */
1918
+ that.addClusterLayer = function (data, id) {
1919
+ scene.fire(
1920
+ msgPrefix + ":addClusterLayer",
1921
+ { args: [data, id] },
1922
+ parentScene
1923
+ );
1924
+ };
1925
+ /* 添加热区图层 */
1926
+ that.addHotLayer = function (
1927
+ layerUsageID,
1928
+ outFields,
1929
+ visiblelevel,
1930
+ clickCallback,
1931
+ style,
1932
+ hstyle
1933
+ ) {
1934
+ var usageID = layerUsageID || 3007;
1935
+ var style = style || {
1936
+ type: "esriSFS",
1937
+ style: "esriSFSSolid",
1938
+ color: [100, 100, 100, 125],
1939
+ outline: {
1940
+ type: "esriSLS",
1941
+ style: "esriSLSSolid",
1942
+ color: [255, 0, 0, 255],
1943
+ width: 1,
1944
+ },
1945
+ };
1946
+ var hstyle = hstyle || {
1947
+ type: "esriSFS",
1948
+ style: "esriSFSSolid",
1949
+ color: [100, 100, 255, 125],
1950
+ outline: {
1951
+ type: "esriSLS",
1952
+ style: "esriSLSSolid",
1953
+ color: [255, 0, 0, 255],
1954
+ width: 1,
1955
+ },
1956
+ };
1957
+ var where = null;
1958
+ scene.fire(
1959
+ msgPrefix + ":addCustomWMSLayer",
1960
+ { args: [usageID, style, hstyle, where, outFields, visiblelevel] },
1961
+ parentScene
1962
+ );
1963
+
1964
+ if (clickCallback) {
1965
+ that.removeEventBind("CustomWMSLayerMouseClick");
1966
+ that.bindEvent("CustomWMSLayerMouseClick", function (evt) {
1967
+ clickCallback(evt.args);
1968
+ });
1969
+ }
1970
+ };
1971
+
1972
+ /* 添加等值线图 */
1973
+ that.addKrigingMap = function (datalist, options) {
1974
+ scene.fire(
1975
+ msgPrefix + ":addKrigingMap",
1976
+ { args: [datalist, options] },
1977
+ parentScene
1978
+ );
1979
+ };
1980
+
1981
+ /* 删除热区图层 */
1982
+ that.removeHotLayer = function () {
1983
+ scene.fire(
1984
+ msgPrefix + ":removeLayer",
1985
+ { args: ["CustomWMSLayer"] },
1986
+ parentScene
1987
+ );
1988
+ };
1989
+
1990
+ /* 图层查询 */
1991
+ that.queryPhylayerFeatures = function (params, callback) {
1992
+ // 移除监听
1993
+ that.removeEventBind("queryPhylayerFeaturesCallback");
1994
+
1995
+ if (callback != undefined) {
1996
+ that.bindEvent("queryPhylayerFeaturesCallback", function (evt) {
1997
+ callback(evt.args);
1998
+ });
1999
+ }
2000
+ scene.fire(
2001
+ msgPrefix + ":queryPhylayerFeatures",
2002
+ {
2003
+ args: [
2004
+ params.queryType,
2005
+ params.queryValue,
2006
+ params.phyLayerIDs,
2007
+ params.where,
2008
+ params.params,
2009
+ params.startIndex,
2010
+ params.maxFeatures,
2011
+ ],
2012
+ },
2013
+ parentScene
2014
+ );
2015
+ };
2016
+ // /* 执行查询任务 */
2017
+ // that.executeQueryTask = function(params, callback) {
2018
+ // var queryTaskContext = {};
2019
+ // queryTaskContext.callback = callback;
2020
+ // queryTaskContext.gisSuccessFn = queryTaskContext.gisErrorFn = function(data, result) {
2021
+ // this.callback(result);
2022
+ // }
2023
+ // var queryTaskService = http.getInstance("", {type : "post", async: false, "callback": callback }, queryTaskContext.gisSuccessFn, queryTaskContext.gisErrorFn, queryTaskContext);
2024
+ // queryTaskService.settings.url = context.gisServerURL + "/home/gis/event/execquerytask.htm";
2025
+ // queryTaskService.ajax(params);
2026
+ // }
2027
+ /* 显示消息框 */
2028
+ that.showInfoWindow = function (params) {
2029
+ var visible = params.visible;
2030
+ var position = {};
2031
+ position.x = params.x;
2032
+ position.y = params.y;
2033
+ var title = params.title;
2034
+ var content = params.content;
2035
+ scene.fire(
2036
+ msgPrefix + ":infoWindow",
2037
+ { args: [visible, position, title, content] },
2038
+ parentScene
2039
+ );
2040
+ };
2041
+ /* 隐藏消息框 */
2042
+ that.hideInfoWindow = function (params) {
2043
+ scene.fire(msgPrefix + ":infoWindow", { args: [false] }, parentScene);
2044
+ };
2045
+
2046
+ /* 显示扩展消息框 */
2047
+ that.showInfoWindowEx = function (params) {
2048
+ scene.fire(
2049
+ msgPrefix + ":showInfoWindow",
2050
+ {
2051
+ args: [
2052
+ params.id || 0,
2053
+ params.title,
2054
+ params.content,
2055
+ params.x,
2056
+ params.y,
2057
+ params.style,
2058
+ params.options,
2059
+ ],
2060
+ },
2061
+ parentScene
2062
+ );
2063
+ };
2064
+ /* 显示扩展消息框 */
2065
+ that.hideInfoWindowEx = function (id) {
2066
+ scene.fire(
2067
+ msgPrefix + ":hideInfoWindow",
2068
+ {
2069
+ args: [id],
2070
+ },
2071
+ parentScene
2072
+ );
2073
+ };
2074
+ /** 设置扩展消息框样式
2075
+ * option 基础样式选项,格式如:{noTitle:true,close:true,title:{},background:'#FFF'}
2076
+ * noTitle: 是否显示标题栏;
2077
+ * close: 是否显示关闭按钮;
2078
+ * title: 标题栏的css样式对象
2079
+ * background : 除标题栏外的其他部分的颜色
2080
+ * style 位置和大小的配置,格式如:{width:300,height:300,achor:'auto',offsetY:0}
2081
+ * width: 宽度
2082
+ * height:高度
2083
+ * achor:箭头方向,其中值包含 'top','left','right','bottom','auto'
2084
+ * offsetY:Y方向上的偏移
2085
+ **/
2086
+ that.setInfoWindowStyle = function (option, style, id) {
2087
+ scene.fire(
2088
+ msgPrefix + ":setInfoWindowStyle",
2089
+ {
2090
+ args: [option, style, id],
2091
+ },
2092
+ parentScene
2093
+ );
2094
+ };
2095
+
2096
+ /* 要素查询 */
2097
+ that.queryFeature = function (params, callback) {
2098
+ if (scene == null) return;
2099
+ scene.fire(
2100
+ msgPrefix + ":queryFeature",
2101
+ {
2102
+ args: [
2103
+ params.layerID,
2104
+ params.where || null,
2105
+ params.geometry || null,
2106
+ params.outFields,
2107
+ params.outGeometry,
2108
+ params.pointTolorence || 0,
2109
+ params.startIndex,
2110
+ params.maxFeatures,
2111
+ null,
2112
+ callback || null,
2113
+ params.sortBy,
2114
+ params.filterNullGeometry,
2115
+ params.options,
2116
+ params.featureIds,
2117
+ ],
2118
+ },
2119
+ parentScene
2120
+ );
2121
+ };
2122
+
2123
+ /* 显示图层
2124
+ * layerID:图层ID ,
2125
+ * serviceID:服务ID(可选),
2126
+ * showAtBottom:是否显示在最底层(true:显示到最底层,false:显示在最顶层),
2127
+ * zoomLevel:缩放级别(传入数字为缩放到对应的级别,传入true缩放到最大可视级别)
2128
+ */
2129
+ that.showVectorLayer = function (
2130
+ layerID,
2131
+ serviceID,
2132
+ showAtBottom,
2133
+ zoomLevel
2134
+ ) {
2135
+ if (scene == null) return;
2136
+ scene.fire(
2137
+ msgPrefix + ":showVectorLayer",
2138
+ { args: [layerID, serviceID, showAtBottom, zoomLevel] },
2139
+ parentScene
2140
+ );
2141
+ };
2142
+
2143
+ /* 隐藏图层 */
2144
+ that.hideVectorLayer = function (layerID, serviceID) {
2145
+ if (scene == null) return;
2146
+ scene.fire(
2147
+ msgPrefix + ":hideVectorLayer",
2148
+ { args: [layerID, serviceID] },
2149
+ parentScene
2150
+ );
2151
+ };
2152
+
2153
+ /* 获取当前地图范围 */
2154
+ that.getMapExtent = function (callback) {
2155
+ // 移除监听
2156
+ that.removeEventBind("getMapExtentCallback");
2157
+
2158
+ if (callback != undefined) {
2159
+ that.bindEvent("getMapExtentCallback", function (evt) {
2160
+ callback(evt.args);
2161
+ });
2162
+ }
2163
+ scene.fire(msgPrefix + ":getMapExtent", { args: [] }, parentScene);
2164
+ };
2165
+
2166
+ /**查询表信息*/
2167
+ that.queryObjectInfo = function (
2168
+ geoShapes,
2169
+ tableName,
2170
+ xFieldName,
2171
+ yFieldName,
2172
+ callback,
2173
+ usePage,
2174
+ currentPage,
2175
+ numPerPage,
2176
+ params,
2177
+ cacheKey
2178
+ ) {
2179
+ var queryParam = {
2180
+ tableName: tableName,
2181
+ xFieldName: xFieldName,
2182
+ yFieldName: yFieldName,
2183
+ };
2184
+ if (params)
2185
+ queryParam = MapUtils.deepClones(true, {}, queryParam, params);
2186
+
2187
+ that.removeEventBind("queryObjectInfoCallback");
2188
+ that.bindEvent("queryObjectInfoCallback", callback);
2189
+ scene.fire(
2190
+ msgPrefix + ":queryObjectInfo",
2191
+ {
2192
+ args: [
2193
+ JSON.stringify(geoShapes),
2194
+ JSON.stringify(queryParam),
2195
+ usePage,
2196
+ currentPage,
2197
+ numPerPage,
2198
+ cacheKey,
2199
+ ],
2200
+ },
2201
+ parentScene,
2202
+ false
2203
+ );
2204
+ };
2205
+
2206
+ that.enableMapSnap = function (layerID, callback) {
2207
+ if (scene == null) return;
2208
+ if (!layerID) return;
2209
+ that.removeEventBind("enableMapSnapCallback");
2210
+ that.bindEvent("enableMapSnapCallback", callback);
2211
+ scene.fire(
2212
+ msgPrefix + ":enableMapSnap",
2213
+ {
2214
+ args: [layerID],
2215
+ },
2216
+ parentScene
2217
+ );
2218
+ };
2219
+
2220
+ that.disableMapSnap = function (layerID) {
2221
+ if (scene == null) return;
2222
+ if (!layerID) return;
2223
+ scene.fire(
2224
+ msgPrefix + ":disableMapSnap",
2225
+ {
2226
+ args: [layerID],
2227
+ },
2228
+ parentScene
2229
+ );
2230
+ };
2231
+
2232
+ that.addMaskLayer = function (
2233
+ layerID,
2234
+ keyField,
2235
+ values,
2236
+ style,
2237
+ zoom,
2238
+ position
2239
+ ) {
2240
+ scene.fire(
2241
+ msgPrefix + ":addMaskLayer",
2242
+ { args: [layerID, keyField, values, style, zoom, position] },
2243
+ parentScene
2244
+ );
2245
+ };
2246
+
2247
+ /* 计算线、面长度,支持线、面格式 */
2248
+ that.getGeometryLength = function (geometry) {
2249
+ return scene.fire(
2250
+ msgPrefix + ":getGeometryLength",
2251
+ { args: [geometry] },
2252
+ parentScene
2253
+ );
2254
+ };
2255
+
2256
+ /* 计算多边形面积 */
2257
+ that.getPolygonArea = function (geometry) {
2258
+ return scene.fire(
2259
+ msgPrefix + ":getPolygonArea",
2260
+ { args: [geometry] },
2261
+ parentScene
2262
+ );
2263
+ };
2264
+
2265
+ that.intersectGeometry = function (polygon1, polygon2) {
2266
+ return scene.fire(
2267
+ msgPrefix + ":intersectGeometry",
2268
+ { args: [polygon1, polygon2] },
2269
+ parentScene
2270
+ );
2271
+ };
2272
+
2273
+ that.getCenterPoint = function (polygon) {
2274
+ return scene.fire(
2275
+ msgPrefix + ":getCenterPoint",
2276
+ { args: [polygon] },
2277
+ parentScene
2278
+ );
2279
+ };
2280
+
2281
+ /* 根据PointID定位空中全景 */
2282
+ that.mmsAirPanoLocateByID = function (pointID) {
2283
+ if (mmsMap && mmsMap.mmsLoaded) {
2284
+ scene.fire(
2285
+ msgPrefix + ":mmsAirPanoLocateCallback",
2286
+ { args: [pointID] },
2287
+ parentScene
2288
+ );
2289
+ }
2290
+ };
2291
+
2292
+ /* 空中全景历史对比回调 */
2293
+ that.mmsAirPanoCompare = function (callback) {
2294
+ if (mmsMap && mmsMap.mmsLoaded) {
2295
+ scene.fire(
2296
+ msgPrefix + ":mmsAirPanoCompareCallback",
2297
+ { args: [callback] },
2298
+ parentScene
2299
+ );
2300
+ }
2301
+ };
2302
+
2303
+ that.setMMSEyePositionTest = function (x, y) {
2304
+ var pos = { x: x, y: y };
2305
+ var evt = { args: [pos] };
2306
+ mmsMap.setMMSEyePosition(evt);
2307
+ };
2308
+
2309
+ /* 切换地图类型 */
2310
+ that.changeControlParam = function (type, param) {
2311
+ scene.fire(
2312
+ msgPrefix + ":changeControlParam",
2313
+ { args: [type, param] },
2314
+ parentScene
2315
+ );
2316
+ };
2317
+
2318
+ /* 获取图层信息 */
2319
+ that.getPhyLayerInfo = function (phyLayerID, getPhyLayerInfoCallBack) {
2320
+ that.removeEventBind("getPhyLayerInfoCallback");
2321
+ if (getPhyLayerInfoCallBack != undefined) {
2322
+ that.bindEvent("getPhyLayerInfoCallback", function (evt) {
2323
+ getPhyLayerInfoCallBack(evt.args);
2324
+ });
2325
+ }
2326
+ scene.fire(
2327
+ msgPrefix + ":getPhyLayerInfo",
2328
+ { args: [phyLayerID] },
2329
+ parentScene,
2330
+ true
2331
+ );
2332
+ };
2333
+
2334
+ /* 获取图层字段信息 */
2335
+ that.getPhyLayerField = function (phyLayerIDs, getPhyLayerFieldCallback) {
2336
+ that.removeEventBind("getPhyLayerFieldCallback");
2337
+ if (getPhyLayerFieldCallback != undefined) {
2338
+ that.bindEvent("getPhyLayerFieldCallback", function (evt) {
2339
+ getPhyLayerFieldCallback(evt.args);
2340
+ });
2341
+ }
2342
+ scene.fire(
2343
+ msgPrefix + ":getPhyLayerField",
2344
+ { args: [phyLayerIDs] },
2345
+ parentScene,
2346
+ true
2347
+ );
2348
+ };
2349
+
2350
+ /* 获取图层字段信息 */
2351
+ that.getPhyLayerField = function (phyLayerIDs, getPhyLayerFieldCallback) {
2352
+ that.removeEventBind("getPhyLayerFieldCallback");
2353
+ if (getPhyLayerFieldCallback != undefined) {
2354
+ that.bindEvent("getPhyLayerFieldCallback", function (evt) {
2355
+ getPhyLayerFieldCallback(evt.args);
2356
+ });
2357
+ }
2358
+ scene.fire(
2359
+ msgPrefix + ":getPhyLayerField",
2360
+ { args: [phyLayerIDs] },
2361
+ parentScene,
2362
+ true
2363
+ );
2364
+ };
2365
+
2366
+ /*对几何图形进行缓冲*/
2367
+ that.getGeometryBuffer = function (
2368
+ geometry,
2369
+ radius,
2370
+ callback,
2371
+ autoTransRadius
2372
+ ) {
2373
+ that.removeEventBind("getGeometryBufferCallback");
2374
+ if (callback != undefined) {
2375
+ that.bindEvent("getGeometryBufferCallback", function (evt) {
2376
+ callback(evt.args);
2377
+ });
2378
+ }
2379
+ scene.fire(
2380
+ msgPrefix + ":getGeometryBuffer",
2381
+ { args: [geometry, radius, autoTransRadius] },
2382
+ parentScene,
2383
+ true
2384
+ );
2385
+ };
2386
+
2387
+ /* 移除图层*/
2388
+ that.removeLayer = function (layerName) {
2389
+ scene.fire(
2390
+ msgPrefix + ":removeLayer",
2391
+ { args: [layerName] },
2392
+ parentScene,
2393
+ true
2394
+ );
2395
+ };
2396
+
2397
+ that.change3dlayerUsageConfig = function () {
2398
+ if (scene == null) return;
2399
+ var config = scene.layerUsageConfig;
2400
+ scene.fire(
2401
+ msgPrefix + ":change3dlayerUsageConfig",
2402
+ { args: [config] },
2403
+ parentScene
2404
+ );
2405
+ };
2406
+ /*显示多轨迹*/
2407
+ that.showTraceMultiHisLayer = function (
2408
+ objectIDs,
2409
+ symbolType,
2410
+ beginDate,
2411
+ endDate,
2412
+ clear,
2413
+ zoom,
2414
+ hStyle
2415
+ ) {
2416
+ scene.fire(
2417
+ msgPrefix + ":showTraceMultiHisLayer",
2418
+ {
2419
+ args: [
2420
+ objectIDs,
2421
+ symbolType,
2422
+ beginDate,
2423
+ endDate,
2424
+ clear,
2425
+ zoom,
2426
+ hStyle,
2427
+ ],
2428
+ },
2429
+ parentScene
2430
+ );
2431
+ };
2432
+ /*清除多轨迹*/
2433
+ that.claerTraceMultiHisLayer = function () {
2434
+ scene.fire(
2435
+ msgPrefix + ":claerTraceMultiHisLayer",
2436
+ { args: [] },
2437
+ parentScene
2438
+ );
2439
+ };
2440
+ /*多人员图标通过id高亮*/
2441
+ that.multiPointsSelectbyID = function (id) {
2442
+ scene.fire(
2443
+ msgPrefix + ":multiPointsSelectbyID",
2444
+ { args: [id] },
2445
+ parentScene
2446
+ );
2447
+ };
2448
+ /*多轨迹通过id高亮*/
2449
+ that.traceMultiSelectbyID = function (id) {
2450
+ scene.fire(
2451
+ msgPrefix + ":traceMultiSelectbyID",
2452
+ { args: [id] },
2453
+ parentScene
2454
+ );
2455
+ };
2456
+
2457
+ // arcgis格式geometry转wkt格式
2458
+ that.agsToWKT = function (geometry, callback) {
2459
+ scene.fire(
2460
+ msgPrefix + ":agsToWKT",
2461
+ { args: [geometry, callback] },
2462
+ parentScene
2463
+ );
2464
+ };
2465
+ /*网格化方式绘制管线*/
2466
+ that.showCustomGrid = function (jsonInfo, region) {
2467
+ scene.fire(
2468
+ msgPrefix + ":showCustomGrid",
2469
+ { args: [jsonInfo, region] },
2470
+ parentScene
2471
+ );
2472
+ };
2473
+
2474
+ /*网格化方式清除管线*/
2475
+ that.clearCustomGrid = function () {
2476
+ scene.fire(msgPrefix + ":clearCustomGrid", { args: [] }, parentScene);
2477
+ };
2478
+
2479
+ /**
2480
+ * 开始测量
2481
+ * @param {*} options {type:'area'|'length'; callBack:绘制完成回调函数;errorCallBack:错误回调函数;}
2482
+ */
2483
+ that.startMeasure = function (options) {
2484
+ if (scene == null) return;
2485
+ scene.fire(
2486
+ msgPrefix + ":startMeasure",
2487
+ { args: [options] },
2488
+ parentScene,
2489
+ false
2490
+ );
2491
+ };
2492
+
2493
+ // 结束测量
2494
+ that.stopMeasure = function () {
2495
+ if (scene == null) return;
2496
+ scene.fire(
2497
+ msgPrefix + ":stopMeasure",
2498
+ { args: [] },
2499
+ parentScene,
2500
+ false
2501
+ );
2502
+ };
2503
+
2504
+ that.mouseMoveEvent = function (callback) {
2505
+ if (scene == null) return;
2506
+ scene.fire(
2507
+ msgPrefix + ":mouseMoveEvent",
2508
+ { args: [callback] },
2509
+ parentScene,
2510
+ false
2511
+ );
2512
+ };
2513
+
2514
+ that.init();
2515
+ };
2516
+ export default EGovaGISMap;