v-openlayers 2.9.0 → 2.9.1

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.
@@ -58392,47 +58392,55 @@ class _G {
58392
58392
  * @param {*} options 地图选项
58393
58393
  * @return {*} Promise 地图实例
58394
58394
  */
58395
- initMap(e, t = {
58396
- controls: {
58397
- scaleLine: !0
58398
- },
58399
- showBasemap: !0,
58400
- dragging: !0,
58401
- interactions: {}
58402
- }) {
58395
+ initMap(e, t) {
58403
58396
  if (!this.target)
58404
58397
  throw new Error("地图目标元素不存在");
58398
+ const n = {
58399
+ controls: {
58400
+ scaleLine: !0
58401
+ },
58402
+ showBasemap: !0,
58403
+ dragging: !0,
58404
+ interactions: {}
58405
+ };
58405
58406
  this.mapConfig = yn.deepClone(e), this.getLayerHandler();
58406
- const { controls: n, showBasemap: i, interactions: a = {} } = t, {
58407
- baseLayers: o,
58408
- prj: l,
58409
- defaultBaseLayerId: u,
58410
- defaultView: h
58407
+ const {
58408
+ controls: i,
58409
+ showBasemap: a,
58410
+ interactions: o = {}
58411
+ } = {
58412
+ ...n,
58413
+ ...t
58414
+ }, {
58415
+ baseLayers: l,
58416
+ prj: u,
58417
+ defaultBaseLayerId: h,
58418
+ defaultView: d
58411
58419
  } = this.mapConfig;
58412
- l === "EPSG:3857" && (h.center = P5(h.center || [113, 33]), h.extent && (h.extent = Np(h.extent, "EPSG:4326", "EPSG:3857"))), this.prj = l;
58413
- const d = [], g = [];
58414
- yn.tree2list(o, g);
58415
- const m = o.filter(
58416
- (_) => _.id === u
58420
+ u === "EPSG:3857" && (d.center = P5(d.center || [113, 33]), d.extent && (d.extent = Np(d.extent, "EPSG:4326", "EPSG:3857"))), this.prj = u;
58421
+ const g = [], m = [];
58422
+ yn.tree2list(l, m);
58423
+ const p = l.filter(
58424
+ (x) => x.id === h
58417
58425
  );
58418
- m.length > 0 && this.getBaseLayer(m[0]).forEach((_) => {
58419
- d.push(_);
58426
+ p.length > 0 && this.getBaseLayer(p[0]).forEach((x) => {
58427
+ g.push(x);
58420
58428
  });
58421
- const p = new h1({
58429
+ const _ = new h1({
58422
58430
  // logo: false,
58423
58431
  controls: D0({
58424
58432
  attribution: !1,
58425
58433
  zoom: !1,
58426
58434
  rotate: !1,
58427
- ...n
58435
+ ...i
58428
58436
  }).extend([]),
58429
58437
  // 隐藏放大缩小按钮
58430
- interactions: new p4(a),
58431
- layers: i ? d : [],
58438
+ interactions: new p4(o),
58439
+ layers: a ? g : [],
58432
58440
  target: this.target,
58433
- view: new ps({ ...h, projection: l })
58441
+ view: new ps({ ...d, projection: u })
58434
58442
  });
58435
- return this.map = p, n.scaleLine && this.map.addControl(
58443
+ return this.map = _, i.scaleLine && this.map.addControl(
58436
58444
  new d1({
58437
58445
  units: "metric",
58438
58446
  bar: !1,
@@ -58442,10 +58450,10 @@ class _G {
58442
58450
  maxWidth: 100
58443
58451
  // target: 'vmap-status-bar',
58444
58452
  })
58445
- ), this.layerHandler.setMap(this.map), this.initEvent(), new Promise((_, x) => {
58453
+ ), this.layerHandler.setMap(this.map), this.initEvent(), new Promise((x, E) => {
58446
58454
  this.mapConfig.extent && this.map.getView().fit(this.mapConfig.extent, {
58447
58455
  duration: 0
58448
- }), this.mapInitExtent = this.map.getView().calculateExtent(this.map.getSize()), _({ map: p });
58456
+ }), this.mapInitExtent = this.map.getView().calculateExtent(this.map.getSize()), x({ map: _ });
58449
58457
  });
58450
58458
  }
58451
58459
  /**
@@ -59014,65 +59022,90 @@ class _G {
59014
59022
  /**
59015
59023
  * 缩放到指定范围
59016
59024
  * @param {*} extent 范围 [minX,minY,maxX,maxY]
59017
- * @param {*} options 可选参数 {duration: 1000, minResolution: 0.000674727, maxZoom: 18}
59025
+ * @param {*} options 可选参数 {duration: 1000, minResolution: 0, maxZoom: 18}
59018
59026
  */
59019
- zoomToExtent(e, t = {
59020
- duration: 1e3,
59021
- maxZoom: 18
59022
- }) {
59023
- this.map.getView().fit(e, t);
59027
+ zoomToExtent(e, t) {
59028
+ const n = {
59029
+ duration: 1e3,
59030
+ // minResolution: 0,
59031
+ maxZoom: 18
59032
+ };
59033
+ this.map.getView().fit(e, { ...n, ...t });
59024
59034
  }
59025
59035
  /**
59026
59036
  * 缩放到点
59027
59037
  * @param {*} coordinate Array 点坐标 [x,y]
59028
- * @param {*} options 可选参数 {duration: 1000, minResolution: 0.000674727, maxZoom: 18}
59038
+ * @param {*} options 可选参数 {duration: 1000, minResolution: 0, maxZoom: 18}
59029
59039
  */
59030
- zoomToPoint(e, t = { duration: 1e3, minResolution: 0, maxZoom: 18 }) {
59031
- const n = new Nn(e);
59032
- this.zoomToGeometry(n, t);
59040
+ zoomToPoint(e, t) {
59041
+ const n = {
59042
+ duration: 1e3,
59043
+ // minResolution: 0,
59044
+ maxZoom: 18
59045
+ }, i = new Nn(e);
59046
+ this.zoomToGeometry(i, { ...n, ...t });
59033
59047
  }
59034
59048
  /**
59035
59049
  * 缩放到几何对象
59036
59050
  * @param {*} geometry 几何对象
59037
59051
  * @param {*} options 可选参数 {duration: 1000, minResolution: 0, maxZoom: 18}
59038
59052
  */
59039
- zoomToGeometry(e, t = {
59040
- duration: 1e3,
59041
- minResolution: 0,
59042
- maxZoom: 18
59043
- }) {
59044
- this.map.getView().fit(e, t);
59053
+ zoomToGeometry(e, t) {
59054
+ const n = {
59055
+ duration: 1e3,
59056
+ // minResolution: 0,
59057
+ maxZoom: 18
59058
+ };
59059
+ let i = this.map.getView();
59060
+ const a = { ...n, ...t };
59061
+ i.fit(e, a);
59045
59062
  }
59046
59063
  /**
59047
59064
  * 缩放到图层
59048
59065
  * @param {*} id 图层id
59049
- * @param {*} map 地图对象
59066
+ * @param {*} options 可选参数 {duration: 1000, minResolution: 0, maxZoom: 18}
59050
59067
  */
59051
- zoomToLayerById(e, t = { maxZoom: 18, duration: 1e3 }) {
59052
- const n = this.getLayerById(e);
59053
- this.zoomToLayer(n, t);
59068
+ zoomToLayerById(e, t) {
59069
+ const n = {
59070
+ duration: 1e3,
59071
+ // minResolution: 0,
59072
+ maxZoom: 18
59073
+ }, i = this.getLayerById(e);
59074
+ this.zoomToLayer(i, { ...n, ...t });
59054
59075
  }
59055
59076
  /**
59056
59077
  * 缩放到图层
59057
59078
  * @param {*} layer 图层
59058
59079
  * @param {*} options 可选参数 {maxZoom: 18, duration: 1000 ,minResolution: 0}
59059
59080
  */
59060
- zoomToLayer(e, t = { maxZoom: 18, duration: 1e3 }) {
59081
+ zoomToLayer(e, t) {
59082
+ const n = {
59083
+ duration: 1e3,
59084
+ // minResolution: 0,
59085
+ maxZoom: 18
59086
+ };
59061
59087
  if (e && e.getSource().getFeatures().length > 0)
59062
59088
  if (e.getSource().getFeatures()[0].getGeometry().getType() === "Point") {
59063
- const n = e.getSource().getFeatures()[0].getGeometry().getCoordinates();
59064
- this.zoomToPoint(n, t);
59089
+ const i = e.getSource().getFeatures()[0].getGeometry().getCoordinates();
59090
+ this.zoomToPoint(i, { ...n, ...t });
59065
59091
  } else
59066
- this.zoomToExtent(e.getSource().getExtent(), t);
59092
+ this.zoomToExtent(e.getSource().getExtent(), {
59093
+ ...n,
59094
+ ...t
59095
+ });
59067
59096
  }
59068
59097
  /**
59069
59098
  * 缩放到多个图层
59070
59099
  * @param {*} layers 图层数组
59071
59100
  * @param {*} options 可选参数 {maxZoom: 18, duration: 1000 ,minResolution: 0}
59072
59101
  */
59073
- zoomToLayers(e, t = { maxZoom: 18, duration: 1e3, minResolution: 0 }) {
59074
- const n = this.getLayersExtent(e);
59075
- n && this.zoomToExtent(n, t);
59102
+ zoomToLayers(e, t) {
59103
+ const n = {
59104
+ duration: 1e3,
59105
+ // minResolution: 0,
59106
+ maxZoom: 18
59107
+ }, i = this.getLayersExtent(e);
59108
+ i && this.zoomToExtent(i, { ...n, ...t });
59076
59109
  }
59077
59110
  /**
59078
59111
  * 获取多个图层的范围
@@ -59098,8 +59131,36 @@ class _G {
59098
59131
  * @param {*} options 可选参数 style
59099
59132
  * @returns 高亮图层
59100
59133
  */
59101
- highlightGeometry(e, t = {
59102
- style: {
59134
+ highlightGeometry(e, t) {
59135
+ const n = {
59136
+ style: {
59137
+ fill: {
59138
+ color: "rgba(255, 0, 0, 0.5)"
59139
+ },
59140
+ stroke: {
59141
+ color: "red",
59142
+ width: 2
59143
+ },
59144
+ circle: {
59145
+ color: "red",
59146
+ radius: 5
59147
+ }
59148
+ }
59149
+ }, { map: i } = this;
59150
+ this.highlightLayer && i.removeLayer(this.highlightLayer), typeof e == "string" ? e = new Hr().readFeature(e) : e = new mi().readFeature(e);
59151
+ const a = new xr(e), o = this.layerHandler.getVectorLayer();
59152
+ return o.getSource().addFeature(a), o.setStyle(
59153
+ Hi({ ...n.style, ...t == null ? void 0 : t.style })
59154
+ ), i.addLayer(o), this.highlightLayer = o, o;
59155
+ }
59156
+ /**
59157
+ * 高亮几何对象
59158
+ * @param {*} geom 几何对象 WKT|GeoJSON
59159
+ * @param {*} options 可选参数 style
59160
+ * @returns 高亮图层
59161
+ */
59162
+ highlight(e, t) {
59163
+ const n = {
59103
59164
  fill: {
59104
59165
  color: "rgba(255, 0, 0, 0.5)"
59105
59166
  },
@@ -59111,52 +59172,26 @@ class _G {
59111
59172
  color: "red",
59112
59173
  radius: 5
59113
59174
  }
59114
- }
59115
- }) {
59116
- const { map: n } = this;
59117
- this.highlightLayer && n.removeLayer(this.highlightLayer), typeof e == "string" ? e = new Hr().readFeature(e) : e = new mi().readFeature(e);
59118
- const i = new xr(e), a = this.layerHandler.getVectorLayer();
59119
- return a.getSource().addFeature(i), a.setStyle(Hi(t.style)), n.addLayer(a), this.highlightLayer = a, a;
59120
- }
59121
- /**
59122
- * 高亮几何对象
59123
- * @param {*} geom 几何对象 WKT|GeoJSON
59124
- * @param {*} options 可选参数 style
59125
- * @returns 高亮图层
59126
- */
59127
- highlight(e, t = {
59128
- fill: {
59129
- color: "rgba(255, 0, 0, 0.5)"
59130
- },
59131
- stroke: {
59132
- color: "red",
59133
- width: 2
59134
- },
59135
- circle: {
59136
- color: "red",
59137
- radius: 5
59138
- }
59139
- }) {
59140
- const { map: n } = this;
59141
- this.highlightLayer && n.removeLayer(this.highlightLayer);
59142
- let i = null;
59143
- if (typeof e == "string" ? i = new H0().wkt2layer(e) : i = new H0().geojson2layer(e), i)
59144
- return i.setStyle(Hi(t)), n.addLayer(i), this.highlightLayer = i, i;
59175
+ }, { map: i } = this;
59176
+ this.highlightLayer && i.removeLayer(this.highlightLayer);
59177
+ let a = null;
59178
+ if (typeof e == "string" ? a = new H0().wkt2layer(e) : a = new H0().geojson2layer(e), a)
59179
+ return a.setStyle(Hi({ ...n, ...t })), i.addLayer(a), this.highlightLayer = a, a;
59145
59180
  }
59146
59181
  /**
59147
59182
  * 飞行到图层
59148
59183
  * @param {*} layer 图层
59149
59184
  * @param {*} options 可选参数 {duration: 1000, minResolution: 0.005274727, maxZoom: 18}
59150
59185
  */
59151
- fly2layer(e, t = {
59152
- duration: 1e3,
59153
- minResolution: 0,
59154
- maxZoom: 18
59155
- }) {
59156
- const { map: n } = this;
59157
- if (n && e) {
59158
- const i = e.getSource();
59159
- n.getView().fit(i.getExtent(), t);
59186
+ fly2layer(e, t) {
59187
+ const n = {
59188
+ duration: 1e3,
59189
+ // minResolution: 0,
59190
+ maxZoom: 18
59191
+ }, { map: i } = this;
59192
+ if (i && e) {
59193
+ const a = e.getSource();
59194
+ i.getView().fit(a.getExtent(), { ...n, ...t });
59160
59195
  }
59161
59196
  }
59162
59197
  /**
@@ -59164,13 +59199,13 @@ class _G {
59164
59199
  * @param {*} extent 范围
59165
59200
  * @param {*} options 可选参数 {duration: 1000, minResolution: 0.005274727, maxZoom: 18}
59166
59201
  */
59167
- fly2extent(e, t = {
59168
- duration: 1e3,
59169
- minResolution: 0,
59170
- maxZoom: 18
59171
- }) {
59172
- const { map: n } = this;
59173
- n && n.getView().fit(e, t);
59202
+ fly2extent(e, t) {
59203
+ const n = {
59204
+ duration: 1e3,
59205
+ // minResolution: 0,
59206
+ maxZoom: 18
59207
+ }, { map: i } = this;
59208
+ i && i.getView().fit(e, { ...n, ...t });
59174
59209
  }
59175
59210
  /**
59176
59211
  * 获取面中心点坐标
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "v-openlayers",
3
3
  "description": "基于vue3+openlayers封装的组件库",
4
4
  "author": "kangjinrui<1092014304@qq.com>",
5
- "version": "2.9.0",
5
+ "version": "2.9.1",
6
6
  "private": false,
7
7
  "main": "package/v-openlayers.mjs",
8
8
  "files": [