cd-mapgis 1.0.41 → 1.0.43
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 +14 -17
- package/src/MapView.js +1 -2
- package/src/StyleUtil.js +2 -2
package/package.json
CHANGED
package/src/LayerUtil.js
CHANGED
|
@@ -209,14 +209,11 @@ export default class LayerUtil {
|
|
|
209
209
|
* 将geoJson的点集合数据包装为一个图层
|
|
210
210
|
* @param {*} p {geoList:[],img:{url,anchor},text:{str,font,color,offsetY}}
|
|
211
211
|
*/
|
|
212
|
-
static getJsonPointsLayer(p) {
|
|
212
|
+
static getJsonPointsLayer(p) {
|
|
213
213
|
let geoJSON = new GeoJSON();
|
|
214
|
-
let
|
|
215
|
-
let
|
|
216
|
-
|
|
217
|
-
});
|
|
218
|
-
for (let i = 0; i < p.geoList; i++) {
|
|
219
|
-
let geo = p.geoList[i];
|
|
214
|
+
let features = [];
|
|
215
|
+
for (let i = 0; i < p.geoList.length; i++) {
|
|
216
|
+
let geo = p.geoList[i];
|
|
220
217
|
var f = new Feature({
|
|
221
218
|
geometry: geoJSON.readGeometry(geo.json)
|
|
222
219
|
});
|
|
@@ -225,21 +222,22 @@ export default class LayerUtil {
|
|
|
225
222
|
p.text.str = geo.text;
|
|
226
223
|
}
|
|
227
224
|
f.setStyle(StyleUtil.getPointStyle(p));
|
|
228
|
-
|
|
229
|
-
}
|
|
230
|
-
|
|
225
|
+
features.push(f);
|
|
226
|
+
}
|
|
227
|
+
let vectorSource = new VectorSource({ features: features });
|
|
228
|
+
return new VectorLayer({
|
|
229
|
+
source: vectorSource
|
|
230
|
+
});
|
|
231
231
|
}
|
|
232
232
|
/**
|
|
233
233
|
* 将geoJson的多边形集合数据包装为一个图层
|
|
234
234
|
* @param {*} p {geoList:[],style:{fillColor,lineColor,lineWidth},text:{str,font,color}}
|
|
235
235
|
*/
|
|
236
|
-
static getJsonPolygonsLayer(p) {
|
|
237
|
-
console.log("1", p);
|
|
236
|
+
static getJsonPolygonsLayer(p) {
|
|
238
237
|
let geoJSON = new GeoJSON();
|
|
239
238
|
let features = [];
|
|
240
|
-
for (let i = 0; i < p.geoList; i++) {
|
|
241
|
-
let geo = p.geoList[i];
|
|
242
|
-
console.log("2", geo);
|
|
239
|
+
for (let i = 0; i < p.geoList.length; i++) {
|
|
240
|
+
let geo = p.geoList[i];
|
|
243
241
|
var f = new Feature({
|
|
244
242
|
geometry: geoJSON.readGeometry(geo.json)
|
|
245
243
|
});
|
|
@@ -249,8 +247,7 @@ export default class LayerUtil {
|
|
|
249
247
|
}
|
|
250
248
|
f.setStyle(StyleUtil.getPolygonStyle(p));
|
|
251
249
|
features.push(f);
|
|
252
|
-
}
|
|
253
|
-
console.log("3", features);
|
|
250
|
+
}
|
|
254
251
|
let vectorSource = new VectorSource({ features: features });
|
|
255
252
|
return new VectorLayer({
|
|
256
253
|
source: vectorSource
|
package/src/MapView.js
CHANGED
|
@@ -198,8 +198,7 @@ export default class MapView {
|
|
|
198
198
|
}
|
|
199
199
|
//将视图调整到一个指定的图层显示范围,并返回是否调整成功.只对矢量图层有效,瓦片图层无效
|
|
200
200
|
viewToLayer(layer) {
|
|
201
|
-
let source = layer.getSource();
|
|
202
|
-
console.log("length",source.getFeatures().length);
|
|
201
|
+
let source = layer.getSource();
|
|
203
202
|
if (source.getFeatures().length === 0) return false;
|
|
204
203
|
var extent = source.getExtent();
|
|
205
204
|
let view = this.map.getView();
|
package/src/StyleUtil.js
CHANGED
|
@@ -107,6 +107,7 @@ export default class StyleUtil {
|
|
|
107
107
|
return new Text({
|
|
108
108
|
text: p.str, // 从要素属性获取文字
|
|
109
109
|
font: font,
|
|
110
|
+
overflow: true, // 关键设置:允许文字溢出
|
|
110
111
|
fill: new Fill({
|
|
111
112
|
color: corlor
|
|
112
113
|
}),
|
|
@@ -153,8 +154,7 @@ export default class StyleUtil {
|
|
|
153
154
|
});
|
|
154
155
|
if (p.text) {
|
|
155
156
|
styleParam.text = StyleUtil.getText(p.text);
|
|
156
|
-
}
|
|
157
|
-
console.log("1111", styleParam)
|
|
157
|
+
}
|
|
158
158
|
return new Style(styleParam);
|
|
159
159
|
}
|
|
160
160
|
}
|