my-openlayer 0.1.9 → 0.1.11

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/dist/core/Line.js CHANGED
@@ -11,8 +11,8 @@ export default class Line {
11
11
  }
12
12
  addLine(data, options) {
13
13
  const layer = new VectorLayer({
14
- name: options.type,
15
- layerName: options.type,
14
+ name: options.layerName,
15
+ layerName: options.layerName,
16
16
  source: new VectorSource({
17
17
  features: (new GeoJSON()).readFeatures(data)
18
18
  }),
@@ -22,7 +22,9 @@ export default class Line {
22
22
  return new Style({
23
23
  stroke: new Stroke({
24
24
  color: options.strokeColor || 'rgba(3, 122, 255, 1)',
25
- width: options.strokeWidth || 2
25
+ width: options.strokeWidth || 2,
26
+ lineDash: options?.lineDash,
27
+ lineDashOffset: options?.lineDashOffset
26
28
  }),
27
29
  });
28
30
  },
@@ -55,8 +57,8 @@ export default class Line {
55
57
  layerName: 'river',
56
58
  source: vectorSource,
57
59
  style: function (feature) {
58
- feature.set('type', options.type);
59
- feature.set('layerName', options.type);
60
+ feature.set('type', options.layerName);
61
+ feature.set('layerName', options.layerName);
60
62
  return new Style({
61
63
  stroke: new Stroke({
62
64
  color: options.strokeColor || 'rgb(0,113,255)',
@@ -20,16 +20,16 @@ class MapTools {
20
20
  static getLayerByLayerName(map, layerName) {
21
21
  const targetLayer = [];
22
22
  const layers = map.getLayers().getArray();
23
- Object.keys(layers).forEach(function (key) {
24
- const _layerName = layers[key].get('layerName');
23
+ Object.values(layers).forEach((layer) => {
24
+ const _layerName = layer.get('layerName');
25
25
  if (typeof layerName === "string") {
26
26
  if (_layerName && _layerName === layerName) {
27
- targetLayer.push(layers[key]);
27
+ targetLayer.push(layer);
28
28
  }
29
29
  }
30
30
  else {
31
31
  if (_layerName && layerName.includes(_layerName)) {
32
- targetLayer.push(layers[key]);
32
+ targetLayer.push(layer);
33
33
  }
34
34
  }
35
35
  });
@@ -32,7 +32,7 @@ export default class Point {
32
32
  // clickLocation: options.clickLocation,
33
33
  // all: JSON.stringify(item),
34
34
  rawData: item, //保存原始数据
35
- type: options.type,
35
+ type: options.layerName,
36
36
  geometry: new olPoint([item.lgtd, item.lttd])
37
37
  });
38
38
  const style = {};
@@ -64,7 +64,7 @@ export default class Point {
64
64
  pointFeatureList.push(pointFeature);
65
65
  });
66
66
  const PointVectorLayer = new VectorLayer({
67
- layerName: options.type,
67
+ layerName: options.layerName,
68
68
  source: new VectorSource({
69
69
  features: pointFeatureList
70
70
  }),
@@ -91,7 +91,7 @@ export default class Point {
91
91
  source: source,
92
92
  });
93
93
  const clusterLayer = new VectorLayer({
94
- layerName: options.type,
94
+ layerName: options.layerName,
95
95
  source: clusterSource,
96
96
  style: function (feature) {
97
97
  const name = feature.get('features')[0].get(options.nameKey);
@@ -33,7 +33,7 @@ export default class Polygon {
33
33
  */
34
34
  addBorderPolygon(data, options) {
35
35
  options = options ?? {};
36
- options.type = options.type ?? 'border';
36
+ options.layerName = options.layerName ?? 'border';
37
37
  options.fillColor = options.fillColor ?? 'rgba(255, 255, 255, 0)';
38
38
  this.addPolygon(data, options);
39
39
  if (options.mask)
@@ -43,12 +43,12 @@ export default class Polygon {
43
43
  //fyBasinJson中的id的key需要跟options中的nameKey一致
44
44
  addPolygon(dataJSON, options) {
45
45
  options = options ?? {};
46
- if (options.type != null) {
47
- MapTools.removeLayer(this.map, options.type);
46
+ if (options.layerName != null) {
47
+ MapTools.removeLayer(this.map, options.layerName);
48
48
  }
49
49
  const layer = new VectorLayer({
50
- name: options.type,
51
- layerName: options.type,
50
+ name: options.layerName,
51
+ layerName: options.layerName,
52
52
  source: new VectorSource({
53
53
  features: (new GeoJSON()).readFeatures(dataJSON, options.projectionOptOptions ?? {})
54
54
  }),
package/dist/types.d.ts CHANGED
@@ -58,7 +58,7 @@ export interface HeatMapOptions {
58
58
  valueKey: string;
59
59
  }
60
60
  export interface OptionsType {
61
- type?: string;
61
+ layerName?: string;
62
62
  nameKey?: string;
63
63
  img?: string;
64
64
  scale?: number;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "my-openlayer",
3
3
  "private": false,
4
- "version": "0.1.9",
4
+ "version": "0.1.11",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",