my-openlayer 0.0.8 → 0.0.10

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.
@@ -1,18 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const vue_1 = require("vue");
4
- const Overlay_1 = require("ol/Overlay");
5
- class DomPoint {
1
+ import { createApp } from "vue";
2
+ import Overlay from "ol/Overlay";
3
+ export default class DomPoint {
6
4
  constructor(map, options) {
7
5
  this.myOlMap = map;
8
6
  const { Template, lgtd, lttd, props, } = options;
9
7
  this.dom = document.createElement('div');
10
8
  this.myOlMap.map.getViewport().appendChild(this.dom);
11
- this.app = (0, vue_1.createApp)(Object.assign(Template, {
12
- props: Object.assign({}, props)
9
+ this.app = createApp(Object.assign(Template, {
10
+ props: { ...props }
13
11
  }));
14
12
  this.app.mount(this.dom);
15
- this.anchor = new Overlay_1.default({
13
+ this.anchor = new Overlay({
16
14
  element: this.dom,
17
15
  positioning: 'center-center',
18
16
  stopEvent: false
@@ -28,4 +26,3 @@ class DomPoint {
28
26
  this.myOlMap.map.removeOverlay(this.anchor);
29
27
  }
30
28
  }
31
- exports.default = DomPoint;
@@ -1,6 +1,5 @@
1
1
  import Map from "ol/Map";
2
2
  import MyOl from "../index";
3
- import { Style } from "ol/style";
4
3
  import { OptionsType, MapJSONData } from "../types";
5
4
  export default class Line {
6
5
  private map;
@@ -16,5 +15,5 @@ export default class Line {
16
15
  addRiverWidthByLev(arr?: any): Promise<void>;
17
16
  setFeatureAttr(feature: {
18
17
  get: (arg0: string) => any;
19
- }): Style;
18
+ }): any;
20
19
  }
package/dist/core/Line.js CHANGED
@@ -1,19 +1,8 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const Vector_1 = require("ol/source/Vector");
13
- const GeoJSON_1 = require("ol/format/GeoJSON");
14
- const Vector_2 = require("ol/layer/Vector");
15
- const style_1 = require("ol/style");
16
- class Line {
1
+ import VectorSource from "ol/source/Vector";
2
+ import GeoJSON from "ol/format/GeoJSON";
3
+ import VectorLayer from "ol/layer/Vector";
4
+ import { Stroke, Style } from "ol/style";
5
+ export default class Line {
17
6
  constructor(myOlMap, map) {
18
7
  this.riverLayerList = [];
19
8
  this.riverLayerShow = false;
@@ -21,65 +10,64 @@ class Line {
21
10
  this.map = map;
22
11
  }
23
12
  addLineCommon(data, options) {
24
- const layer = new Vector_2.default({
13
+ const layer = new VectorLayer({
25
14
  name: options.type,
26
15
  layerName: options.type,
27
- source: new Vector_1.default({
28
- features: (new GeoJSON_1.default()).readFeatures(data)
16
+ source: new VectorSource({
17
+ features: (new GeoJSON()).readFeatures(data)
29
18
  }),
30
19
  style: function (feature) {
31
- return new style_1.Style({
32
- stroke: new style_1.Stroke({
20
+ return new Style({
21
+ stroke: new Stroke({
33
22
  color: options.strokeColor || 'rgba(3, 122, 255, 1)',
34
23
  width: options.strokeWidth || 3
35
24
  }),
36
25
  });
37
- }
26
+ },
27
+ zIndex: options.zIndex ?? 3
38
28
  });
39
29
  this[options.type + 'Layer'] = layer;
40
30
  this.map.addLayer(layer);
41
31
  }
42
32
  // 添加水系并按照zoom显示不同级别
43
- addRiverLayersByZoom(fyRiverJson_1) {
44
- return __awaiter(this, arguments, void 0, function* (fyRiverJson, options = { type: 'river' }) {
45
- this.riverLayerShow = !!options.show;
46
- this.riverLayerList = [];
47
- for (let i = 1; i <= 5; i++) {
48
- const vectorSource = new Vector_1.default({
49
- format: new GeoJSON_1.default(),
50
- loader: function () {
51
- const geojson = new GeoJSON_1.default();
52
- fyRiverJson.features.forEach((feature) => {
53
- if (feature.properties.level === i) {
54
- const olFeature = geojson.readFeature(feature);
55
- vectorSource.addFeature(olFeature);
56
- }
57
- });
58
- },
59
- // 其他配置
60
- });
61
- const riverLayer = new Vector_2.default({
62
- name: 'river',
63
- layerName: 'river',
64
- source: vectorSource,
65
- style: function () {
66
- return new style_1.Style({
67
- stroke: new style_1.Stroke({
68
- color: options.strokeColor || 'rgb(0,113,255)',
69
- width: options.strokeWidth || 3
70
- })
71
- });
72
- },
73
- zIndex: 6,
74
- });
75
- riverLayer.setVisible(false);
76
- this.riverLayerList.push(riverLayer);
77
- this.map.addLayer(riverLayer);
78
- }
79
- this.showRiverLayerByZoom();
80
- this.myOlMap.mapOnEvent('moveend', () => {
81
- this.showRiverLayerByZoom();
33
+ async addRiverLayersByZoom(fyRiverJson, options = { type: 'river' }) {
34
+ this.riverLayerShow = !!options.show;
35
+ this.riverLayerList = [];
36
+ for (let i = 1; i <= 5; i++) {
37
+ const vectorSource = new VectorSource({
38
+ format: new GeoJSON(),
39
+ loader: function () {
40
+ const geojson = new GeoJSON();
41
+ fyRiverJson.features.forEach((feature) => {
42
+ if (feature.properties.level === i) {
43
+ const olFeature = geojson.readFeature(feature);
44
+ vectorSource.addFeature(olFeature);
45
+ }
46
+ });
47
+ },
48
+ // 其他配置
49
+ });
50
+ const riverLayer = new VectorLayer({
51
+ name: 'river',
52
+ layerName: 'river',
53
+ source: vectorSource,
54
+ style: function () {
55
+ return new Style({
56
+ stroke: new Stroke({
57
+ color: options.strokeColor || 'rgb(0,113,255)',
58
+ width: options.strokeWidth || 3
59
+ })
60
+ });
61
+ },
62
+ zIndex: options.zIndex ?? 6
82
63
  });
64
+ riverLayer.setVisible(false);
65
+ this.riverLayerList.push(riverLayer);
66
+ this.map.addLayer(riverLayer);
67
+ }
68
+ this.showRiverLayerByZoom();
69
+ this.myOlMap.mapOnEvent('moveend', () => {
70
+ this.showRiverLayerByZoom();
83
71
  });
84
72
  }
85
73
  showRiverLayer(show) {
@@ -101,29 +89,26 @@ class Line {
101
89
  });
102
90
  }
103
91
  // 添加全部级别河流根据级别显示不同宽度
104
- addRiverWidthByLev() {
105
- return __awaiter(this, arguments, void 0, function* (arr = {}) {
106
- const riverLayer = new Vector_2.default({
107
- name: 'river',
108
- layerName: 'river',
109
- source: new Vector_1.default({
110
- features: (new GeoJSON_1.default()).readFeatures(arr)
111
- }),
112
- style: (feature) => this.setFeatureAttr(feature),
113
- zIndex: 3
114
- });
115
- this.map.addLayer(riverLayer);
92
+ async addRiverWidthByLev(arr = {}) {
93
+ const riverLayer = new VectorLayer({
94
+ name: 'river',
95
+ layerName: 'river',
96
+ source: new VectorSource({
97
+ features: (new GeoJSON()).readFeatures(arr)
98
+ }),
99
+ style: (feature) => this.setFeatureAttr(feature),
100
+ zIndex: 3
116
101
  });
102
+ this.map.addLayer(riverLayer);
117
103
  }
118
104
  setFeatureAttr(feature) {
119
105
  const level = feature.get('level');
120
106
  const levelWidth = { 1: 2, 2: 1, 3: 0.5, 4: 0.5, 5: 0.5 };
121
- return new style_1.Style({
122
- stroke: new style_1.Stroke({
107
+ return new Style({
108
+ stroke: new Stroke({
123
109
  color: 'rgba(3, 122, 255, 1)',
124
110
  width: levelWidth[Number(level)]
125
111
  }),
126
112
  });
127
113
  }
128
114
  }
129
- exports.default = Line;
@@ -2,7 +2,6 @@
2
2
  * 地图底图图层
3
3
  */
4
4
  import Map from "ol/Map";
5
- import WMTSTileGrid from "ol/tilegrid/WMTS";
6
5
  import { MapbaseType, MapJSONData } from "../types";
7
6
  interface MapLayersOptions {
8
7
  zIndex?: number;
@@ -18,7 +17,7 @@ export default class MapBaseLayers {
18
17
  constructor(map: Map, options: MapLayersOptions);
19
18
  addMapLayer(type: MapbaseType): void;
20
19
  createLayer(layer: any): any;
21
- getTileGrid(length: number): WMTSTileGrid;
20
+ getTileGrid(length: number): any;
22
21
  getTiandiTuLayer(tiandituType?: 'img_c' | 'ter_c'): any;
23
22
  getTerrainLayer(): any;
24
23
  /**
@@ -1,20 +1,18 @@
1
- "use strict";
2
1
  /**
3
2
  * 地图底图图层
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const layer_1 = require("ol/layer");
7
- const proj_1 = require("ol/proj");
8
- const extent_1 = require("ol/extent");
9
- const source_1 = require("ol/source");
10
- const WMTS_1 = require("ol/tilegrid/WMTS");
11
- const XYZ_1 = require("ol/source/XYZ");
12
- const MapTools_1 = require("./MapTools");
4
+ import { Tile as TileLayer } from "ol/layer";
5
+ import { get as getProjection } from "ol/proj";
6
+ import { getTopLeft, getWidth } from "ol/extent";
7
+ import { WMTS } from "ol/source";
8
+ import WMTSTileGrid from "ol/tilegrid/WMTS";
9
+ import XYZ from "ol/source/XYZ";
10
+ import MapTools from "./MapTools";
13
11
  const LAYER_TYPES = {
14
12
  TIANDITU: 'tianditu',
15
13
  TERRAIN: 'terrain'
16
14
  };
17
- class MapBaseLayers {
15
+ export default class MapBaseLayers {
18
16
  constructor(map, options) {
19
17
  this.mapLayers = {
20
18
  tianditu: null,
@@ -28,7 +26,7 @@ class MapBaseLayers {
28
26
  token: ''
29
27
  };
30
28
  this.map = map;
31
- this.options = Object.assign(Object.assign({}, this.options), options);
29
+ this.options = { ...this.options, ...options };
32
30
  if (!this.options.token) {
33
31
  throw new Error('请配置token');
34
32
  }
@@ -52,14 +50,14 @@ class MapBaseLayers {
52
50
  }
53
51
  createLayer(layer) {
54
52
  if (this.options.mapClip && this.options.mapClipData) {
55
- layer = MapTools_1.default.setMapClip(layer, this.options.mapClipData);
53
+ layer = MapTools.setMapClip(layer, this.options.mapClipData);
56
54
  }
57
55
  return layer;
58
56
  }
59
57
  getTileGrid(length) {
60
- const projection = (0, proj_1.get)('EPSG:4326');
61
- const projectionExtent = projection === null || projection === void 0 ? void 0 : projection.getExtent();
62
- const size = (0, extent_1.getWidth)(projectionExtent) / 256;
58
+ const projection = getProjection('EPSG:4326');
59
+ const projectionExtent = projection?.getExtent();
60
+ const size = getWidth(projectionExtent) / 256;
63
61
  const resolutions = new Array(length);
64
62
  const matrixIds = new Array(length);
65
63
  for (let i = 0; i < length; i += 1) {
@@ -67,16 +65,16 @@ class MapBaseLayers {
67
65
  resolutions[i] = size / pow;
68
66
  matrixIds[i] = i;
69
67
  }
70
- return new WMTS_1.default({
71
- origin: (0, extent_1.getTopLeft)(projectionExtent),
68
+ return new WMTSTileGrid({
69
+ origin: getTopLeft(projectionExtent),
72
70
  resolutions,
73
71
  matrixIds
74
72
  });
75
73
  }
76
74
  //img_c 影像底图 ter_c 地形底图
77
75
  getTiandiTuLayer(tiandituType = 'img_c') {
78
- const layer = new layer_1.Tile({
79
- source: new source_1.WMTS({
76
+ const layer = new TileLayer({
77
+ source: new WMTS({
80
78
  url: `https://t{0-7}.tianditu.gov.cn/${tiandituType}/wmts?tk=${this.options.token}`,
81
79
  // subdomains: ['t0', 't1', 't2', 't3', 't4', 't5', 't6', 't7'],
82
80
  layer: 'img',
@@ -99,8 +97,8 @@ class MapBaseLayers {
99
97
  addZhujiLayer(show) {
100
98
  console.log('[注记加载]');
101
99
  if (!this.zhujiMapLayer) {
102
- this.zhujiMapLayer = new layer_1.Tile({
103
- source: new XYZ_1.default({
100
+ this.zhujiMapLayer = new TileLayer({
101
+ source: new XYZ({
104
102
  url: `http://t{0-7}.tianditu.gov.cn/DataServer?T=cia_c&tk=${this.options.token}&x={x}&y={y}&l={z}`,
105
103
  projection: 'EPSG:4326'
106
104
  }),
@@ -111,4 +109,3 @@ class MapBaseLayers {
111
109
  this.zhujiMapLayer.setVisible(show);
112
110
  }
113
111
  }
114
- exports.default = MapBaseLayers;
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const Vector_1 = require("ol/layer/Vector");
4
- const Vector_2 = require("ol/source/Vector");
5
- const GeoJSON_1 = require("ol/format/GeoJSON");
6
- const style_1 = require("ol/style");
7
- const render_1 = require("ol/render");
8
- class MapTools {
2
+ import VectorLayer from "ol/layer/Vector";
3
+ import VectorSource from "ol/source/Vector";
4
+ import GeoJSON from "ol/format/GeoJSON";
5
+ import { Fill, Style } from "ol/style";
6
+ import { getVectorContext } from "ol/render";
7
+ export default class MapTools {
9
8
  constructor(map) {
10
9
  this.map = map;
11
10
  }
@@ -31,25 +30,23 @@ class MapTools {
31
30
  * 设置地图裁剪
32
31
  */
33
32
  static setMapClip(baseLayer, data) {
34
- var _a;
35
- const clipLayer = new Vector_1.default({
33
+ const clipLayer = new VectorLayer({
36
34
  style: null,
37
- source: new Vector_2.default({
38
- features: new GeoJSON_1.default().readFeatures(data)
35
+ source: new VectorSource({
36
+ features: new GeoJSON().readFeatures(data)
39
37
  })
40
38
  });
41
- const style = new style_1.Style({
42
- fill: new style_1.Fill({
39
+ const style = new Style({
40
+ fill: new Fill({
43
41
  color: 'transparent'
44
42
  })
45
43
  });
46
44
  baseLayer.on("prerender", (event) => {
47
- var _a;
48
- const vectorContext = (0, render_1.getVectorContext)(event);
45
+ const vectorContext = getVectorContext(event);
49
46
  event.context.globalCompositeOperation = 'source-over';
50
47
  const ctx = event.context;
51
48
  ctx.save();
52
- (_a = clipLayer.getSource()) === null || _a === void 0 ? void 0 : _a.forEachFeature(function (feature) {
49
+ clipLayer.getSource()?.forEachFeature(function (feature) {
53
50
  vectorContext.drawFeature(feature, style);
54
51
  });
55
52
  ctx.clip();
@@ -58,9 +55,8 @@ class MapTools {
58
55
  const ctx = event.context;
59
56
  ctx.restore();
60
57
  });
61
- (_a = clipLayer.getSource()) === null || _a === void 0 ? void 0 : _a.on('addfeature', function () {
62
- var _a;
63
- baseLayer.setExtent((_a = clipLayer.getSource()) === null || _a === void 0 ? void 0 : _a.getExtent());
58
+ clipLayer.getSource()?.on('addfeature', function () {
59
+ baseLayer.setExtent(clipLayer.getSource()?.getExtent());
64
60
  });
65
61
  return baseLayer;
66
62
  }
@@ -68,4 +64,3 @@ class MapTools {
68
64
  this.map.removeLayer(this.getLayerByLayerName(layerName));
69
65
  }
70
66
  }
71
- exports.default = MapTools;
@@ -1,6 +1,4 @@
1
1
  import Map from "ol/Map";
2
- import VectorLayer from "ol/layer/Vector";
3
- import VectorSource from "ol/source/Vector";
4
2
  import MyOl from "../index";
5
3
  import { OptionsType, PointData } from '../types';
6
4
  export default class Point {
@@ -17,7 +15,7 @@ export default class Point {
17
15
  * hasImg: Boolean 是否显示图标
18
16
  * }
19
17
  */
20
- addPoint(pointData: PointData[], type: string, options: OptionsType): VectorLayer<VectorSource<import("ol/geom").Geometry>>;
18
+ addPoint(pointData: PointData[], type: string, options: OptionsType): any;
21
19
  addClusterPoint(pointData: any[], type: string | undefined, options: OptionsType): void;
22
20
  /**
23
21
  * 添加点 - 闪烁
@@ -1,17 +1,16 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const Overlay_1 = require("ol/Overlay");
4
- const Feature_1 = require("ol/Feature");
5
- const geom_1 = require("ol/geom");
6
- const style_1 = require("ol/style");
2
+ import Overlay from 'ol/Overlay';
3
+ import Feature from "ol/Feature";
4
+ import { Point as olPoint } from "ol/geom";
5
+ import { Text, Style, Fill, Stroke, Icon } from "ol/style";
7
6
  // import {Style, Icon, Text} from "ol/style";
8
- const Vector_1 = require("ol/layer/Vector");
9
- const Vector_2 = require("ol/source/Vector");
10
- const source_1 = require("ol/source");
11
- const turf = require("turf");
12
- const GeoJSON_1 = require("ol/format/GeoJSON");
13
- const DomPoint_1 = require("./DomPoint");
14
- class Point {
7
+ import VectorLayer from "ol/layer/Vector";
8
+ import VectorSource from "ol/source/Vector";
9
+ import { Cluster } from 'ol/source';
10
+ import * as turf from 'turf';
11
+ import GeoJSON from "ol/format/GeoJSON";
12
+ import DomPoint from "./DomPoint";
13
+ export default class Point {
15
14
  constructor(myOlMap, map) {
16
15
  this.myOlMap = myOlMap;
17
16
  this.map = map;
@@ -29,23 +28,22 @@ class Point {
29
28
  addPoint(pointData, type, options) {
30
29
  const pointFeatureList = [];
31
30
  pointData.forEach((item) => {
32
- var _a;
33
- const pointFeature = new Feature_1.default({
31
+ const pointFeature = new Feature({
34
32
  // clickLocation: options.clickLocation,
35
33
  // all: JSON.stringify(item),
36
34
  rawData: item, //保存原始数据
37
35
  type: type,
38
- geometry: new geom_1.Point([item.lgtd, item.lttd])
36
+ geometry: new olPoint([item.lgtd, item.lttd])
39
37
  });
40
38
  const style = {};
41
39
  if (options.nameKey) {
42
- style.text = new style_1.Text({
40
+ style.text = new Text({
43
41
  text: item[options.nameKey],
44
42
  font: options.textFont || '12px Calibri,sans-serif',
45
- fill: new style_1.Fill({
43
+ fill: new Fill({
46
44
  color: options.textFillColor || '#FFF'
47
45
  }),
48
- stroke: new style_1.Stroke({
46
+ stroke: new Stroke({
49
47
  color: options.textStrokeColor || '#000',
50
48
  width: options.textStrokeWidth || 3
51
49
  }),
@@ -55,19 +53,19 @@ class Point {
55
53
  if (options.hasImg || options.hasImg === undefined) {
56
54
  const iconOptions = {
57
55
  src: options.img,
58
- scale: (_a = options.scale) !== null && _a !== void 0 ? _a : 1,
56
+ scale: options.scale ?? 1,
59
57
  };
60
58
  if (options.color) {
61
59
  iconOptions.color = options.color;
62
60
  }
63
- style.image = new style_1.Icon(iconOptions);
61
+ style.image = new Icon(iconOptions);
64
62
  }
65
- pointFeature.setStyle(new style_1.Style(style));
63
+ pointFeature.setStyle(new Style(style));
66
64
  pointFeatureList.push(pointFeature);
67
65
  });
68
- const PointVectorLayer = new Vector_1.default({
66
+ const PointVectorLayer = new VectorLayer({
69
67
  layerName: type,
70
- source: new Vector_2.default({
68
+ source: new VectorSource({
71
69
  features: pointFeatureList
72
70
  }),
73
71
  zIndex: options.zIndex || 4,
@@ -79,35 +77,35 @@ class Point {
79
77
  addClusterPoint(pointData, type = 'village', options) {
80
78
  const pointFeatureList = [];
81
79
  pointData.forEach(item => {
82
- const pointFeature = new Feature_1.default({
83
- geometry: new geom_1.Point([item.lgtd, item.lttd]),
80
+ const pointFeature = new Feature({
81
+ geometry: new olPoint([item.lgtd, item.lttd]),
84
82
  name: options.nameKey ? item[options.nameKey] : '',
85
83
  });
86
84
  pointFeatureList.push(pointFeature);
87
85
  });
88
- const source = new Vector_2.default({
86
+ const source = new VectorSource({
89
87
  features: pointFeatureList,
90
88
  });
91
- const clusterSource = new source_1.Cluster({
89
+ const clusterSource = new Cluster({
92
90
  distance: 40, // The distance for clustering in pixels
93
91
  source: source,
94
92
  });
95
- const clusterLayer = new Vector_1.default({
93
+ const clusterLayer = new VectorLayer({
96
94
  layerName: type,
97
95
  source: clusterSource,
98
96
  style: function (feature) {
99
97
  const aviValue = feature.get('features')[0].get('name');
100
- return new style_1.Style({
101
- image: new style_1.Icon({
98
+ return new Style({
99
+ image: new Icon({
102
100
  src: options.img,
103
101
  }),
104
- text: new style_1.Text({
102
+ text: new Text({
105
103
  text: aviValue,
106
104
  font: '12px Calibri,sans-serif',
107
- fill: new style_1.Fill({
105
+ fill: new Fill({
108
106
  color: '#FFF'
109
107
  }),
110
- stroke: new style_1.Stroke({
108
+ stroke: new Stroke({
111
109
  color: '#000',
112
110
  width: 3
113
111
  }),
@@ -125,16 +123,16 @@ class Point {
125
123
  *
126
124
  */
127
125
  addFlashWarnPoint(img) {
128
- const flashIconLayer = new Vector_1.default({
129
- source: new Vector_2.default({
126
+ const flashIconLayer = new VectorLayer({
127
+ source: new VectorSource({
130
128
  features: [
131
- new Feature_1.default({
132
- geometry: new geom_1.Point([119.81, 29.969]),
129
+ new Feature({
130
+ geometry: new olPoint([119.81, 29.969]),
133
131
  })
134
132
  ]
135
133
  }),
136
- style: new style_1.Style({
137
- image: new style_1.Icon({
134
+ style: new Style({
135
+ image: new Icon({
138
136
  src: img,
139
137
  })
140
138
  }),
@@ -152,8 +150,8 @@ class Point {
152
150
  return centroid.geometry.coordinates;
153
151
  };
154
152
  const features = json.features;
155
- const vectorSource = new Vector_2.default({
156
- format: new GeoJSON_1.default(),
153
+ const vectorSource = new VectorSource({
154
+ format: new GeoJSON(),
157
155
  });
158
156
  twinkleList.forEach(item => {
159
157
  const feature = features.find((ele) => {
@@ -162,7 +160,7 @@ class Point {
162
160
  if (!feature)
163
161
  return;
164
162
  feature.properties.level = item.lev;
165
- const geojson = new GeoJSON_1.default();
163
+ const geojson = new GeoJSON();
166
164
  const olFeature = geojson.readFeature(feature);
167
165
  vectorSource.addFeature(olFeature);
168
166
  if (feature) {
@@ -171,22 +169,22 @@ class Point {
171
169
  item.lttd = polygonCenter[1];
172
170
  }
173
171
  });
174
- const basinLayer = new Vector_1.default({
172
+ const basinLayer = new VectorLayer({
175
173
  name: 'twinklePoint',
176
174
  layerName: 'twinklePoint',
177
175
  source: vectorSource,
178
176
  style: function (feature) {
179
- return new style_1.Style({
180
- stroke: new style_1.Stroke({
177
+ return new Style({
178
+ stroke: new Stroke({
181
179
  color: 'rgb(139,188,245)',
182
180
  width: 3
183
181
  }),
184
- fill: new style_1.Fill({ color: 'rgba(255, 255, 255, 0)' }),
185
- text: new style_1.Text({
182
+ fill: new Fill({ color: 'rgba(255, 255, 255, 0)' }),
183
+ text: new Text({
186
184
  text: feature.values_['BASIN'] || "",
187
185
  font: '14px Calibri,sans-serif',
188
- fill: new style_1.Fill({ color: '#FFF' }),
189
- stroke: new style_1.Stroke({
186
+ fill: new Fill({ color: '#FFF' }),
187
+ stroke: new Stroke({
190
188
  color: '#409EFF', width: 2
191
189
  }),
192
190
  })
@@ -206,13 +204,12 @@ class Point {
206
204
  * @param callback
207
205
  */
208
206
  setTwinkleLayer(twinkleList, className = 'marker_warning', key, callback) {
209
- var _a;
210
207
  // 查找class是warn-points的dom,并删除
211
208
  const arr = document.getElementsByClassName(className);
212
209
  const l = arr.length;
213
210
  for (let i = l - 1; i >= 0; i--) {
214
211
  if (arr[i] !== null) {
215
- (_a = arr[i].parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(arr[i]);
212
+ arr[i].parentNode?.removeChild(arr[i]);
216
213
  }
217
214
  }
218
215
  const el = document.getElementById('marker_warning');
@@ -230,7 +227,7 @@ class Point {
230
227
  if (el)
231
228
  el.insertAdjacentElement('afterend', el2);
232
229
  // 创建一个覆盖物
233
- const anchor = new Overlay_1.default({
230
+ const anchor = new Overlay({
234
231
  element: document.getElementById(className + i) || undefined,
235
232
  positioning: 'center-center',
236
233
  className: className
@@ -261,7 +258,7 @@ class Point {
261
258
  setDomPoint(id, lgtd, lttd) {
262
259
  const el = document.getElementById(id);
263
260
  if (el) {
264
- const anchor = new Overlay_1.default({
261
+ const anchor = new Overlay({
265
262
  id: id,
266
263
  element: el,
267
264
  positioning: 'center-center',
@@ -277,7 +274,7 @@ class Point {
277
274
  }
278
275
  setDomPointVue(pointInfoList, template) {
279
276
  const layer = pointInfoList.map((pointInfo) => {
280
- return new DomPoint_1.default(this.myOlMap, {
277
+ return new DomPoint(this.myOlMap, {
281
278
  Template: template,
282
279
  lgtd: pointInfo.lgtd,
283
280
  lttd: pointInfo.lttd,
@@ -303,4 +300,3 @@ class Point {
303
300
  };
304
301
  }
305
302
  }
306
- exports.default = Point;
@@ -1,7 +1,4 @@
1
1
  import Map from "ol/Map";
2
- import VectorLayer from "ol/layer/Vector";
3
- import VectorSource from "ol/source/Vector";
4
- import { Geometry } from "ol/geom";
5
2
  import MyOl from "../index";
6
3
  import { OptionsType, MapJSONData } from '../types';
7
4
  export default class Polygon {
@@ -22,7 +19,7 @@ export default class Polygon {
22
19
  * @param options 图层配置
23
20
  */
24
21
  addPolygonMapLayer(data: MapJSONData, type: string | undefined, options: OptionsType): void;
25
- addPolygonLayerCommon(dataJSON: MapJSONData, options?: OptionsType): Promise<VectorLayer<VectorSource<Geometry>>>;
22
+ addPolygonLayerCommon(dataJSON: MapJSONData, options?: OptionsType): Promise<any>;
26
23
  /**
27
24
  * 根据数据数组更新某个面颜色
28
25
  * @param layerName 图层名称
@@ -1,25 +1,15 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const Vector_1 = require("ol/layer/Vector");
13
- const Vector_2 = require("ol/source/Vector");
14
- const GeoJSON_1 = require("ol/format/GeoJSON");
15
- const style_1 = require("ol/style");
16
- const layer_1 = require("ol/layer");
17
- const geom_1 = require("ol/geom");
18
- const Polygon_1 = require("ol/geom/Polygon");
19
- const Feature_1 = require("ol/Feature");
20
- const ImageStatic_1 = require("ol/source/ImageStatic");
21
- const MapTools_1 = require("./MapTools");
22
- class Polygon {
2
+ import VectorLayer from "ol/layer/Vector";
3
+ import VectorSource from "ol/source/Vector";
4
+ import GeoJSON from "ol/format/GeoJSON";
5
+ import { Fill, Stroke, Style, Text } from "ol/style";
6
+ import { Image as ImageLayer } from "ol/layer";
7
+ import { Geometry, LinearRing } from "ol/geom";
8
+ import { fromExtent } from "ol/geom/Polygon";
9
+ import Feature from "ol/Feature";
10
+ import ImageStatic from "ol/source/ImageStatic";
11
+ import MapTools from "./MapTools";
12
+ export default class Polygon {
23
13
  constructor(myOlMap, map) {
24
14
  this.colorMap = {
25
15
  '0': 'rgba(255, 0, 0, 0.6)',
@@ -44,34 +34,32 @@ class Polygon {
44
34
  * @param options 图层配置
45
35
  */
46
36
  addPolygonMapLayer(data, type = 'fuyangqu', options) {
47
- var _a;
48
- const borderLayer = new Vector_1.default({
37
+ const borderLayer = new VectorLayer({
49
38
  name: type,
50
39
  layerName: options.type || type,
51
- source: new Vector_2.default({
52
- features: (new GeoJSON_1.default()).readFeatures(data)
40
+ source: new VectorSource({
41
+ features: (new GeoJSON()).readFeatures(data)
53
42
  }),
54
43
  style: function (feature) {
55
- var _a, _b, _c, _d;
56
44
  feature.set('layerName', type);
57
- return new style_1.Style({
58
- stroke: new style_1.Stroke({
45
+ return new Style({
46
+ stroke: new Stroke({
59
47
  color: options.strokeColor || '#EBEEF5',
60
48
  width: options.strokeWidth || 3
61
49
  }),
62
- fill: new style_1.Fill({ color: 'rgba(255, 255, 255, 0)' }),
63
- text: new style_1.Text({
50
+ fill: new Fill({ color: 'rgba(255, 255, 255, 0)' }),
51
+ text: new Text({
64
52
  text: options.nameKey ? feature.values_[options.nameKey] : "",
65
- font: (_a = options.textFont) !== null && _a !== void 0 ? _a : '14px Calibri,sans-serif',
66
- fill: new style_1.Fill({ color: (_b = options.textFillColor) !== null && _b !== void 0 ? _b : '#FFF' }),
67
- stroke: new style_1.Stroke({
68
- color: (_c = options.textStrokeColor) !== null && _c !== void 0 ? _c : '#409EFF',
69
- width: (_d = options.textStrokeWidth) !== null && _d !== void 0 ? _d : 2
53
+ font: options.textFont ?? '14px Calibri,sans-serif',
54
+ fill: new Fill({ color: options.textFillColor ?? '#FFF' }),
55
+ stroke: new Stroke({
56
+ color: options.textStrokeColor ?? '#409EFF',
57
+ width: options.textStrokeWidth ?? 2
70
58
  })
71
59
  })
72
60
  });
73
61
  },
74
- zIndex: (_a = options.zIndex) !== null && _a !== void 0 ? _a : 2
62
+ zIndex: options.zIndex ?? 2
75
63
  });
76
64
  borderLayer.setVisible(options.show === undefined ? true : options.show);
77
65
  this.map.addLayer(borderLayer);
@@ -80,53 +68,49 @@ class Polygon {
80
68
  }
81
69
  // 添加分区
82
70
  //fyBasinJson中的id的key需要跟options中的nameKey一致
83
- addPolygonLayerCommon(dataJSON_1) {
84
- return __awaiter(this, arguments, void 0, function* (dataJSON, options = {}) {
85
- var _a, _b, _c;
86
- if (options.type != null) {
87
- this.myOlMap.getTools().removeLayer(options.type);
88
- }
89
- const layer = new Vector_1.default({
90
- name: options.type,
91
- layerName: options.type,
92
- source: new Vector_2.default({
93
- features: (new GeoJSON_1.default()).readFeatures(dataJSON, (_a = options.projectionOptOptions) !== null && _a !== void 0 ? _a : {})
94
- }),
95
- style: function (feature) {
96
- var _a, _b, _c, _d, _e, _f;
97
- feature.set('layerName', options.type);
98
- return new style_1.Style({
99
- stroke: new style_1.Stroke({
100
- color: (_a = options.strokeColor) !== null && _a !== void 0 ? _a : '#EBEEF5',
101
- width: (_b = options.strokeWidth) !== null && _b !== void 0 ? _b : 3,
102
- lineDash: options.lineDash,
103
- lineDashOffset: options.lineDashOffset
104
- }),
105
- fill: new style_1.Fill({ color: options.fillColor || 'rgba(255, 255, 255, 0.3)' }),
106
- text: new style_1.Text({
107
- text: options.nameKey ? feature.values_[options.nameKey] : "",
108
- font: (_c = options.textFont) !== null && _c !== void 0 ? _c : '14px Calibri,sans-serif',
109
- fill: new style_1.Fill({ color: (_d = options.textFillColor) !== null && _d !== void 0 ? _d : '#FFF' }),
110
- stroke: new style_1.Stroke({
111
- color: (_e = options.textStrokeColor) !== null && _e !== void 0 ? _e : '#409EFF',
112
- width: (_f = options.textStrokeWidth) !== null && _f !== void 0 ? _f : 2
113
- })
71
+ async addPolygonLayerCommon(dataJSON, options = {}) {
72
+ if (options.type != null) {
73
+ this.myOlMap.getTools().removeLayer(options.type);
74
+ }
75
+ const layer = new VectorLayer({
76
+ name: options.type,
77
+ layerName: options.type,
78
+ source: new VectorSource({
79
+ features: (new GeoJSON()).readFeatures(dataJSON, options.projectionOptOptions ?? {})
80
+ }),
81
+ style: function (feature) {
82
+ feature.set('layerName', options.type);
83
+ return new Style({
84
+ stroke: new Stroke({
85
+ color: options.strokeColor ?? '#EBEEF5',
86
+ width: options.strokeWidth ?? 3,
87
+ lineDash: options.lineDash,
88
+ lineDashOffset: options.lineDashOffset
89
+ }),
90
+ fill: new Fill({ color: options.fillColor || 'rgba(255, 255, 255, 0.3)' }),
91
+ text: new Text({
92
+ text: options.nameKey ? feature.values_[options.nameKey] : "",
93
+ font: options.textFont ?? '14px Calibri,sans-serif',
94
+ fill: new Fill({ color: options.textFillColor ?? '#FFF' }),
95
+ stroke: new Stroke({
96
+ color: options.textStrokeColor ?? '#409EFF',
97
+ width: options.textStrokeWidth ?? 2
114
98
  })
115
- });
116
- },
117
- zIndex: (_b = options.zIndex) !== null && _b !== void 0 ? _b : 2
118
- });
119
- layer.setVisible(options.show === undefined ? true : options.show);
120
- this.map.addLayer(layer);
121
- if (options.fitView) {
122
- // 获取面的范围
123
- const extent = (_c = layer.getSource()) === null || _c === void 0 ? void 0 : _c.getExtent();
124
- // 适应这个范围
125
- if (extent)
126
- this.map.getView().fit(extent, { duration: 500 });
127
- }
128
- return layer;
99
+ })
100
+ });
101
+ },
102
+ zIndex: options.zIndex ?? 2
129
103
  });
104
+ layer.setVisible(options.show === undefined ? true : options.show);
105
+ this.map.addLayer(layer);
106
+ if (options.fitView) {
107
+ // 获取面的范围
108
+ const extent = layer.getSource()?.getExtent();
109
+ // 适应这个范围
110
+ if (extent)
111
+ this.map.getView().fit(extent, { duration: 500 });
112
+ }
113
+ return layer;
130
114
  }
131
115
  /**
132
116
  * 根据数据数组更新某个面颜色
@@ -140,28 +124,27 @@ class Polygon {
140
124
  */
141
125
  updateFeatureColors(layerName, colorObj, options) {
142
126
  const layer = this.map.getLayers().getArray().find(layer => layer.get('name') === layerName);
143
- if (layer instanceof Vector_1.default) {
127
+ if (layer instanceof VectorLayer) {
144
128
  const source = layer.getSource();
145
129
  const features = source.getFeatures();
146
130
  features.forEach((feature) => {
147
- var _a, _b, _c, _d, _e;
148
131
  if (options.nameKey) {
149
132
  const name = feature['values_'][options.nameKey];
150
133
  const newColor = colorObj[name];
151
134
  if (newColor) {
152
- feature.setStyle(new style_1.Style({
153
- stroke: new style_1.Stroke({
154
- color: (_a = options.strokeColor) !== null && _a !== void 0 ? _a : '#EBEEF5',
155
- width: (_b = options.strokeWidth) !== null && _b !== void 0 ? _b : 3
135
+ feature.setStyle(new Style({
136
+ stroke: new Stroke({
137
+ color: options.strokeColor ?? '#EBEEF5',
138
+ width: options.strokeWidth ?? 3
156
139
  }),
157
- fill: new style_1.Fill({ color: newColor }),
158
- text: new style_1.Text({
140
+ fill: new Fill({ color: newColor }),
141
+ text: new Text({
159
142
  text: options.showText === false ? "" : name,
160
- font: (_c = options.textFont) !== null && _c !== void 0 ? _c : '14px Calibri,sans-serif',
161
- fill: new style_1.Fill({ color: options.textFillColor || '#FFF' }),
162
- stroke: new style_1.Stroke({
163
- color: (_d = options.textStrokeColor) !== null && _d !== void 0 ? _d : '#409EFF',
164
- width: (_e = options.textStrokeWidth) !== null && _e !== void 0 ? _e : 2
143
+ font: options.textFont ?? '14px Calibri,sans-serif',
144
+ fill: new Fill({ color: options.textFillColor || '#FFF' }),
145
+ stroke: new Stroke({
146
+ color: options.textStrokeColor ?? '#409EFF',
147
+ width: options.textStrokeWidth ?? 2
165
148
  })
166
149
  })
167
150
  }));
@@ -179,7 +162,6 @@ class Polygon {
179
162
  * @param options
180
163
  */
181
164
  setOutLayer(data, options) {
182
- var _a, _b, _c;
183
165
  /** geom转坐标数组 **/
184
166
  function getCoordsGroup(geom) {
185
167
  let group = []; //
@@ -211,19 +193,19 @@ class Polygon {
211
193
  return;
212
194
  }
213
195
  const extent = view.getProjection().getExtent();
214
- const polygonRing = (0, Polygon_1.fromExtent)(extent);
196
+ const polygonRing = fromExtent(extent);
215
197
  part.forEach((item) => {
216
- const linearRing = new geom_1.LinearRing(item);
198
+ const linearRing = new LinearRing(item);
217
199
  polygonRing.appendLinearRing(linearRing);
218
200
  });
219
201
  return polygonRing;
220
202
  }
221
203
  /** 添加遮罩 **/
222
204
  function createShade(geom, view) {
223
- if (geom instanceof geom_1.Geometry) {
205
+ if (geom instanceof Geometry) {
224
206
  const source = geom.clone();
225
207
  const polygon = erase(source, view);
226
- const feature = new Feature_1.default({
208
+ const feature = new Feature({
227
209
  geometry: polygon
228
210
  });
229
211
  return {
@@ -233,31 +215,31 @@ class Polygon {
233
215
  }
234
216
  }
235
217
  // 遮罩样式
236
- const shadeStyle = new style_1.Style({
237
- fill: new style_1.Fill({
238
- color: (_a = options === null || options === void 0 ? void 0 : options.fillColor) !== null && _a !== void 0 ? _a : 'rgba(0,27,59,0.8)'
218
+ const shadeStyle = new Style({
219
+ fill: new Fill({
220
+ color: options?.fillColor ?? 'rgba(0,27,59,0.8)'
239
221
  }),
240
- stroke: new style_1.Stroke({
241
- width: (_b = options === null || options === void 0 ? void 0 : options.strokeWidth) !== null && _b !== void 0 ? _b : 1,
242
- color: (_c = options === null || options === void 0 ? void 0 : options.strokeColor) !== null && _c !== void 0 ? _c : 'rgba(0,27,59,0.8)'
222
+ stroke: new Stroke({
223
+ width: options?.strokeWidth ?? 1,
224
+ color: options?.strokeColor ?? 'rgba(0,27,59,0.8)'
243
225
  })
244
226
  });
245
227
  // 遮罩数据源
246
- const vtSource = new Vector_2.default();
228
+ const vtSource = new VectorSource();
247
229
  // 遮罩图层
248
- const vtLayer = new Vector_1.default({
230
+ const vtLayer = new VectorLayer({
249
231
  source: vtSource,
250
232
  style: shadeStyle,
251
233
  zIndex: 99
252
234
  });
253
235
  this.map.addLayer(vtLayer);
254
- const features = new GeoJSON_1.default().readFeatures(data);
236
+ const features = new GeoJSON().readFeatures(data);
255
237
  const ft = features[0];
256
238
  const bound = ft.getGeometry();
257
239
  const result = createShade(bound, this.map.getView());
258
240
  if (result) {
259
241
  vtSource.addFeature(result.feature);
260
- if (options === null || options === void 0 ? void 0 : options.extent)
242
+ if (options?.extent)
261
243
  this.map.getView().fit(result.shade);
262
244
  }
263
245
  }
@@ -269,9 +251,8 @@ class Polygon {
269
251
  * @param options 图层配置
270
252
  */
271
253
  addImgLayer(layerName, img, extent, options = { zIndex: 3 }) {
272
- var _a, _b;
273
254
  if (img && extent) {
274
- const source = new ImageStatic_1.default({
255
+ const source = new ImageStatic({
275
256
  url: img,
276
257
  imageExtent: extent
277
258
  });
@@ -279,16 +260,16 @@ class Polygon {
279
260
  this[layerName].setSource(source);
280
261
  }
281
262
  else {
282
- let imageLayer = new layer_1.Image();
263
+ let imageLayer = new ImageLayer();
283
264
  imageLayer.set('name', layerName);
284
265
  imageLayer.set('layerName', layerName);
285
266
  imageLayer.setSource(source);
286
- imageLayer.setZIndex((_a = options.zIndex) !== null && _a !== void 0 ? _a : 3);
287
- imageLayer.setOpacity((_b = options.opacity) !== null && _b !== void 0 ? _b : 1);
267
+ imageLayer.setZIndex(options.zIndex ?? 3);
268
+ imageLayer.setOpacity(options.opacity ?? 1);
288
269
  if (options.show !== undefined)
289
270
  imageLayer.setVisible(options.show);
290
271
  if (options.mapClip && options.mapClipData) {
291
- imageLayer = MapTools_1.default.setMapClip(imageLayer, options.mapClipData);
272
+ imageLayer = MapTools.setMapClip(imageLayer, options.mapClipData);
292
273
  }
293
274
  this.map.addLayer(imageLayer);
294
275
  this[layerName] = imageLayer;
@@ -304,4 +285,3 @@ class Polygon {
304
285
  this[layerName] = null;
305
286
  }
306
287
  }
307
- exports.default = Polygon;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import View from "ol/View";
2
1
  import Map from "ol/Map";
3
2
  import Polygon from "./core/Polygon";
4
3
  import Point from "./core/Point";
@@ -25,7 +24,7 @@ export default class MyOl {
25
24
  * @param options.extent 视图范围
26
25
  * @returns View
27
26
  */
28
- static getView(options?: MapInitType): View;
27
+ static getView(options?: MapInitType): any;
29
28
  /**
30
29
  * 获取 地图 面 操作
31
30
  * @returns Polygon
package/dist/index.js CHANGED
@@ -1,25 +1,24 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const proj4_1 = require("ol/proj/proj4");
4
- const proj_1 = require("ol/proj");
5
- const View_1 = require("ol/View");
6
- const Map_1 = require("ol/Map");
7
- const Polygon_1 = require("./core/Polygon");
8
- const Point_1 = require("./core/Point");
9
- const Line_1 = require("./core/Line");
10
- const MapBaseLayers_1 = require("./core/MapBaseLayers");
11
- const proj4_2 = require("proj4");
12
- const MapTools_1 = require("./core/MapTools");
13
- const control_1 = require("ol/control");
2
+ import { register as olProj4Register } from 'ol/proj/proj4';
3
+ import { Projection as olProjProjection, addProjection as olProjAddProjection, fromLonLat as olProjFromLonLat } from 'ol/proj';
4
+ import View from "ol/View";
5
+ import Map from "ol/Map";
6
+ import Polygon from "./core/Polygon";
7
+ import Point from "./core/Point";
8
+ import Line from "./core/Line";
9
+ import MapBaseLayers from "./core/MapBaseLayers";
10
+ import proj4 from "proj4";
11
+ import MapTools from "./core/MapTools";
12
+ import { defaults as defaultControls } from 'ol/control';
14
13
  class MyOl {
15
14
  constructor(id, options) {
16
15
  options.center = options.center || MyOl.DefaultOptions.center;
17
- this.options = Object.assign(Object.assign({}, MyOl.DefaultOptions), options);
18
- this.map = new Map_1.default({
16
+ this.options = { ...MyOl.DefaultOptions, ...options };
17
+ this.map = new Map({
19
18
  target: id, // 地图容器
20
19
  view: MyOl.getView(this.options), // 视图
21
20
  layers: this.options.layers || [],
22
- controls: (0, control_1.defaults)({
21
+ controls: defaultControls({
23
22
  zoom: false,
24
23
  rotate: false,
25
24
  attribution: false
@@ -37,28 +36,28 @@ class MyOl {
37
36
  * @returns View
38
37
  */
39
38
  static getView(options = MyOl.DefaultOptions) {
40
- proj4_2.default.defs("EPSG:4490", "+proj=longlat +ellps=GRS80 +no_defs");
41
- proj4_2.default.defs("EPSG:4549", "+proj=tmerc +lat_0=0 +lon_0=120 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs");
42
- (0, proj4_1.register)(proj4_2.default);
43
- const cgsc2000 = new proj_1.Projection({
39
+ proj4.defs("EPSG:4490", "+proj=longlat +ellps=GRS80 +no_defs");
40
+ proj4.defs("EPSG:4549", "+proj=tmerc +lat_0=0 +lon_0=120 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs");
41
+ olProj4Register(proj4);
42
+ const cgsc2000 = new olProjProjection({
44
43
  code: "EPSG:4490",
45
44
  extent: [-180, -90, 180, 90],
46
45
  worldExtent: [-180, -90, 180, 90],
47
46
  units: "degrees"
48
47
  });
49
- (0, proj_1.addProjection)(cgsc2000);
48
+ olProjAddProjection(cgsc2000);
50
49
  // debugger
51
50
  // 视图配置
52
51
  const viewOptions = {
53
52
  projection: cgsc2000, // 坐标系
54
- center: (0, proj_1.fromLonLat)(options.center, cgsc2000), // 中心点
53
+ center: olProjFromLonLat(options.center, cgsc2000), // 中心点
55
54
  zoom: options.zoom || 10, // 缩放级别
56
55
  minZoom: options.minZoom || 8,
57
56
  maxZoom: options.maxZoom || 20
58
57
  };
59
58
  if (options.extent)
60
59
  viewOptions.extent = options.extent;
61
- return new View_1.default(viewOptions);
60
+ return new View(viewOptions);
62
61
  }
63
62
  // ╔══════════╗
64
63
  // ║ 地图 面 ║
@@ -69,12 +68,12 @@ class MyOl {
69
68
  */
70
69
  getPolygon() {
71
70
  if (!this.polygon)
72
- this.polygon = new Polygon_1.default(this, this.map);
71
+ this.polygon = new Polygon(this, this.map);
73
72
  return this.polygon;
74
73
  }
75
74
  getMapBaseLayers() {
76
75
  if (!this.baseLayers)
77
- this.baseLayers = new MapBaseLayers_1.default(this.map, {
76
+ this.baseLayers = new MapBaseLayers(this.map, {
78
77
  zIndex: 1,
79
78
  mapClip: !!this.options.mapClipData,
80
79
  mapClipData: this.options.mapClipData,
@@ -174,7 +173,7 @@ class MyOl {
174
173
  */
175
174
  getPoint() {
176
175
  if (!this.point)
177
- this.point = new Point_1.default(this, this.map);
176
+ this.point = new Point(this, this.map);
178
177
  return this.point;
179
178
  }
180
179
  // ╔══════════╗
@@ -186,7 +185,7 @@ class MyOl {
186
185
  */
187
186
  getLine() {
188
187
  if (!this.line)
189
- this.line = new Line_1.default(this, this.map);
188
+ this.line = new Line(this, this.map);
190
189
  return this.line;
191
190
  }
192
191
  /**
@@ -207,7 +206,7 @@ class MyOl {
207
206
  */
208
207
  getTools() {
209
208
  if (!this.mapTools)
210
- this.mapTools = new MapTools_1.default(this.map);
209
+ this.mapTools = new MapTools(this.map);
211
210
  return this.mapTools;
212
211
  }
213
212
  restPosition(duration = 3000) {
@@ -274,4 +273,4 @@ MyOl.DefaultOptions = {
274
273
  maxZoom: 20,
275
274
  extent: undefined
276
275
  };
277
- exports.default = MyOl;
276
+ export default MyOl;
package/dist/types.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "my-openlayer",
3
3
  "private": false,
4
- "version": "0.0.8",
4
+ "version": "0.0.10",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",