cd-mapgis 1.1.6 → 1.1.7
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/PointLayer.js +23 -6
package/package.json
CHANGED
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);
|
|
@@ -41,17 +41,34 @@ export default class PointLayer {
|
|
|
41
41
|
let feature = new Feature({
|
|
42
42
|
geometry: new Point(p.point)
|
|
43
43
|
});
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
let p = {};
|
|
45
|
+
if (p.img) {
|
|
46
|
+
p.image = new Icon({
|
|
46
47
|
src: p.img, // 外部图标路径
|
|
47
48
|
scale: 1, // 缩放比例
|
|
48
49
|
anchor: [0.5, 0.5], // 锚点为中心
|
|
49
50
|
anchorOrigin: 'center',
|
|
50
51
|
anchorXUnits: 'fraction',
|
|
51
52
|
anchorYUnits: 'fraction'
|
|
52
|
-
})
|
|
53
|
-
}
|
|
54
|
-
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (p.text) {
|
|
56
|
+
let font = p.font ? p.font : 'bold 20px 宋体';
|
|
57
|
+
let corlor = p.corlor ? p.corlor : '#0619e9';
|
|
58
|
+
let offsetY = p.offsetY ? p.offsetY : -10;
|
|
59
|
+
p.text = new Text({
|
|
60
|
+
text: p.text, // 从要素属性获取文字
|
|
61
|
+
font: font,
|
|
62
|
+
overflow: true, // 关键设置:允许文字溢出
|
|
63
|
+
fill: new Fill({
|
|
64
|
+
color: corlor
|
|
65
|
+
}),
|
|
66
|
+
offsetX: 0,
|
|
67
|
+
offsetY: offsetY // 文字显示在图标上方
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
feature.setStyle(new Style(p));
|
|
71
|
+
feature.set('attr', p.attr);
|
|
55
72
|
return feature;
|
|
56
73
|
}
|
|
57
74
|
/**
|