egovamap 0.35.67 → 0.35.69
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.
- package/egovamap/egovagisviewer.js +90 -1
- package/egovamap/egovamap.js +34 -13
- package/package.json +1 -1
|
@@ -91,6 +91,10 @@ var EGovaGISMap = function (
|
|
|
91
91
|
that.gisVisible = false;
|
|
92
92
|
that.gisLoaded = false;
|
|
93
93
|
that.isLoading = false;
|
|
94
|
+
that._boundGlobalCallback = null;
|
|
95
|
+
that._viewerScript = null;
|
|
96
|
+
that._viewerLink = null;
|
|
97
|
+
that._handleViewerScriptLoad = null;
|
|
94
98
|
|
|
95
99
|
//that.$gisMapFrame = null;
|
|
96
100
|
that.gisMapContainer = null;
|
|
@@ -389,6 +393,7 @@ var EGovaGISMap = function (
|
|
|
389
393
|
mainLink.setAttribute("href", cssUrl);
|
|
390
394
|
mainLink.setAttribute("rel", "stylesheet");
|
|
391
395
|
document.getElementsByTagName("head").item(0).appendChild(mainLink);
|
|
396
|
+
that._viewerLink = mainLink;
|
|
392
397
|
|
|
393
398
|
var url =
|
|
394
399
|
gisServerURL +
|
|
@@ -406,7 +411,11 @@ var EGovaGISMap = function (
|
|
|
406
411
|
if(context.initJSAsync) { // 初始化JS是否同步加载
|
|
407
412
|
mainScript.setAttribute("async", false);
|
|
408
413
|
}
|
|
409
|
-
|
|
414
|
+
that._handleViewerScriptLoad = function () {
|
|
415
|
+
return that.createMap();
|
|
416
|
+
};
|
|
417
|
+
mainScript.onload = that._handleViewerScriptLoad;
|
|
418
|
+
that._viewerScript = mainScript;
|
|
410
419
|
document.getElementsByTagName("head").item(0).appendChild(mainScript);
|
|
411
420
|
};
|
|
412
421
|
|
|
@@ -2608,7 +2617,47 @@ var EGovaGISMap = function (
|
|
|
2608
2617
|
};
|
|
2609
2618
|
|
|
2610
2619
|
that.destroyMap = function () {
|
|
2620
|
+
var currentMap = window.eMapList && window.eMapList[that.id];
|
|
2611
2621
|
that.callMap("destroyMap");
|
|
2622
|
+
if (that._viewerScript) {
|
|
2623
|
+
that._viewerScript.onload = null;
|
|
2624
|
+
that._viewerScript.onerror = null;
|
|
2625
|
+
that._viewerScript.remove();
|
|
2626
|
+
that._viewerScript = null;
|
|
2627
|
+
}
|
|
2628
|
+
if (that._viewerLink) {
|
|
2629
|
+
that._viewerLink.remove();
|
|
2630
|
+
that._viewerLink = null;
|
|
2631
|
+
}
|
|
2632
|
+
if (window.eMapList && window.eMapList[that.id]) {
|
|
2633
|
+
window.eMapList[that.id] = null;
|
|
2634
|
+
delete window.eMapList[that.id];
|
|
2635
|
+
}
|
|
2636
|
+
if (currentMap && currentMap.egovagis) {
|
|
2637
|
+
currentMap.egovagis.fireCallback = null;
|
|
2638
|
+
currentMap.egovagis.fireErrorCallback = null;
|
|
2639
|
+
currentMap.egovagis.reconfigMap = null;
|
|
2640
|
+
currentMap.egovagis.eMap = null;
|
|
2641
|
+
currentMap.egovagis.global = null;
|
|
2642
|
+
currentMap.egovagis.sysConfig = null;
|
|
2643
|
+
}
|
|
2644
|
+
if (that.callbackList) {
|
|
2645
|
+
Object.keys(that.callbackList).forEach(function (key) {
|
|
2646
|
+
that.callbackList[key] = null;
|
|
2647
|
+
delete that.callbackList[key];
|
|
2648
|
+
});
|
|
2649
|
+
}
|
|
2650
|
+
if (that.onMapLoadedHandlers) {
|
|
2651
|
+
that.onMapLoadedHandlers.length = 0;
|
|
2652
|
+
}
|
|
2653
|
+
that._handleViewerScriptLoad = null;
|
|
2654
|
+
that._boundGlobalCallback = null;
|
|
2655
|
+
that.globalCallback = function () {};
|
|
2656
|
+
that.fireCallback = function () {};
|
|
2657
|
+
that.gisMapContainer = null;
|
|
2658
|
+
that.globeMapContainer = null;
|
|
2659
|
+
that.gisLoaded = false;
|
|
2660
|
+
that.isLoading = false;
|
|
2612
2661
|
};
|
|
2613
2662
|
|
|
2614
2663
|
that.switchGisMapType = function (type, callback) {
|
|
@@ -2853,7 +2902,47 @@ var EGovaGISMap = function (
|
|
|
2853
2902
|
}
|
|
2854
2903
|
|
|
2855
2904
|
that.destroyMap = function () {
|
|
2905
|
+
var currentMap = window.eMapList && window.eMapList[that.id];
|
|
2856
2906
|
that.callMap("destroyMap");
|
|
2907
|
+
if (that._viewerScript) {
|
|
2908
|
+
that._viewerScript.onload = null;
|
|
2909
|
+
that._viewerScript.onerror = null;
|
|
2910
|
+
that._viewerScript.remove();
|
|
2911
|
+
that._viewerScript = null;
|
|
2912
|
+
}
|
|
2913
|
+
if (that._viewerLink) {
|
|
2914
|
+
that._viewerLink.remove();
|
|
2915
|
+
that._viewerLink = null;
|
|
2916
|
+
}
|
|
2917
|
+
if (window.eMapList && window.eMapList[that.id]) {
|
|
2918
|
+
window.eMapList[that.id] = null;
|
|
2919
|
+
delete window.eMapList[that.id];
|
|
2920
|
+
}
|
|
2921
|
+
if (currentMap && currentMap.egovagis) {
|
|
2922
|
+
currentMap.egovagis.fireCallback = null;
|
|
2923
|
+
currentMap.egovagis.fireErrorCallback = null;
|
|
2924
|
+
currentMap.egovagis.reconfigMap = null;
|
|
2925
|
+
currentMap.egovagis.eMap = null;
|
|
2926
|
+
currentMap.egovagis.global = null;
|
|
2927
|
+
currentMap.egovagis.sysConfig = null;
|
|
2928
|
+
}
|
|
2929
|
+
if (that.callbackList) {
|
|
2930
|
+
Object.keys(that.callbackList).forEach(function (key) {
|
|
2931
|
+
that.callbackList[key] = null;
|
|
2932
|
+
delete that.callbackList[key];
|
|
2933
|
+
});
|
|
2934
|
+
}
|
|
2935
|
+
if (that.onMapLoadedHandlers) {
|
|
2936
|
+
that.onMapLoadedHandlers.length = 0;
|
|
2937
|
+
}
|
|
2938
|
+
that._handleViewerScriptLoad = null;
|
|
2939
|
+
that._boundGlobalCallback = null;
|
|
2940
|
+
that.globalCallback = function () {};
|
|
2941
|
+
that.fireCallback = function () {};
|
|
2942
|
+
that.gisMapContainer = null;
|
|
2943
|
+
that.globeMapContainer = null;
|
|
2944
|
+
that.gisLoaded = false;
|
|
2945
|
+
that.isLoading = false;
|
|
2857
2946
|
}
|
|
2858
2947
|
|
|
2859
2948
|
that.pointInPolygon = function (point, polygon, callback) {
|
package/egovamap/egovamap.js
CHANGED
|
@@ -47,6 +47,31 @@ function getMapContainer(container) {
|
|
|
47
47
|
}
|
|
48
48
|
return result;
|
|
49
49
|
}
|
|
50
|
+
|
|
51
|
+
function ensureCanvasGetContextPatched() {
|
|
52
|
+
if (typeof HTMLCanvasElement === 'undefined') {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
var canvasProto = HTMLCanvasElement.prototype;
|
|
57
|
+
if (canvasProto.__egovamapGetContextPatched) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
var originalGetContext =
|
|
62
|
+
canvasProto.__egovamapOriginalGetContext || canvasProto.getContext;
|
|
63
|
+
canvasProto.__egovamapOriginalGetContext = originalGetContext;
|
|
64
|
+
canvasProto.getContext = function (type, attributes) {
|
|
65
|
+
if (type === 'webgl') {
|
|
66
|
+
attributes = Object.assign({}, attributes, {
|
|
67
|
+
preserveDrawingBuffer: true,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return originalGetContext.call(this, type, attributes);
|
|
71
|
+
};
|
|
72
|
+
canvasProto.__egovamapGetContextPatched = true;
|
|
73
|
+
}
|
|
74
|
+
|
|
50
75
|
var EGovaMap = function (
|
|
51
76
|
containerID,
|
|
52
77
|
callback,
|
|
@@ -55,6 +80,7 @@ var EGovaMap = function (
|
|
|
55
80
|
mapParam,
|
|
56
81
|
context
|
|
57
82
|
) {
|
|
83
|
+
ensureCanvasGetContextPatched();
|
|
58
84
|
context &&
|
|
59
85
|
!context.assetsPath &&
|
|
60
86
|
(context.assetsPath = '/library/urban/egovamap');
|
|
@@ -5577,6 +5603,7 @@ var EGovaMap = function (
|
|
|
5577
5603
|
if (scene == null) return;
|
|
5578
5604
|
if (gisMap && gisMap.destroyMap) {
|
|
5579
5605
|
gisMap.destroyMap();
|
|
5606
|
+
gisMap = null;
|
|
5580
5607
|
}
|
|
5581
5608
|
};
|
|
5582
5609
|
|
|
@@ -5742,17 +5769,6 @@ var EGovaMap = function (
|
|
|
5742
5769
|
EGovaBI.call(this, globeMap, gisMap, mapType);
|
|
5743
5770
|
gisMobileMap && EgovamapMEx.call(this, gisMobileMap);
|
|
5744
5771
|
|
|
5745
|
-
//解决html2canvas截图空白问题
|
|
5746
|
-
HTMLCanvasElement.prototype.getContext = (function (origFn) {
|
|
5747
|
-
return function (type, attributes) {
|
|
5748
|
-
if (type === 'webgl') {
|
|
5749
|
-
attributes = Object.assign({}, attributes, {
|
|
5750
|
-
preserveDrawingBuffer: true,
|
|
5751
|
-
});
|
|
5752
|
-
}
|
|
5753
|
-
return origFn.call(this, type, attributes);
|
|
5754
|
-
};
|
|
5755
|
-
})(HTMLCanvasElement.prototype.getContext);
|
|
5756
5772
|
};
|
|
5757
5773
|
|
|
5758
5774
|
var EGovaMapUtils = {
|
|
@@ -5805,6 +5821,7 @@ var EGovaMapUtils = {
|
|
|
5805
5821
|
for (var i = mapArray.length - 1; i >= 0; i--) {
|
|
5806
5822
|
if (mapArray[i] === mapList[uniqueID]) {
|
|
5807
5823
|
mapArray[i].destroyMap();
|
|
5824
|
+
mapArray[i] = null;
|
|
5808
5825
|
delete mapArray[i];
|
|
5809
5826
|
break;
|
|
5810
5827
|
}
|
|
@@ -5825,12 +5842,16 @@ var EGovaMapUtils = {
|
|
|
5825
5842
|
}
|
|
5826
5843
|
}
|
|
5827
5844
|
}
|
|
5828
|
-
|
|
5829
5845
|
if(window && window.eMapList){
|
|
5830
|
-
const mapId = uniqueID+ '
|
|
5846
|
+
const mapId = uniqueID+ '_gis_emap';
|
|
5831
5847
|
if(window.eMapList[mapId]){
|
|
5848
|
+
window.eMapList[mapId] = null;
|
|
5832
5849
|
delete window.eMapList[mapId];
|
|
5833
5850
|
}
|
|
5851
|
+
if(window[mapId]){
|
|
5852
|
+
window[mapId] = null;
|
|
5853
|
+
delete window[mapId];
|
|
5854
|
+
}
|
|
5834
5855
|
}
|
|
5835
5856
|
},
|
|
5836
5857
|
};
|