cd-mapgis 1.0.49 → 1.0.51
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/package.json +1 -1
- package/src/HttpUtil.js +9 -1
- package/src/OM.js +9 -0
package/package.json
CHANGED
package/src/HttpUtil.js
CHANGED
|
@@ -12,6 +12,10 @@ export default class httpUtil {
|
|
|
12
12
|
}
|
|
13
13
|
return xhr;
|
|
14
14
|
}
|
|
15
|
+
static _getParams() {
|
|
16
|
+
let paramsStr = sessionStorage.getItem("map-params");
|
|
17
|
+
return JSON.parse(paramsStr);
|
|
18
|
+
}
|
|
15
19
|
/**
|
|
16
20
|
* get请求
|
|
17
21
|
* @param {*} url
|
|
@@ -46,6 +50,8 @@ export default class httpUtil {
|
|
|
46
50
|
* @param {*} headers
|
|
47
51
|
*/
|
|
48
52
|
static post(url, data, headers) {
|
|
53
|
+
let p = httpUtil._getParams();
|
|
54
|
+
let debug = p.debug ? p.debug : false;
|
|
49
55
|
return new Promise((resolve, reject) => {
|
|
50
56
|
data = data || {};
|
|
51
57
|
let xhr = httpUtil._getUtil();
|
|
@@ -60,7 +66,9 @@ export default class httpUtil {
|
|
|
60
66
|
xhr.onreadystatechange = function () {
|
|
61
67
|
if (xhr.status === 200) {
|
|
62
68
|
if (xhr.readyState == 4) {
|
|
63
|
-
|
|
69
|
+
if (debug) {
|
|
70
|
+
console.log(url, data, xhr.responseText);
|
|
71
|
+
}
|
|
64
72
|
resolve(xhr.responseText)
|
|
65
73
|
}
|
|
66
74
|
} else {
|
package/src/OM.js
CHANGED
|
@@ -137,6 +137,15 @@ export default class OM {
|
|
|
137
137
|
let params = OM._getParams();
|
|
138
138
|
let layerHost = params.layerHost ? params.layerHost : {};
|
|
139
139
|
let mapViews = p.mapViews ? (p.mapViews.length ? p.mapViews : [p.mapViews]) : [MapView.Instance];
|
|
140
|
+
//清除之前的图层
|
|
141
|
+
for (let k = 0; k < mapViews.length; k++) {
|
|
142
|
+
let mapView = mapViews[k];
|
|
143
|
+
let map = mapView.map;
|
|
144
|
+
let layers = map.getLayers();
|
|
145
|
+
layers.forEach(function (layer) {
|
|
146
|
+
map.removeLayer(layer); // 移除每个图层
|
|
147
|
+
});
|
|
148
|
+
}
|
|
140
149
|
//先加载后端默认加载的图层
|
|
141
150
|
let postRes = await OM.getDic("def_view_layers");
|
|
142
151
|
let defViewLayers = postRes.data ? JSON.parse(postRes.data) : [];
|