v-openlayers 2.9.3 → 2.9.4

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.
@@ -34296,18 +34296,76 @@ function isFunction(obj) {
34296
34296
  function isEmptyObject(obj) {
34297
34297
  return isObject$1(obj) && Object.keys(obj).length === 0;
34298
34298
  }
34299
+ function isGeometry(geometry) {
34300
+ return (geometry == null ? void 0 : geometry.getType) && [
34301
+ "Point",
34302
+ "LineString",
34303
+ "LinearRing",
34304
+ "Polygon",
34305
+ "MultiPoint",
34306
+ "MultiLineString",
34307
+ "MultiPolygon",
34308
+ "GeometryCollection",
34309
+ "Circle"
34310
+ ].includes(geometry == null ? void 0 : geometry.getType());
34311
+ }
34312
+ function isLinearRing(geometry) {
34313
+ return (geometry == null ? void 0 : geometry.getType) && (geometry == null ? void 0 : geometry.getType()) === "LinearRing";
34314
+ }
34315
+ function isMultiPoint(geometry) {
34316
+ return (geometry == null ? void 0 : geometry.getType) && (geometry == null ? void 0 : geometry.getType()) === "MultiPoint";
34317
+ }
34318
+ function isMultiLineString(geometry) {
34319
+ return (geometry == null ? void 0 : geometry.getType) && (geometry == null ? void 0 : geometry.getType()) === "MultiLineString";
34320
+ }
34321
+ function isMultiPolygon(geometry) {
34322
+ return (geometry == null ? void 0 : geometry.getType) && (geometry == null ? void 0 : geometry.getType()) === "MultiPolygon";
34323
+ }
34324
+ function isGeometryCollection(geometry) {
34325
+ return (geometry == null ? void 0 : geometry.getType) && (geometry == null ? void 0 : geometry.getType()) === "GeometryCollection";
34326
+ }
34327
+ function isCircle(geometry) {
34328
+ return (geometry == null ? void 0 : geometry.getType) && (geometry == null ? void 0 : geometry.getType()) === "Circle";
34329
+ }
34330
+ function isPoint(geometry) {
34331
+ return (geometry == null ? void 0 : geometry.getType) && (geometry == null ? void 0 : geometry.getType()) === "Point";
34332
+ }
34333
+ function isLineString(geometry) {
34334
+ return (geometry == null ? void 0 : geometry.getType) && (geometry == null ? void 0 : geometry.getType()) === "LineString";
34335
+ }
34336
+ function isPolygon(geometry) {
34337
+ return (geometry == null ? void 0 : geometry.getType) && (geometry == null ? void 0 : geometry.getType()) === "Polygon";
34338
+ }
34339
+ function isGeoJSON(geojson2) {
34340
+ return (geojson2 == null ? void 0 : geojson2.type) && ((geojson2 == null ? void 0 : geojson2.type) === "FeatureCollection" || (geojson2 == null ? void 0 : geojson2.type) === "Feature");
34341
+ }
34342
+ function isWKT(wkt2) {
34343
+ return typeof wkt2 === "string" && (wkt2.startsWith("POINT") || wkt2.startsWith("LINESTRING") || wkt2.startsWith("POLYGON") || wkt2.startsWith("MULTIPOINT") || wkt2.startsWith("MULTILINESTRING") || wkt2.startsWith("MULTIPOLYGON") || wkt2.startsWith("GEOMETRYCOLLECTION"));
34344
+ }
34299
34345
  const TypeCheckUtils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
34300
34346
  __proto__: null,
34301
34347
  isArray: isArray$1,
34302
34348
  isBlob,
34349
+ isCircle,
34303
34350
  isEmptyObject,
34304
34351
  isFile,
34305
34352
  isFunction,
34353
+ isGeoJSON,
34354
+ isGeometry,
34355
+ isGeometryCollection,
34356
+ isLineString,
34357
+ isLinearRing,
34358
+ isMultiLineString,
34359
+ isMultiPoint,
34360
+ isMultiPolygon,
34306
34361
  isNumber: isNumber$1,
34307
34362
  isObject: isObject$1,
34363
+ isPoint,
34364
+ isPolygon,
34308
34365
  isRegExp,
34309
34366
  isString: isString$1,
34310
- isUndefined
34367
+ isUndefined,
34368
+ isWKT
34311
34369
  }, Symbol.toStringTag, { value: "Module" }));
34312
34370
  function isExternal(path2) {
34313
34371
  return /^(https?:|mailto:|tel:)/.test(path2);
@@ -34817,7 +34875,7 @@ function getImage({
34817
34875
  }) {
34818
34876
  let image = null;
34819
34877
  if (icon == null ? void 0 : icon.src) {
34820
- let { src, fromColor, toColor, scale: scale2 = 1, color } = icon;
34878
+ let { src, fromColor = "currentColor", toColor, scale: scale2 = 1, color } = icon;
34821
34879
  if (fromColor && toColor) {
34822
34880
  src = getSvg(src, fromColor, toColor);
34823
34881
  }
@@ -56748,7 +56806,10 @@ class LayerHandler {
56748
56806
  matrixIds: params2.matrixIds || localParams.matrixIds
56749
56807
  };
56750
56808
  }
56751
- getWmtsUrl({ url, customParams = {} }) {
56809
+ getWmtsUrl({
56810
+ url,
56811
+ customParams = {}
56812
+ }) {
56752
56813
  const _requestParams = __spreadValues({}, customParams);
56753
56814
  if (Object.keys(customParams).length === 0) {
56754
56815
  return url;
@@ -57172,7 +57233,7 @@ class LayerHandler {
57172
57233
  // }
57173
57234
  /**
57174
57235
  * 创建矢量图层
57175
- * @param options
57236
+ * @param options
57176
57237
  * @param {*} options.id
57177
57238
  * @param {*} options.style
57178
57239
  * @returns vector layer
@@ -57191,7 +57252,7 @@ class LayerHandler {
57191
57252
  }
57192
57253
  /**
57193
57254
  * ring
57194
- * @param {*} options
57255
+ * @param {*} options
57195
57256
  * @param {*} options.center
57196
57257
  * @param {*} options.outerR
57197
57258
  * @param {*} options.innerR
@@ -57201,50 +57262,21 @@ class LayerHandler {
57201
57262
  var _a2;
57202
57263
  const layer = this.getVectorLayer();
57203
57264
  const feature2 = new Feature({
57204
- geometry: new GeometryHandler().createRing(options2.center, options2.outerR, options2.innerR)
57265
+ geometry: new GeometryHandler().createRing(
57266
+ options2.center,
57267
+ options2.outerR,
57268
+ options2.innerR
57269
+ )
57205
57270
  });
57206
57271
  (_a2 = layer.getSource()) == null ? void 0 : _a2.addFeature(feature2);
57207
57272
  return layer;
57208
57273
  }
57209
- /**
57210
- * 创建点
57211
- * @param {*} options
57212
- * @param {*} options.layerId
57213
- * @param {*} options.features
57214
- * @param {*} options.zIndex
57215
- * @param {*} options.style
57216
- * @param {*} options.map
57217
- * @param {*} options.clear
57218
- * @returns layer
57219
- */
57220
57274
  createPoints(options2) {
57221
57275
  return this.createCustomLayer(__spreadProps(__spreadValues({}, options2), { multiple: false }));
57222
57276
  }
57223
- /**
57224
- * 创建线
57225
- * @param {*} options
57226
- * @param {*} options.layerId
57227
- * @param {*} options.features
57228
- * @param {*} options.zIndex
57229
- * @param {*} options.style
57230
- * @param {*} options.map
57231
- * @param {*} options.clear
57232
- * @returns layer
57233
- */
57234
57277
  createLines(options2) {
57235
57278
  return this.createCustomLayer(__spreadProps(__spreadValues({}, options2), { multiple: false }));
57236
57279
  }
57237
- /**
57238
- * 创建多线
57239
- * @param {*} options
57240
- * @param {*} options.layerId
57241
- * @param {*} options.features
57242
- * @param {*} options.zIndex
57243
- * @param {*} options.style
57244
- * @param {*} options.map
57245
- * @param {*} options.clear
57246
- * @returns layer
57247
- */
57248
57280
  createMultiLines(options2) {
57249
57281
  return this.createCustomLayer(__spreadProps(__spreadValues({}, options2), { multiple: true }));
57250
57282
  }
@@ -57254,19 +57286,52 @@ class LayerHandler {
57254
57286
  createMultiPolygons(options2) {
57255
57287
  return this.createCustomLayer(__spreadProps(__spreadValues({}, options2), { multiple: true }));
57256
57288
  }
57289
+ createLabels(options2) {
57290
+ return this.createCustomLayer(__spreadProps(__spreadValues({}, options2), {
57291
+ multiple: false
57292
+ }));
57293
+ }
57257
57294
  /**
57258
- * 创建自定义矢量图层
57259
- * @param {*} options
57260
- * @param {*} options.layerId
57261
- * @param {*} options.features
57262
- * @param {*} options.zIndex
57263
- * @param {*} options.style
57264
- * @param {*} options.map
57265
- * @param {*} options.clear
57266
- * @param {*} options.multiple
57267
- * @param {*} options.cluster
57268
- * @param {*} options.geomField
57269
- * @returns layer
57295
+ * 创建矢量点-单个要素
57296
+ * @param options 图层配置选项
57297
+ * @param {*} options.layerId 图层id
57298
+ * @param {*} options.features 要素集合
57299
+ * @param {*} options.zIndex 图层zIndex
57300
+ * @param {*} options.style 图层样式
57301
+ * @param {*} options.map 地图实例
57302
+ * @param {*} options.clear 是否清空图层
57303
+ * @param {*} options.point 点要素
57304
+ * @returns 矢量图层
57305
+ */
57306
+ createPoint(options2) {
57307
+ return this.createCustomLayer(__spreadProps(__spreadValues({
57308
+ multiple: false
57309
+ }, options2), {
57310
+ style: {
57311
+ circle: {
57312
+ radius: 6,
57313
+ fill: {
57314
+ color: "red"
57315
+ }
57316
+ }
57317
+ },
57318
+ features: [options2.point]
57319
+ }));
57320
+ }
57321
+ /**
57322
+ * 创建矢量图层并添加到地图
57323
+ * @param options 图层配置选项
57324
+ * @param {*} options.layerId 图层id
57325
+ * @param {*} options.features 要素集合
57326
+ * @param {*} options.zIndex 图层zIndex
57327
+ * @param {*} options.style 图层样式
57328
+ * @param {*} options.map 地图实例
57329
+ * @param {*} options.clear 是否清空图层
57330
+ * @param {*} options.multiple 是否多要素
57331
+ * @param {*} options.cluster 是否聚类
57332
+ * @param {*} options.geomField 几何字段 默认wktstr
57333
+ * @param {*} options.zoomToLayer 是否缩放到图层
57334
+ * @returns 矢量图层
57270
57335
  */
57271
57336
  createCustomLayer(options2) {
57272
57337
  const {
@@ -61611,25 +61676,12 @@ class WktHandler extends WKT {
61611
61676
  return new WKT().writeFeature(feature2);
61612
61677
  }
61613
61678
  /**
61614
- * 将VectorLayer转换为WKT格式
61615
- * @param layer VectorLayer对象
61616
- * @returns WKT字符串
61679
+ * 将WKT转换为Feature对象
61680
+ * @param wkt WKT字符串
61681
+ * @returns Feature对象
61617
61682
  */
61618
- layer2wkt(layer) {
61619
- var _a2;
61620
- if (layer) {
61621
- const features = ((_a2 = layer.getSource()) == null ? void 0 : _a2.getFeatures()) || [];
61622
- if (features.length === 1) {
61623
- const feature2 = features[0];
61624
- return new WKT().writeFeature(feature2);
61625
- } else if (features.length > 1) {
61626
- return new WKT().writeFeatures(features);
61627
- } else {
61628
- return "layer is null";
61629
- }
61630
- } else {
61631
- return "layer is null";
61632
- }
61683
+ wkt2feature(wkt2) {
61684
+ return new WKT().readFeature(wkt2);
61633
61685
  }
61634
61686
  /**
61635
61687
  * 将GeoJSON转换为WKT格式
@@ -61651,6 +61703,27 @@ class WktHandler extends WKT {
61651
61703
  const geojson2 = new GeoJSON().writeFeaturesObject(features);
61652
61704
  return geojson2;
61653
61705
  }
61706
+ /**
61707
+ * 将VectorLayer转换为WKT格式
61708
+ * @param layer VectorLayer对象
61709
+ * @returns WKT字符串
61710
+ */
61711
+ layer2wkt(layer) {
61712
+ var _a2;
61713
+ if (layer) {
61714
+ const features = ((_a2 = layer.getSource()) == null ? void 0 : _a2.getFeatures()) || [];
61715
+ if (features.length === 1) {
61716
+ const feature2 = features[0];
61717
+ return new WKT().writeFeature(feature2);
61718
+ } else if (features.length > 1) {
61719
+ return new WKT().writeFeatures(features);
61720
+ } else {
61721
+ return "layer is null";
61722
+ }
61723
+ } else {
61724
+ return "layer is null";
61725
+ }
61726
+ }
61654
61727
  /**
61655
61728
  * 将WKT转换为VectorLayer
61656
61729
  * @param wkt WKT字符串
@@ -61941,15 +62014,15 @@ function distance(from, to, options2 = {}) {
61941
62014
  }
61942
62015
  function coordEach(geojson2, callback, excludeWrapCoord) {
61943
62016
  if (geojson2 === null) return;
61944
- var j, k, l, geometry, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection, type = geojson2.type, isFeatureCollection = type === "FeatureCollection", isFeature = type === "Feature", stop = isFeatureCollection ? geojson2.features.length : 1;
62017
+ var j, k, l, geometry, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection2, type = geojson2.type, isFeatureCollection = type === "FeatureCollection", isFeature = type === "Feature", stop = isFeatureCollection ? geojson2.features.length : 1;
61945
62018
  for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
61946
62019
  geometryMaybeCollection = isFeatureCollection ? geojson2.features[featureIndex].geometry : isFeature ? geojson2.geometry : geojson2;
61947
- isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
61948
- stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
62020
+ isGeometryCollection2 = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
62021
+ stopG = isGeometryCollection2 ? geometryMaybeCollection.geometries.length : 1;
61949
62022
  for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
61950
62023
  var multiFeatureIndex = 0;
61951
62024
  var geometryIndex = 0;
61952
- geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
62025
+ geometry = isGeometryCollection2 ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
61953
62026
  if (geometry === null) continue;
61954
62027
  coords = geometry.coordinates;
61955
62028
  var geomType = geometry.type;
@@ -62054,16 +62127,16 @@ function featureReduce(geojson2, callback, initialValue) {
62054
62127
  return previousValue;
62055
62128
  }
62056
62129
  function geomEach(geojson2, callback) {
62057
- var i, j, g, geometry, stopG, geometryMaybeCollection, isGeometryCollection, featureProperties, featureBBox, featureId2, featureIndex = 0, isFeatureCollection = geojson2.type === "FeatureCollection", isFeature = geojson2.type === "Feature", stop = isFeatureCollection ? geojson2.features.length : 1;
62130
+ var i, j, g, geometry, stopG, geometryMaybeCollection, isGeometryCollection2, featureProperties, featureBBox, featureId2, featureIndex = 0, isFeatureCollection = geojson2.type === "FeatureCollection", isFeature = geojson2.type === "Feature", stop = isFeatureCollection ? geojson2.features.length : 1;
62058
62131
  for (i = 0; i < stop; i++) {
62059
62132
  geometryMaybeCollection = isFeatureCollection ? geojson2.features[i].geometry : isFeature ? geojson2.geometry : geojson2;
62060
62133
  featureProperties = isFeatureCollection ? geojson2.features[i].properties : isFeature ? geojson2.properties : {};
62061
62134
  featureBBox = isFeatureCollection ? geojson2.features[i].bbox : isFeature ? geojson2.bbox : void 0;
62062
62135
  featureId2 = isFeatureCollection ? geojson2.features[i].id : isFeature ? geojson2.id : void 0;
62063
- isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
62064
- stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
62136
+ isGeometryCollection2 = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
62137
+ stopG = isGeometryCollection2 ? geometryMaybeCollection.geometries.length : 1;
62065
62138
  for (g = 0; g < stopG; g++) {
62066
- geometry = isGeometryCollection ? geometryMaybeCollection.geometries[g] : geometryMaybeCollection;
62139
+ geometry = isGeometryCollection2 ? geometryMaybeCollection.geometries[g] : geometryMaybeCollection;
62067
62140
  if (geometry === null) {
62068
62141
  if (callback(
62069
62142
  null,
@@ -76727,6 +76800,26 @@ class GeojsonHandler extends GeoJSON {
76727
76800
  });
76728
76801
  return vectorLayer;
76729
76802
  }
76803
+ /**
76804
+ * 将VectorLayer转换为GeoJSON格式
76805
+ * @param layer VectorLayer对象
76806
+ * @returns GeoJSON对象
76807
+ */
76808
+ layer2geojson(layer) {
76809
+ var _a2;
76810
+ if (layer) {
76811
+ const features = (_a2 = layer.getSource()) == null ? void 0 : _a2.getFeatures();
76812
+ if (features.length === 1) {
76813
+ return new GeoJSON().writeFeatureObject(features[0]);
76814
+ } else if (features.length > 1) {
76815
+ return new GeoJSON().writeFeaturesObject(features);
76816
+ } else {
76817
+ return { type: "FeatureCollection", features: [] };
76818
+ }
76819
+ } else {
76820
+ return { type: "FeatureCollection", features: [] };
76821
+ }
76822
+ }
76730
76823
  }
76731
76824
  class Base {
76732
76825
  constructor() {
@@ -76917,7 +77010,7 @@ class MeasurementManager {
76917
77010
  /**
76918
77011
  * 创建测量图层
76919
77012
  */
76920
- createMeasurementLayer(geometry, isPolygon) {
77013
+ createMeasurementLayer(geometry, isPolygon2) {
76921
77014
  const feature2 = new Feature({ geometry });
76922
77015
  const styles = [
76923
77016
  STYLE_CONFIG.RESULT_STYLE,
@@ -76925,7 +77018,7 @@ class MeasurementManager {
76925
77018
  geometry: (feature22) => {
76926
77019
  const geom = feature22.getGeometry();
76927
77020
  if (!geom) return null;
76928
- const coordinates2 = isPolygon ? geom.getCoordinates()[0] : geom.getCoordinates();
77021
+ const coordinates2 = isPolygon2 ? geom.getCoordinates()[0] : geom.getCoordinates();
76929
77022
  return coordinates2 ? new MultiPoint(coordinates2) : null;
76930
77023
  }
76931
77024
  }))
@@ -76986,9 +77079,9 @@ class MeasurementManager {
76986
77079
  this.state.measureTooltip.setOffset([0, -7]);
76987
77080
  }
76988
77081
  if (this.state.lastGeometry) {
76989
- const isPolygon = this.state.curMeasureType === MEASURE_TYPES.AREA;
76990
- const layer = this.createMeasurementLayer(this.state.lastGeometry, isPolygon);
76991
- if (isPolygon) {
77082
+ const isPolygon2 = this.state.curMeasureType === MEASURE_TYPES.AREA;
77083
+ const layer = this.createMeasurementLayer(this.state.lastGeometry, isPolygon2);
77084
+ if (isPolygon2) {
76992
77085
  this.state.polygonLayerArray.push(layer);
76993
77086
  } else {
76994
77087
  this.state.polylineLayerArray.push(layer);
@@ -78663,6 +78756,10 @@ class VMap {
78663
78756
  * @param {*} options 可选参数 {duration: 1000, minResolution: 0, maxZoom: 18}
78664
78757
  */
78665
78758
  zoomToExtent(extent, options2 = {}) {
78759
+ if (!extent || extent.length === 0) {
78760
+ console.error("参数不合法: extent不能为空");
78761
+ return;
78762
+ }
78666
78763
  const defaultOptions = {
78667
78764
  duration: 1e3,
78668
78765
  maxZoom: 18
@@ -78675,6 +78772,10 @@ class VMap {
78675
78772
  * @param {*} options 可选参数 {duration: 1000, minResolution: 0, maxZoom: 18}
78676
78773
  */
78677
78774
  zoomToPoint(coordinate, options2 = {}) {
78775
+ if (!coordinate || coordinate.length === 0) {
78776
+ console.error("参数不合法: coordinate不能为空");
78777
+ return;
78778
+ }
78678
78779
  const defaultOptions = {
78679
78780
  duration: 1e3,
78680
78781
  maxZoom: 18
@@ -78688,6 +78789,10 @@ class VMap {
78688
78789
  * @param {*} options 可选参数 {duration: 1000, minResolution: 0, maxZoom: 18}
78689
78790
  */
78690
78791
  zoomToGeometry(geometry, options2 = {}) {
78792
+ if (!geometry) {
78793
+ console.error("参数不合法: geometry不能为空");
78794
+ return;
78795
+ }
78691
78796
  const defaultOptions = {
78692
78797
  duration: 1e3,
78693
78798
  maxZoom: 18
@@ -78695,12 +78800,42 @@ class VMap {
78695
78800
  let view2 = this.map.getView();
78696
78801
  view2.fit(geometry, __spreadValues(__spreadValues({}, defaultOptions), options2));
78697
78802
  }
78803
+ /**
78804
+ * 缩放到集合对象
78805
+ * @param {*} obj geometry | WKT | GeoJSON
78806
+ */
78807
+ zoomToObject(obj, options2 = {}) {
78808
+ if (!obj) {
78809
+ console.error("参数不合法: obj不能为空");
78810
+ return;
78811
+ }
78812
+ const defaultOptions = {
78813
+ duration: 1e3,
78814
+ maxZoom: 18
78815
+ };
78816
+ if (isWKT(obj)) {
78817
+ const geometry = new WKT().readGeometry(obj);
78818
+ this.zoomToGeometry(geometry, __spreadValues(__spreadValues({}, defaultOptions), options2));
78819
+ } else if (isGeoJSON(obj)) {
78820
+ const geometry = new GeoJSON().readGeometry(obj);
78821
+ this.zoomToGeometry(geometry, __spreadValues(__spreadValues({}, defaultOptions), options2));
78822
+ } else if (isGeometry(obj)) {
78823
+ this.zoomToGeometry(obj, __spreadValues(__spreadValues({}, defaultOptions), options2));
78824
+ } else {
78825
+ console.error("参数不合法: obj类型不支持");
78826
+ return;
78827
+ }
78828
+ }
78698
78829
  /**
78699
78830
  * 缩放到图层
78700
78831
  * @param {*} id 图层id
78701
78832
  * @param {*} options 可选参数 {duration: 1000, minResolution: 0, maxZoom: 18}
78702
78833
  */
78703
78834
  zoomToLayerById(id2, options2 = {}) {
78835
+ if (!id2) {
78836
+ console.error("参数不合法: id不能为空");
78837
+ return;
78838
+ }
78704
78839
  const defaultOptions = {
78705
78840
  duration: 1e3,
78706
78841
  maxZoom: 18
@@ -78714,6 +78849,10 @@ class VMap {
78714
78849
  * @param {*} options 可选参数 {maxZoom: 18, duration: 1000 ,minResolution: 0}
78715
78850
  */
78716
78851
  zoomToLayer(layer, options2 = {}) {
78852
+ if (!layer) {
78853
+ console.error("参数不合法: layer不能为空");
78854
+ return;
78855
+ }
78717
78856
  const defaultOptions = {
78718
78857
  duration: 1e3,
78719
78858
  maxZoom: 18
@@ -78733,6 +78872,10 @@ class VMap {
78733
78872
  * @param {*} options 可选参数 {maxZoom: 18, duration: 1000 ,minResolution: 0}
78734
78873
  */
78735
78874
  zoomToLayers(layers, options2 = {}) {
78875
+ if (!layers || layers.length === 0) {
78876
+ console.error("参数不合法: layers不能为空");
78877
+ return;
78878
+ }
78736
78879
  const defaultOptions = {
78737
78880
  duration: 1e3,
78738
78881
  maxZoom: 18
@@ -78932,21 +79075,47 @@ class VMap {
78932
79075
  }
78933
79076
  /**
78934
79077
  * 获取面中心点坐标
78935
- * @param {*} polygon 面几何对象
79078
+ * @param {*} polygon 面几何对象 Polygon|WKT|GeoJSON
78936
79079
  * @returns 中心点坐标 [x,y]
78937
79080
  */
78938
79081
  getCenterByPolygon(polygon2) {
78939
- const extent = polygon2.getExtent();
78940
- return [(extent[2] + extent[0]) / 2, (extent[3] + extent[1]) / 2];
79082
+ let geometry = null;
79083
+ if (isPolygon(polygon2)) {
79084
+ geometry = polygon2;
79085
+ } else if (isWKT(polygon2)) {
79086
+ geometry = new WKT().readGeometry(polygon2);
79087
+ } else if (isGeoJSON(polygon2)) {
79088
+ geometry = new GeoJSON().readGeometry(polygon2);
79089
+ }
79090
+ if (!geometry) {
79091
+ console.error("参数不合法");
79092
+ return null;
79093
+ }
79094
+ return geometry.getInteriorPoint().getCoordinates();
78941
79095
  }
78942
79096
  /**
78943
79097
  * 获取线中心点
78944
- * @param {*} linestring 线几何对象
79098
+ * @param {*} linestring 几何对象 LineString|WKT|GeoJSON
78945
79099
  * @returns 线几何对象中心点坐标 [x,y]
78946
79100
  */
78947
79101
  getCenterByLinestring(linestring) {
78948
- const coordinates2 = linestring.getCoordinates();
78949
- return coordinates2[Math.floor(coordinates2.length / 2)];
79102
+ let geometry = null;
79103
+ if (isLineString(linestring)) {
79104
+ geometry = linestring;
79105
+ } else if (isWKT(linestring)) {
79106
+ geometry = new WKT().readGeometry(linestring);
79107
+ } else if (isGeoJSON(linestring)) {
79108
+ geometry = new GeoJSON().readGeometry(linestring);
79109
+ }
79110
+ if (!geometry) return null;
79111
+ const coordinates2 = geometry.getCoordinates();
79112
+ if (coordinates2.length === 2) {
79113
+ const x = (coordinates2[0][0] + coordinates2[1][0]) / 2;
79114
+ const y = (coordinates2[0][1] + coordinates2[1][1]) / 2;
79115
+ return [x, y];
79116
+ } else {
79117
+ return coordinates2[Math.floor(coordinates2.length / 2)];
79118
+ }
78950
79119
  }
78951
79120
  /**
78952
79121
  * 计算长度
@@ -78967,7 +79136,7 @@ class VMap {
78967
79136
  /**
78968
79137
  * 计算面积
78969
79138
  * @param {*} layer 面图层
78970
- * @param {*} projection 投影坐标系
79139
+ * @param {*} projection 投影坐标系 默认EPSG:4326
78971
79140
  * @returns 面图层面积(单位:平方公里)
78972
79141
  */
78973
79142
  getAreaByLayer(layer, projection2 = "EPSG:4326") {
@@ -78982,15 +79151,42 @@ class VMap {
78982
79151
  }
78983
79152
  /**
78984
79153
  * 计算面积
78985
- * @param {*} polygon wkt | geojson
78986
- * @param {*} projection EPSG:4326
79154
+ * @param {*} polygon 面几何对象 Polygon|WKT|GeoJSON
79155
+ * @param {*} projection 投影坐标系 默认EPSG:4326
78987
79156
  * @returns 面积(单位:平方公里)
78988
79157
  */
78989
79158
  getAreaByPolygon(polygon2, projection2 = "EPSG:4326") {
78990
- const geom = typeof polygon2 === "string" ? new WKT().readGeometry(polygon2) : new GeoJSON().readGeometry(polygon2);
78991
- const area = getArea(geom, { projection: projection2 });
79159
+ let geometry = null;
79160
+ if (isPolygon(polygon2)) {
79161
+ geometry = polygon2;
79162
+ } else if (isWKT(polygon2)) {
79163
+ geometry = new WKT().readGeometry(polygon2);
79164
+ } else if (isGeoJSON(polygon2)) {
79165
+ geometry = new GeoJSON().readGeometry(polygon2);
79166
+ }
79167
+ if (!geometry) return null;
79168
+ const area = getArea(geometry, { projection: projection2 });
78992
79169
  return Number(area / 1e6);
78993
79170
  }
79171
+ /**
79172
+ * 计算长度
79173
+ * @param {*} linestring 线几何对象 LineString|WKT|GeoJSON
79174
+ * @param {*} projection 投影坐标系 默认EPSG:4326
79175
+ * @returns 长度(单位:米)
79176
+ */
79177
+ getLengthByLinestring(linestring, projection2 = "EPSG:4326") {
79178
+ let geometry = null;
79179
+ if (isLineString(linestring)) {
79180
+ geometry = linestring;
79181
+ } else if (isWKT(linestring)) {
79182
+ geometry = new WKT().readGeometry(linestring);
79183
+ } else if (isGeoJSON(linestring)) {
79184
+ geometry = new GeoJSON().readGeometry(linestring);
79185
+ }
79186
+ if (!geometry) return null;
79187
+ const length2 = getLength(geometry, { projection: projection2 });
79188
+ return Number(length2);
79189
+ }
78994
79190
  /**
78995
79191
  * @description: 清理资源
78996
79192
  */
@@ -79475,7 +79671,7 @@ class OlHandler extends VMap {
79475
79671
  return vector;
79476
79672
  }
79477
79673
  }
79478
- function getOlHandler(domid) {
79674
+ function getOlHandler(domid = "v-ol-map-id") {
79479
79675
  return new OlHandler(domid);
79480
79676
  }
79481
79677
  const useEmits$2 = [
@@ -81195,7 +81391,7 @@ const _hoisted_1$a = ["id"];
81195
81391
  const __default__$l = defineComponent({
81196
81392
  name: "OlMap"
81197
81393
  });
81198
- const _sfc_main$m = /* @__PURE__ */ Object.assign(__default__$l, {
81394
+ const _sfc_main$m = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, __default__$l), {
81199
81395
  props: {
81200
81396
  mapConfig: {
81201
81397
  type: Object,
@@ -81283,6 +81479,7 @@ const _sfc_main$m = /* @__PURE__ */ Object.assign(__default__$l, {
81283
81479
  showBasemap: showBasemap.value,
81284
81480
  interactions: props.interactions
81285
81481
  }).then(({ map }) => {
81482
+ var _a2, _b2, _c;
81286
81483
  olInstance.isSyncing = isSyncing;
81287
81484
  mapReady.value = true;
81288
81485
  map.set("mouseStatus", V_MOUSE_STATUS.none);
@@ -81290,7 +81487,12 @@ const _sfc_main$m = /* @__PURE__ */ Object.assign(__default__$l, {
81290
81487
  emits("ready", olInstance);
81291
81488
  curZoom.value = map.getView().getZoom() - 1;
81292
81489
  bindEvent();
81293
- createLayers(mapConfig2.value.businessLayers);
81490
+ if (mapConfig2.value.businessLayers instanceof Array) {
81491
+ createLayers(mapConfig2.value.businessLayers);
81492
+ }
81493
+ if (mapConfig2.value.maskLayer && ((_a2 = mapConfig2.value.maskLayer) == null ? void 0 : _a2.visible) && ((_c = (_b2 = mapConfig2.value.maskLayer) == null ? void 0 : _b2.innerPolygons) == null ? void 0 : _c.length) > 0) {
81494
+ createMaskLayer(mapConfig2.value.maskLayer);
81495
+ }
81294
81496
  });
81295
81497
  });
81296
81498
  let mousePoint = null;
@@ -81376,6 +81578,33 @@ const _sfc_main$m = /* @__PURE__ */ Object.assign(__default__$l, {
81376
81578
  };
81377
81579
  addLayer(layers);
81378
81580
  };
81581
+ const createMaskLayer = ({
81582
+ id: id2 = VcUtils.uuidOnlyStr(),
81583
+ zIndex = 9999,
81584
+ visible: visible2 = false,
81585
+ style,
81586
+ outerPolygon,
81587
+ innerPolygons
81588
+ }) => {
81589
+ const layer = olInstance.layerHandler.getVectorLayer({
81590
+ id: id2,
81591
+ visible: visible2,
81592
+ style: getStyle(style)
81593
+ });
81594
+ const polygons = [outerPolygon];
81595
+ innerPolygons.forEach((element) => {
81596
+ polygons.push(element);
81597
+ });
81598
+ const outer = new Polygon(polygons);
81599
+ const feature2 = new Feature({
81600
+ geometry: outer
81601
+ });
81602
+ layer.getSource().addFeature(feature2);
81603
+ olInstance.map.addLayer(layer);
81604
+ setTimeout(() => {
81605
+ layer.setZIndex(zIndex);
81606
+ }, 0);
81607
+ };
81379
81608
  ref(false);
81380
81609
  let activeIdentify = ref("");
81381
81610
  let identifyList = ref([]);
@@ -81425,8 +81654,8 @@ const _sfc_main$m = /* @__PURE__ */ Object.assign(__default__$l, {
81425
81654
  ], 32);
81426
81655
  };
81427
81656
  }
81428
- });
81429
- const OlMap = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["__scopeId", "data-v-3bb39f11"]]);
81657
+ }));
81658
+ const OlMap = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["__scopeId", "data-v-ba4d3e4b"]]);
81430
81659
  const basemapSrc = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAWVJREFUWEftls9Kw0AQxr9JQTx4FxTP3hoPepUQ0ZvRiz5Ai0L6DuJT+KdI+wCetBexxRS8i43voOgbBA8Z2ZKWIG52mxjNYXPd2Znffpnd+QganzeIfDCOAaxphOuEjAC0ezvzl6SK9gafPjg+V8XlXPfVAP1I0No5C6i2jXQAWJWlwHr83wAwANVRYKv7csPMGwCW0k21sLJaoMfUW8cKuJ1Q2umlA7jd8BqMAwB3HNPJ8Kj+lOb2+lGZ1xDkdsJ3AIsc0/r34gLkLwDGJwya9o8NaQCMAkYBo0AVFCjXkk0Gkewl3L2PWkQ4U8+1HBGElpgFmU+xSJtACFv+W+Y0BFnt3vbchRZAjrNNR7xM2UlOA1AJBV6FD5QZkjz/37l6dizLGgJ4C5r2clYOSszonsySzQogilOtdkrMDhHdPjTq+5kAKlM6K0A6XnUDROzUhiXmdFP4wyJFAXyA8Bg07EOdPF/o6uB9Vuth3wAAAABJRU5ErkJggg==";
81431
81660
  const useProps$2 = {
81432
81661
  position: {
@@ -82811,7 +83040,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
82811
83040
  watch(
82812
83041
  features,
82813
83042
  () => {
82814
- initLayer();
83043
+ initLayer(false);
82815
83044
  },
82816
83045
  {
82817
83046
  deep: true
@@ -82849,28 +83078,29 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
82849
83078
  return true;
82850
83079
  }
82851
83080
  };
82852
- const initLayer = () => {
83081
+ const initLayer = (isCheckId = true) => {
82853
83082
  const layerId2 = getLayerId();
82854
- if (isValidLayerId()) {
82855
- if (clusterOptions.value) {
82856
- olHandler.removeLayerById(layerId2);
82857
- layerObject.value = olHandler.getLayerHandler().getClusterLayer(features.value, __spreadValues({
82858
- id: layerId2,
82859
- visible: visible2.value,
82860
- style: layerStyle.value,
82861
- zIndex: zIndex.value,
82862
- geomField: geomField.value
82863
- }, clusterOptions.value));
82864
- olHandler.map.addLayer(layerObject.value);
82865
- } else {
82866
- layerObject.value = olHandler.getLayerHandler().createCustomLayer(__spreadProps(__spreadValues({}, props), {
82867
- clear: true,
82868
- layerId: layerId2,
82869
- style: layerStyle.value
82870
- }));
82871
- }
82872
- emits("ready", layerObject.value);
83083
+ if (isCheckId && !isValidLayerId()) {
83084
+ return;
83085
+ }
83086
+ if (clusterOptions.value) {
83087
+ olHandler.removeLayerById(layerId2);
83088
+ layerObject.value = olHandler.getLayerHandler().getClusterLayer(features.value, __spreadValues({
83089
+ id: layerId2,
83090
+ visible: visible2.value,
83091
+ style: layerStyle.value,
83092
+ zIndex: zIndex.value,
83093
+ geomField: geomField.value
83094
+ }, clusterOptions.value));
83095
+ olHandler.map.addLayer(layerObject.value);
83096
+ } else {
83097
+ layerObject.value = olHandler.getLayerHandler().createCustomLayer(__spreadProps(__spreadValues({}, props), {
83098
+ clear: true,
83099
+ layerId: layerId2,
83100
+ style: layerStyle.value
83101
+ }));
82873
83102
  }
83103
+ emits("ready", layerObject.value);
82874
83104
  };
82875
83105
  const initEvent = () => {
82876
83106
  handleSelect();