cd-mapgis 1.1.4 → 1.1.6
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 +2 -14
- package/src/PointLayer.js +4 -16
package/package.json
CHANGED
package/src/LineLayer.js
CHANGED
|
@@ -83,21 +83,9 @@ export default class LineLayer {
|
|
|
83
83
|
*/
|
|
84
84
|
fitToLayer(){
|
|
85
85
|
const map = this.map;
|
|
86
|
-
|
|
87
|
-
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
88
|
-
features.forEach(f => {
|
|
89
|
-
const coord = f.getGeometry().getCoordinates();
|
|
90
|
-
minX = Math.min(minX, coord[0]);
|
|
91
|
-
minY = Math.min(minY, coord[1]);
|
|
92
|
-
maxX = Math.max(maxX, coord[0]);
|
|
93
|
-
maxY = Math.max(maxY, coord[1]);
|
|
94
|
-
});
|
|
95
|
-
const manualExtent = [minX, minY, maxX, maxY];
|
|
96
|
-
console.log('手动计算 extent:', manualExtent);
|
|
97
|
-
map.getView().fit(manualExtent, {
|
|
86
|
+
map.getView().fit(this.vectorSource.getExtent(), {
|
|
98
87
|
size: map.getSize(),
|
|
99
|
-
maxZoom:
|
|
100
|
-
duration: 1000
|
|
88
|
+
maxZoom: 18
|
|
101
89
|
})
|
|
102
90
|
}
|
|
103
91
|
}
|
package/src/PointLayer.js
CHANGED
|
@@ -14,7 +14,7 @@ export default class PointLayer {
|
|
|
14
14
|
this.vectorSource = new VectorSource();
|
|
15
15
|
this.vectorLayer = new VectorLayer({
|
|
16
16
|
source: this.vectorSource
|
|
17
|
-
});
|
|
17
|
+
});
|
|
18
18
|
this.mapView = p.mapView ? p.mapView : MapView.Instance;
|
|
19
19
|
this.map = this.mapView.map;
|
|
20
20
|
this.map.addLayer(this.vectorLayer);
|
|
@@ -51,7 +51,7 @@ export default class PointLayer {
|
|
|
51
51
|
anchorYUnits: 'fraction'
|
|
52
52
|
})
|
|
53
53
|
}));
|
|
54
|
-
feature.set('attr', p.attr);
|
|
54
|
+
feature.set('attr', p.attr);
|
|
55
55
|
return feature;
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
@@ -87,21 +87,9 @@ export default class PointLayer {
|
|
|
87
87
|
*/
|
|
88
88
|
fitToLayer() {
|
|
89
89
|
const map = this.map;
|
|
90
|
-
|
|
91
|
-
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
92
|
-
features.forEach(f => {
|
|
93
|
-
const coord = f.getGeometry().getCoordinates();
|
|
94
|
-
minX = Math.min(minX, coord[0]);
|
|
95
|
-
minY = Math.min(minY, coord[1]);
|
|
96
|
-
maxX = Math.max(maxX, coord[0]);
|
|
97
|
-
maxY = Math.max(maxY, coord[1]);
|
|
98
|
-
});
|
|
99
|
-
const manualExtent = [minX, minY, maxX, maxY];
|
|
100
|
-
console.log('手动计算 extent:', manualExtent);
|
|
101
|
-
map.getView().fit(manualExtent, {
|
|
90
|
+
map.getView().fit(this.vectorSource.getExtent(), {
|
|
102
91
|
size: map.getSize(),
|
|
103
|
-
maxZoom:
|
|
104
|
-
duration: 1000
|
|
92
|
+
maxZoom: 18
|
|
105
93
|
})
|
|
106
94
|
}
|
|
107
95
|
}
|