cd-mapgis 1.0.40 → 1.0.42
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/LayerUtil.js +20 -14
- package/src/MapView.js +1 -0
- package/src/StyleUtil.js +1 -0
package/package.json
CHANGED
package/src/LayerUtil.js
CHANGED
|
@@ -210,13 +210,12 @@ export default class LayerUtil {
|
|
|
210
210
|
* @param {*} p {geoList:[],img:{url,anchor},text:{str,font,color,offsetY}}
|
|
211
211
|
*/
|
|
212
212
|
static getJsonPointsLayer(p) {
|
|
213
|
+
console.log("1", p);
|
|
213
214
|
let geoJSON = new GeoJSON();
|
|
214
|
-
let
|
|
215
|
-
let
|
|
216
|
-
source: vectorSource
|
|
217
|
-
});
|
|
218
|
-
for (let i = 0; i < p.geoList; i++) {
|
|
215
|
+
let features = [];
|
|
216
|
+
for (let i = 0; i < p.geoList.length; i++) {
|
|
219
217
|
let geo = p.geoList[i];
|
|
218
|
+
console.log("2", geo);
|
|
220
219
|
var f = new Feature({
|
|
221
220
|
geometry: geoJSON.readGeometry(geo.json)
|
|
222
221
|
});
|
|
@@ -225,22 +224,25 @@ export default class LayerUtil {
|
|
|
225
224
|
p.text.str = geo.text;
|
|
226
225
|
}
|
|
227
226
|
f.setStyle(StyleUtil.getPointStyle(p));
|
|
228
|
-
|
|
227
|
+
features.push(f);
|
|
229
228
|
}
|
|
230
|
-
|
|
229
|
+
console.log("3", features);
|
|
230
|
+
let vectorSource = new VectorSource({ features: features });
|
|
231
|
+
return new VectorLayer({
|
|
232
|
+
source: vectorSource
|
|
233
|
+
});
|
|
231
234
|
}
|
|
232
235
|
/**
|
|
233
236
|
* 将geoJson的多边形集合数据包装为一个图层
|
|
234
237
|
* @param {*} p {geoList:[],style:{fillColor,lineColor,lineWidth},text:{str,font,color}}
|
|
235
238
|
*/
|
|
236
239
|
static getJsonPolygonsLayer(p) {
|
|
240
|
+
console.log("1", p);
|
|
237
241
|
let geoJSON = new GeoJSON();
|
|
238
|
-
let
|
|
239
|
-
let
|
|
240
|
-
source: vectorSource
|
|
241
|
-
});
|
|
242
|
-
for (let i = 0; i < p.geoList; i++) {
|
|
242
|
+
let features = [];
|
|
243
|
+
for (let i = 0; i < p.geoList.length; i++) {
|
|
243
244
|
let geo = p.geoList[i];
|
|
245
|
+
console.log("2", geo);
|
|
244
246
|
var f = new Feature({
|
|
245
247
|
geometry: geoJSON.readGeometry(geo.json)
|
|
246
248
|
});
|
|
@@ -249,8 +251,12 @@ export default class LayerUtil {
|
|
|
249
251
|
p.text.str = geo.text;
|
|
250
252
|
}
|
|
251
253
|
f.setStyle(StyleUtil.getPolygonStyle(p));
|
|
252
|
-
|
|
254
|
+
features.push(f);
|
|
253
255
|
}
|
|
254
|
-
|
|
256
|
+
console.log("3", features);
|
|
257
|
+
let vectorSource = new VectorSource({ features: features });
|
|
258
|
+
return new VectorLayer({
|
|
259
|
+
source: vectorSource
|
|
260
|
+
});
|
|
255
261
|
}
|
|
256
262
|
}
|
package/src/MapView.js
CHANGED
|
@@ -199,6 +199,7 @@ export default class MapView {
|
|
|
199
199
|
//将视图调整到一个指定的图层显示范围,并返回是否调整成功.只对矢量图层有效,瓦片图层无效
|
|
200
200
|
viewToLayer(layer) {
|
|
201
201
|
let source = layer.getSource();
|
|
202
|
+
console.log("length",source.getFeatures().length);
|
|
202
203
|
if (source.getFeatures().length === 0) return false;
|
|
203
204
|
var extent = source.getExtent();
|
|
204
205
|
let view = this.map.getView();
|