cd-mapgis 1.0.59 → 1.0.61

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cd-mapgis",
3
- "version": "1.0.59",
3
+ "version": "1.0.61",
4
4
  "main": "./src/index.js",
5
5
  "types": "./src/index.d.ts",
6
6
  "type": "module",
package/src/LayerUtil.js CHANGED
@@ -12,6 +12,7 @@ import Feature from 'ol/Feature.js';
12
12
  import VectorSource from 'ol/source/Vector.js';
13
13
  import VectorLayer from 'ol/layer/Vector.js';
14
14
  import StyleUtil from './StyleUtil.js';
15
+ import LineString from 'ol/geom/LineString.js';
15
16
 
16
17
  /**
17
18
  * 图层工具
@@ -205,15 +206,30 @@ export default class LayerUtil {
205
206
  });
206
207
  return { layer: layer, geometry: geometry };
207
208
  }
209
+ /**
210
+ * [[116.4074, 39.9042], [121.4737, 31.2304]]
211
+ * @param {*} p
212
+ */
213
+ static getTracePointsLayer(p) {
214
+ let coordinates = JSON.parse(p.data);
215
+ let geometry = new LineString(coordinates);
216
+ let feature = new Feature({ geometry: geometry });
217
+ let vectorSource = new VectorSource({ features: [feature] });
218
+ let layer = new VectorLayer({
219
+ source: vectorSource,
220
+ style: p.style
221
+ });
222
+ return { layer: layer, geometry: geometry };
223
+ }
208
224
  /**
209
225
  * 将geoJson的点集合数据包装为一个图层
210
226
  * @param {*} p {geoList:[],img:{url,anchor},text:{str,font,color,offsetY}}
211
227
  */
212
- static getJsonPointsLayer(p) {
228
+ static getJsonPointsLayer(p) {
213
229
  let geoJSON = new GeoJSON();
214
230
  let features = [];
215
231
  for (let i = 0; i < p.geoList.length; i++) {
216
- let geo = p.geoList[i];
232
+ let geo = p.geoList[i];
217
233
  var f = new Feature({
218
234
  geometry: geoJSON.readGeometry(geo.json)
219
235
  });
@@ -223,7 +239,7 @@ export default class LayerUtil {
223
239
  }
224
240
  f.setStyle(StyleUtil.getPointStyle(p));
225
241
  features.push(f);
226
- }
242
+ }
227
243
  let vectorSource = new VectorSource({ features: features });
228
244
  return new VectorLayer({
229
245
  source: vectorSource
@@ -233,11 +249,11 @@ export default class LayerUtil {
233
249
  * 将geoJson的多边形集合数据包装为一个图层
234
250
  * @param {*} p {geoList:[],style:{fillColor,lineColor,lineWidth},text:{str,font,color}}
235
251
  */
236
- static getJsonPolygonsLayer(p) {
252
+ static getJsonPolygonsLayer(p) {
237
253
  let geoJSON = new GeoJSON();
238
254
  let features = [];
239
255
  for (let i = 0; i < p.geoList.length; i++) {
240
- let geo = p.geoList[i];
256
+ let geo = p.geoList[i];
241
257
  var f = new Feature({
242
258
  geometry: geoJSON.readGeometry(geo.json)
243
259
  });
@@ -247,7 +263,7 @@ export default class LayerUtil {
247
263
  }
248
264
  f.setStyle(StyleUtil.getPolygonStyle(p));
249
265
  features.push(f);
250
- }
266
+ }
251
267
  let vectorSource = new VectorSource({ features: features });
252
268
  return new VectorLayer({
253
269
  source: vectorSource
package/src/MapView.js CHANGED
@@ -80,7 +80,14 @@ export default class MapView {
80
80
  this.clearTemplayer(); //移除之前的显示
81
81
  p.style = StyleUtil.getViewOnTemplayerStyle();
82
82
  //重建图层,避免在其他地方全部移除图层后,templayer不为空,但是已经不在地图中的情况
83
- let res = LayerUtil.getJsonLayer(p);
83
+ let res;
84
+ if (p.type == 'jsonPoints') {
85
+ res = LayerUtil.getJsonPointsLayer(p);
86
+ } else if(p.type == 'tracePoints'){
87
+ res = LayerUtil.getTracePointsLayer(p);
88
+ }else {
89
+ res = LayerUtil.getJsonLayer(p);
90
+ }
84
91
  this._view_templayer = res.layer;
85
92
  this.map.addLayer(this._view_templayer);// 添加到地图
86
93
  // fit方法 - 自动适应范围