cd-mapgis 1.0.66 → 1.0.67

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cd-mapgis",
3
- "version": "1.0.66",
3
+ "version": "1.0.67",
4
4
  "main": "./src/index.js",
5
5
  "types": "./src/index.d.ts",
6
6
  "type": "module",
@@ -0,0 +1,49 @@
1
+ import VectorSource from 'ol/source/Vector.js';
2
+ import VectorLayer from 'ol/layer/Vector.js';
3
+ import Feature from 'ol/Feature.js';
4
+ import MapView from './MapView.js';
5
+ import Point from 'ol/geom/Point.js';
6
+ import Style from 'ol/style/Style.js';
7
+ import Icon from 'ol/style/Icon.js';
8
+
9
+ export default class Location {
10
+ constructor(p) {
11
+ this.param = p;
12
+ this.img = p.img;
13
+ this.vectorSource = null;
14
+ this.vectorLayer = null;
15
+ this.map = p.map ? p.map : MapView.Instance.map;
16
+ }
17
+
18
+ /**
19
+ * [lon,lat]
20
+ * @param {*} point
21
+ */
22
+ mark(point) {
23
+ if (!this.vectorLayer) {
24
+ let vectorSource = new VectorSource();
25
+ let vectorLayer = new VectorLayer({
26
+ source: vectorSource
27
+ });
28
+ this.map.addLayer(vectorLayer);
29
+ this.vectorSource = vectorSource;
30
+ this.vectorLayer = vectorLayer;
31
+ }
32
+ this.vectorSource.clear();
33
+ // 使用外部圆点图标
34
+ let dotFeature = new Feature({
35
+ geometry: new Point(point)
36
+ });
37
+ dotFeature.setStyle(new Style({
38
+ image: new Icon({
39
+ src: this.img, // 外部图标路径
40
+ scale: 1, // 缩放比例
41
+ anchor: [0.5, 0.5], // 锚点为中心
42
+ anchorOrigin: 'center',
43
+ anchorXUnits: 'fraction',
44
+ anchorYUnits: 'fraction'
45
+ })
46
+ }));
47
+ this.vectorSource.addFeature(dotFeature);
48
+ }
49
+ }
package/src/index.js CHANGED
@@ -6,6 +6,7 @@ import Overlay from './Overlay.js';
6
6
  import HttpUtil from './HttpUtil.js';
7
7
  import InnerUtil from './InnerUtil.js';
8
8
  import StyleUtil from './StyleUtil.js';
9
+ import Location from './Location.js';
9
10
 
10
11
  // 导出模块
11
12
  export {
@@ -15,5 +16,6 @@ export {
15
16
  Overlay,
16
17
  HttpUtil,
17
18
  InnerUtil,
18
- StyleUtil
19
+ StyleUtil,
20
+ Location
19
21
  };