cd-mapgis 1.0.48 → 1.0.50
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 +27 -1
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;
|
|
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
|
@@ -21,7 +21,7 @@ export default class OM {
|
|
|
21
21
|
}
|
|
22
22
|
static _getParams() {
|
|
23
23
|
let paramsStr = sessionStorage.getItem("map-params");
|
|
24
|
-
return
|
|
24
|
+
return JSON.parse(paramsStr);
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* post请求
|
|
@@ -112,6 +112,23 @@ export default class OM {
|
|
|
112
112
|
static getAddressByPoint(p) {
|
|
113
113
|
return OM.post("/map/getAddressByPoint", p);
|
|
114
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* 获取字段列表
|
|
117
|
+
* @param {*} p {tableName}
|
|
118
|
+
* @returns
|
|
119
|
+
*/
|
|
120
|
+
static getFields(p) {
|
|
121
|
+
return OM.post("/map/getFields", p);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* 导出图层属性表
|
|
125
|
+
* @param {*} p {tableName}
|
|
126
|
+
* @returns
|
|
127
|
+
*/
|
|
128
|
+
static exportLayerAttr(p) {
|
|
129
|
+
let params = OM._getParams();
|
|
130
|
+
window.open(params.geoServer + "/map/exportLayerAttr?tableName=" + p.tableName);
|
|
131
|
+
}
|
|
115
132
|
/**
|
|
116
133
|
* 向地图视图添加图层
|
|
117
134
|
* @param {*} p {mapViews(单个对象或者数组),geoLayers(geoServer固定图层),server(url,data,sort,layerCall)}
|
|
@@ -120,6 +137,15 @@ export default class OM {
|
|
|
120
137
|
let params = OM._getParams();
|
|
121
138
|
let layerHost = params.layerHost ? params.layerHost : {};
|
|
122
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
|
+
}
|
|
123
149
|
//先加载后端默认加载的图层
|
|
124
150
|
let postRes = await OM.getDic("def_view_layers");
|
|
125
151
|
let defViewLayers = postRes.data ? JSON.parse(postRes.data) : [];
|