cd-mapgis 1.1.4 → 1.1.5

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.1.4",
3
+ "version": "1.1.5",
4
4
  "main": "./src/index.js",
5
5
  "types": "./src/index.d.ts",
6
6
  "type": "module",
package/src/LineLayer.js CHANGED
@@ -15,6 +15,7 @@ export default class LineLayer {
15
15
  this.vectorLayer = new VectorLayer({
16
16
  source: this.vectorSource
17
17
  });
18
+ this.features = [];
18
19
  this.mapView = p.mapView ? p.mapView : MapView.Instance;
19
20
  this.map = this.mapView.map;
20
21
  this.map.addLayer(this.vectorLayer);
@@ -48,6 +49,7 @@ export default class LineLayer {
48
49
  })
49
50
  }));
50
51
  feature.set('attr', p.attr);
52
+ this.features.push(feature);
51
53
  return feature;
52
54
  }
53
55
  /**
@@ -82,10 +84,9 @@ export default class LineLayer {
82
84
  * 缩放到本图层显示范围
83
85
  */
84
86
  fitToLayer(){
85
- const map = this.map;
86
- const features = this.vectorSource.getFeatures();
87
+ const map = this.map;
87
88
  let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
88
- features.forEach(f => {
89
+ this.features.forEach(f => {
89
90
  const coord = f.getGeometry().getCoordinates();
90
91
  minX = Math.min(minX, coord[0]);
91
92
  minY = Math.min(minY, coord[1]);
package/src/PointLayer.js CHANGED
@@ -15,6 +15,7 @@ export default class PointLayer {
15
15
  this.vectorLayer = new VectorLayer({
16
16
  source: this.vectorSource
17
17
  });
18
+ this.features = [];
18
19
  this.mapView = p.mapView ? p.mapView : MapView.Instance;
19
20
  this.map = this.mapView.map;
20
21
  this.map.addLayer(this.vectorLayer);
@@ -52,6 +53,7 @@ export default class PointLayer {
52
53
  })
53
54
  }));
54
55
  feature.set('attr', p.attr);
56
+ this.features.push(feature);
55
57
  return feature;
56
58
  }
57
59
  /**
@@ -86,10 +88,9 @@ export default class PointLayer {
86
88
  * 缩放到本图层显示范围
87
89
  */
88
90
  fitToLayer() {
89
- const map = this.map;
90
- const features = this.vectorSource.getFeatures();
91
+ const map = this.map;
91
92
  let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
92
- features.forEach(f => {
93
+ this.features.forEach(f => {
93
94
  const coord = f.getGeometry().getCoordinates();
94
95
  minX = Math.min(minX, coord[0]);
95
96
  minY = Math.min(minY, coord[1]);
@@ -97,6 +98,7 @@ export default class PointLayer {
97
98
  maxY = Math.max(maxY, coord[1]);
98
99
  });
99
100
  const manualExtent = [minX, minY, maxX, maxY];
101
+ console.log('features:', this.features);
100
102
  console.log('手动计算 extent:', manualExtent);
101
103
  map.getView().fit(manualExtent, {
102
104
  size: map.getSize(),