cd-mapgis 1.1.18 → 1.1.20

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/OM.js +31 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cd-mapgis",
3
- "version": "1.1.18",
3
+ "version": "1.1.20",
4
4
  "main": "./src/index.js",
5
5
  "types": "./src/index.d.ts",
6
6
  "type": "module",
package/src/OM.js CHANGED
@@ -39,9 +39,9 @@ export default class OM {
39
39
  static getIp(text) {
40
40
  const ipv4Regex = /\b(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/;
41
41
  const ipv4Matches = text.match(ipv4Regex) || [];
42
- if(ipv4Matches.length > 0){
42
+ if (ipv4Matches.length > 0) {
43
43
  return ipv4Matches[0];
44
- }else{
44
+ } else {
45
45
  return '';
46
46
  }
47
47
  }
@@ -50,8 +50,8 @@ export default class OM {
50
50
  * @param {*} key
51
51
  */
52
52
  static getDic(key) {
53
- console.log('window.location.hostname',window.location.hostname);
54
- console.log('window.location.href',window.location.href);
53
+ console.log('window.location.hostname', window.location.hostname);
54
+ console.log('window.location.href', window.location.href);
55
55
  const hostname = OM.getIp(window.location.href);
56
56
  return OM.post("/map/getDic", { dicKey: key, clientIp: hostname });
57
57
  }
@@ -235,6 +235,33 @@ export default class OM {
235
235
  //
236
236
  mapView.viewLayers.push({ type: 'def', name: obj.name, layer: obj.layer });
237
237
  }
238
+ //直接加载固定的geoServer图层
239
+ if (p.geoLayers && p.geoLayers.length > 0) {
240
+ postRes = await OM.getDic("geoserver");
241
+ if (!postRes.data) {
242
+ throw new Error("未配置geoserver");
243
+ }
244
+ let geoserverDic = JSON.parse(postRes.data);
245
+ let wmsUrl = geoserverDic.url + '/' + geoserverDic.workspace + '/wms';
246
+ wmsUrl = InnerUtil.getGeoServerUrl(wmsUrl, geoLayerUrl);
247
+ let geoParam = { workspace: geoserverDic.workspace, url: wmsUrl };
248
+ let _layers = [];
249
+ let layerNames = {};
250
+ for (let i = 0; i < p.geoLayers.length; i++) {
251
+ let l = p.geoLayers[i];
252
+ _layers.push(l.layerName);
253
+ layerNames[l.layerName] = l.title;
254
+ }
255
+ postRes = await OM.checkPushLayers({ layers: _layers });
256
+ let pushLayers = postRes.data ? postRes.data : [];
257
+ for (let i = 0; i < pushLayers.length; i++) {
258
+ geoParam.name = pushLayers[i];
259
+ let layer = LayerUtil.geoServerWmsLayer(geoParam);
260
+ map.addLayer(layer);
261
+ mapView.viewLayers.push({ type: 'geoLayer', name: layerNames[geoParam.name], layer: layer });
262
+ mapView.geoServerLayers.push(geoParam.name);
263
+ }
264
+ }
238
265
  //再加载geoServer接口图层
239
266
  let param = p.param ? p.param : {};
240
267
  let res = await OM.post("/map/getPushLayer", param);