cd-mapgis 1.1.3 → 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 +1 -1
- package/src/LineLayer.js +14 -2
- package/src/PointLayer.js +15 -2
package/package.json
CHANGED
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,8 +84,18 @@ export default class LineLayer {
|
|
|
82
84
|
* 缩放到本图层显示范围
|
|
83
85
|
*/
|
|
84
86
|
fitToLayer(){
|
|
85
|
-
const map = this.map;
|
|
86
|
-
|
|
87
|
+
const map = this.map;
|
|
88
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
89
|
+
this.features.forEach(f => {
|
|
90
|
+
const coord = f.getGeometry().getCoordinates();
|
|
91
|
+
minX = Math.min(minX, coord[0]);
|
|
92
|
+
minY = Math.min(minY, coord[1]);
|
|
93
|
+
maxX = Math.max(maxX, coord[0]);
|
|
94
|
+
maxY = Math.max(maxY, coord[1]);
|
|
95
|
+
});
|
|
96
|
+
const manualExtent = [minX, minY, maxX, maxY];
|
|
97
|
+
console.log('手动计算 extent:', manualExtent);
|
|
98
|
+
map.getView().fit(manualExtent, {
|
|
87
99
|
size: map.getSize(),
|
|
88
100
|
maxZoom: 16,
|
|
89
101
|
duration: 1000
|
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,8 +88,19 @@ export default class PointLayer {
|
|
|
86
88
|
* 缩放到本图层显示范围
|
|
87
89
|
*/
|
|
88
90
|
fitToLayer() {
|
|
89
|
-
const map = this.map;
|
|
90
|
-
|
|
91
|
+
const map = this.map;
|
|
92
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
93
|
+
this.features.forEach(f => {
|
|
94
|
+
const coord = f.getGeometry().getCoordinates();
|
|
95
|
+
minX = Math.min(minX, coord[0]);
|
|
96
|
+
minY = Math.min(minY, coord[1]);
|
|
97
|
+
maxX = Math.max(maxX, coord[0]);
|
|
98
|
+
maxY = Math.max(maxY, coord[1]);
|
|
99
|
+
});
|
|
100
|
+
const manualExtent = [minX, minY, maxX, maxY];
|
|
101
|
+
console.log('features:', this.features);
|
|
102
|
+
console.log('手动计算 extent:', manualExtent);
|
|
103
|
+
map.getView().fit(manualExtent, {
|
|
91
104
|
size: map.getSize(),
|
|
92
105
|
maxZoom: 16,
|
|
93
106
|
duration: 1000
|