cd-mapgis 1.1.5 → 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 +3 -16
- package/src/PointLayer.js +5 -19
package/package.json
CHANGED
package/src/LineLayer.js
CHANGED
|
@@ -15,7 +15,6 @@ export default class LineLayer {
|
|
|
15
15
|
this.vectorLayer = new VectorLayer({
|
|
16
16
|
source: this.vectorSource
|
|
17
17
|
});
|
|
18
|
-
this.features = [];
|
|
19
18
|
this.mapView = p.mapView ? p.mapView : MapView.Instance;
|
|
20
19
|
this.map = this.mapView.map;
|
|
21
20
|
this.map.addLayer(this.vectorLayer);
|
|
@@ -49,7 +48,6 @@ export default class LineLayer {
|
|
|
49
48
|
})
|
|
50
49
|
}));
|
|
51
50
|
feature.set('attr', p.attr);
|
|
52
|
-
this.features.push(feature);
|
|
53
51
|
return feature;
|
|
54
52
|
}
|
|
55
53
|
/**
|
|
@@ -84,21 +82,10 @@ export default class LineLayer {
|
|
|
84
82
|
* 缩放到本图层显示范围
|
|
85
83
|
*/
|
|
86
84
|
fitToLayer(){
|
|
87
|
-
const map = this.map;
|
|
88
|
-
|
|
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, {
|
|
85
|
+
const map = this.map;
|
|
86
|
+
map.getView().fit(this.vectorSource.getExtent(), {
|
|
99
87
|
size: map.getSize(),
|
|
100
|
-
maxZoom:
|
|
101
|
-
duration: 1000
|
|
88
|
+
maxZoom: 18
|
|
102
89
|
})
|
|
103
90
|
}
|
|
104
91
|
}
|
package/src/PointLayer.js
CHANGED
|
@@ -14,8 +14,7 @@ export default class PointLayer {
|
|
|
14
14
|
this.vectorSource = new VectorSource();
|
|
15
15
|
this.vectorLayer = new VectorLayer({
|
|
16
16
|
source: this.vectorSource
|
|
17
|
-
});
|
|
18
|
-
this.features = [];
|
|
17
|
+
});
|
|
19
18
|
this.mapView = p.mapView ? p.mapView : MapView.Instance;
|
|
20
19
|
this.map = this.mapView.map;
|
|
21
20
|
this.map.addLayer(this.vectorLayer);
|
|
@@ -52,8 +51,7 @@ export default class PointLayer {
|
|
|
52
51
|
anchorYUnits: 'fraction'
|
|
53
52
|
})
|
|
54
53
|
}));
|
|
55
|
-
feature.set('attr', p.attr);
|
|
56
|
-
this.features.push(feature);
|
|
54
|
+
feature.set('attr', p.attr);
|
|
57
55
|
return feature;
|
|
58
56
|
}
|
|
59
57
|
/**
|
|
@@ -88,22 +86,10 @@ export default class PointLayer {
|
|
|
88
86
|
* 缩放到本图层显示范围
|
|
89
87
|
*/
|
|
90
88
|
fitToLayer() {
|
|
91
|
-
const map = this.map;
|
|
92
|
-
|
|
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, {
|
|
89
|
+
const map = this.map;
|
|
90
|
+
map.getView().fit(this.vectorSource.getExtent(), {
|
|
104
91
|
size: map.getSize(),
|
|
105
|
-
maxZoom:
|
|
106
|
-
duration: 1000
|
|
92
|
+
maxZoom: 18
|
|
107
93
|
})
|
|
108
94
|
}
|
|
109
95
|
}
|