vue-openlayers-plugin 1.0.72 → 1.0.73

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.
Files changed (29) hide show
  1. package/lib/{index-034c9e0d.mjs → index-363194c0.mjs} +407 -88
  2. package/lib/{index.es-6551e4c0.mjs → index.es-a7ad7c48.mjs} +1 -1
  3. package/lib/index.esm.js +1 -1
  4. package/lib/index.umd.js +406 -87
  5. package/package.json +1 -1
  6. package/types/src/components/CustomOpenlayer/components/dialogs/LayerPanel.vue.d.ts +46 -164
  7. package/types/src/components/CustomOpenlayer/components/dialogs/LayerPanel.vue.d.ts.map +1 -1
  8. package/types/src/components/CustomOpenlayer/types/index.d.ts +24 -3
  9. package/types/src/components/CustomOpenlayer/types/index.d.ts.map +1 -1
  10. package/types/src/components/CustomOpenlayer/utils/LayerManager.d.ts.map +1 -1
  11. package/types/src/components/CustomOpenlayer/utils/LayerTreeManager.d.ts.map +1 -1
  12. package/types/src/components/CustomOpenlayer/utils/coordinateTransform.d.ts +28 -0
  13. package/types/src/components/CustomOpenlayer/utils/coordinateTransform.d.ts.map +1 -0
  14. package/types/src/components/CustomOpenlayer/utils/index.d.ts +1 -0
  15. package/types/src/components/CustomOpenlayer/utils/index.d.ts.map +1 -1
  16. package/types/src/components/CustomOpenlayer/utils/layerManager.d.ts +13 -0
  17. package/types/src/components/CustomOpenlayer/utils/layers/BaseLayer.d.ts +5 -0
  18. package/types/src/components/CustomOpenlayer/utils/layers/BaseLayer.d.ts.map +1 -1
  19. package/types/src/components/CustomOpenlayer/utils/layers/GMLLayerHandler.d.ts.map +1 -1
  20. package/types/src/components/CustomOpenlayer/utils/layers/GeoJSONLayerHandler.d.ts.map +1 -1
  21. package/types/src/components/CustomOpenlayer/utils/layers/KMLLayerHandler.d.ts.map +1 -1
  22. package/types/src/components/CustomOpenlayer/utils/layers/TiandituLayerHandler.d.ts.map +1 -1
  23. package/types/src/components/CustomOpenlayer/utils/layers/TileLayerHandler.d.ts.map +1 -1
  24. package/types/src/components/CustomOpenlayer/utils/layers/VectorTileLayerHandler.d.ts.map +1 -1
  25. package/types/src/components/CustomOpenlayer/utils/layers/WKTLayerHandler.d.ts.map +1 -1
  26. package/types/src/components/CustomOpenlayer/utils/layers/WMSLayerHandler.d.ts.map +1 -1
  27. package/types/src/components/CustomOpenlayer/utils/layers/WMTSLayerHandler.d.ts.map +1 -1
  28. package/types/src/components/CustomOpenlayer/utils/mapManager.d.ts.map +1 -1
  29. package/types/tsconfig.tsbuildinfo +1 -1
package/lib/index.umd.js CHANGED
@@ -81994,6 +81994,24 @@ ${this.attributes_.map(
81994
81994
  this.config.opacity = this.config.opacity / 100;
81995
81995
  }
81996
81996
  }
81997
+ /**
81998
+ * 注册自定义投影
81999
+ * @returns 注册的投影代码,如果没有注册则返回 undefined
82000
+ */
82001
+ registerCustomProjection() {
82002
+ const projectionCode = this.config.projection;
82003
+ const projectionDefinition = this.config.projectionDefinition;
82004
+ if (projectionCode && projectionDefinition) {
82005
+ try {
82006
+ proj4$1.defs(projectionCode, projectionDefinition);
82007
+ register$3(proj4$1);
82008
+ return projectionCode;
82009
+ } catch (error2) {
82010
+ console.error(`Failed to register projection ${projectionCode}:`, error2);
82011
+ }
82012
+ }
82013
+ return void 0;
82014
+ }
81997
82015
  /**
81998
82016
  * 获取图层实例(同步方法,用于向后兼容)
81999
82017
  */
@@ -82451,6 +82469,7 @@ ${this.attributes_.map(
82451
82469
  * 创建瓦片数据源
82452
82470
  */
82453
82471
  createTileSource() {
82472
+ this.registerCustomProjection();
82454
82473
  let sourceType = this.getSourceTypeFromLayerType();
82455
82474
  sourceType = sourceType || "xyz";
82456
82475
  switch (sourceType.toLowerCase()) {
@@ -82569,7 +82588,8 @@ ${this.attributes_.map(
82569
82588
  * 创建WMS数据源
82570
82589
  */
82571
82590
  createWMSSource() {
82572
- return new ImageWMS$1({
82591
+ this.registerCustomProjection();
82592
+ const options = {
82573
82593
  url: this.config.url,
82574
82594
  params: {
82575
82595
  "LAYERS": this.config.wmsLayers || "",
@@ -82579,7 +82599,11 @@ ${this.attributes_.map(
82579
82599
  },
82580
82600
  ratio: 1,
82581
82601
  crossOrigin: "anonymous"
82582
- });
82602
+ };
82603
+ if (this.config.projection) {
82604
+ options.projection = this.config.projection;
82605
+ }
82606
+ return new ImageWMS$1(options);
82583
82607
  }
82584
82608
  /**
82585
82609
  * 更新WMS参数
@@ -82864,13 +82888,17 @@ ${this.attributes_.map(
82864
82888
  * 创建WMTS数据源
82865
82889
  */
82866
82890
  createWMTSSource() {
82867
- if (this.config.url && !this.capabilities) {
82868
- throw new Error("WMTS capabilities must be loaded first. Use loadCapabilities() method.");
82891
+ const wmtsConfig = this.config.wmtsConfig || {};
82892
+ const url = wmtsConfig.url || this.config.url;
82893
+ if (!url) {
82894
+ throw new Error("WMTS URL is required");
82869
82895
  }
82896
+ if (this.config.url && !this.capabilities && !wmtsConfig.resolutions)
82897
+ ;
82870
82898
  if (this.capabilities) {
82871
82899
  const options = optionsFromCapabilities(this.capabilities, {
82872
- layer: this.config.wmtsLayer || "",
82873
- matrixSet: this.config.wmtsMatrixSet || "EPSG:4326"
82900
+ layer: wmtsConfig.layer || this.config.layerName || "",
82901
+ matrixSet: wmtsConfig.matrixSet || this.config.matrixSet || "EPSG:4326"
82874
82902
  });
82875
82903
  if (!options) {
82876
82904
  throw new Error("Failed to create WMTS options from capabilities");
@@ -82886,26 +82914,46 @@ ${this.attributes_.map(
82886
82914
  crossOrigin: "anonymous"
82887
82915
  });
82888
82916
  } else {
82889
- const projection2 = get$c("EPSG:4326");
82890
- const projectionExtent = projection2.getExtent();
82891
- const size2 = Math.sqrt(projectionExtent[2] - projectionExtent[0]) / 256;
82892
- const resolutions = new Array(19);
82893
- const matrixIds = new Array(19);
82894
- for (let z2 = 0; z2 < 19; ++z2) {
82895
- resolutions[z2] = size2 / Math.pow(2, z2);
82896
- matrixIds[z2] = z2;
82917
+ const projectionCode = wmtsConfig.projection || this.config.projection || "EPSG:4326";
82918
+ const projectionDefinition = wmtsConfig.projectionDefinition || this.config.projectionDefinition;
82919
+ if (projectionDefinition) {
82920
+ proj4$1.defs(projectionCode, projectionDefinition);
82921
+ register$3(proj4$1);
82897
82922
  }
82923
+ const projection2 = get$c(projectionCode);
82924
+ const projectionExtent = projection2.getExtent();
82925
+ let resolutions = wmtsConfig.resolutions || this.config.resolutions;
82926
+ let matrixIds = wmtsConfig.matrixIds || this.config.matrixIds;
82927
+ const tileSize = wmtsConfig.tileSize || 256;
82928
+ const tileSizeNumber = typeof tileSize === "number" ? tileSize : tileSize[0];
82929
+ if (!resolutions) {
82930
+ const width = projectionExtent[2] - projectionExtent[0];
82931
+ const size2 = width / tileSizeNumber;
82932
+ const zoomLevels = 19;
82933
+ resolutions = new Array(zoomLevels);
82934
+ for (let z2 = 0; z2 < zoomLevels; ++z2) {
82935
+ resolutions[z2] = size2 / Math.pow(2, z2);
82936
+ }
82937
+ }
82938
+ if (!matrixIds) {
82939
+ matrixIds = new Array(resolutions.length);
82940
+ for (let z2 = 0; z2 < resolutions.length; ++z2) {
82941
+ matrixIds[z2] = z2.toString();
82942
+ }
82943
+ }
82944
+ const origin = wmtsConfig.origin || this.config.origin || [projectionExtent[0], projectionExtent[3]];
82898
82945
  return new WMTS$3({
82899
- url: this.config.url,
82900
- layer: this.config.wmtsLayer || "",
82901
- matrixSet: this.config.wmtsMatrixSet || "EPSG:4326",
82902
- format: "image/png",
82903
- projection: "EPSG:4326",
82904
- style: this.config.wmtsStyle || "default",
82946
+ url,
82947
+ layer: wmtsConfig.layer || this.config.layerName || "",
82948
+ matrixSet: wmtsConfig.matrixSet || this.config.matrixSet || projectionCode,
82949
+ format: wmtsConfig.format || this.config.format || "image/png",
82950
+ projection: projectionCode,
82951
+ style: wmtsConfig.style || this.config.style || "default",
82905
82952
  tileGrid: new WMTSTileGrid$3({
82906
- origin: [projectionExtent[0], projectionExtent[3]],
82953
+ origin,
82907
82954
  resolutions,
82908
- matrixIds
82955
+ matrixIds,
82956
+ tileSize
82909
82957
  }),
82910
82958
  crossOrigin: "anonymous"
82911
82959
  });
@@ -82949,21 +82997,21 @@ ${this.attributes_.map(
82949
82997
  * 设置图层
82950
82998
  */
82951
82999
  setLayer(layer2) {
82952
- this.config.wmtsLayer = layer2;
83000
+ this.config.layerName = layer2;
82953
83001
  this.layer = null;
82954
83002
  }
82955
83003
  /**
82956
83004
  * 设置矩阵集
82957
83005
  */
82958
83006
  setMatrixSet(matrixSet) {
82959
- this.config.wmtsMatrixSet = matrixSet;
83007
+ this.config.matrixSet = matrixSet;
82960
83008
  this.layer = null;
82961
83009
  }
82962
83010
  /**
82963
83011
  * 设置样式
82964
83012
  */
82965
83013
  setWMTSStyle(style) {
82966
- this.config.wmtsStyle = style;
83014
+ this.config.style = style;
82967
83015
  this.layer = null;
82968
83016
  }
82969
83017
  /**
@@ -83768,10 +83816,13 @@ ${this.attributes_.map(
83768
83816
  */
83769
83817
  createVectorSource() {
83770
83818
  var _a3;
83819
+ this.registerCustomProjection();
83771
83820
  const format2 = new GeoJSON$4();
83772
83821
  const mapProjection = ((_a3 = this.map) == null ? void 0 : _a3.getView().getProjection().getCode()) || "EPSG:4326";
83822
+ const dataProjection = this.config.projection || "EPSG:4326";
83773
83823
  if (this.config.data) {
83774
83824
  const features2 = format2.readFeatures(this.config.data, {
83825
+ dataProjection,
83775
83826
  featureProjection: mapProjection
83776
83827
  });
83777
83828
  this.originalFeatures = features2;
@@ -83779,7 +83830,10 @@ ${this.attributes_.map(
83779
83830
  } else if (this.config.url) {
83780
83831
  const source = new VectorSource$2({
83781
83832
  url: this.config.url,
83782
- format: new GeoJSON$4({ featureProjection: mapProjection })
83833
+ format: new GeoJSON$4({
83834
+ dataProjection,
83835
+ featureProjection: mapProjection
83836
+ })
83783
83837
  });
83784
83838
  source.on("featuresloadend", () => {
83785
83839
  this.originalFeatures = source.getFeatures();
@@ -84172,6 +84226,7 @@ ${this.attributes_.map(
84172
84226
  * 应用过滤器(实现基类的抽象方法)
84173
84227
  */
84174
84228
  applyFilters() {
84229
+ debugger;
84175
84230
  const layer2 = this.getLayer();
84176
84231
  const source = layer2.getSource();
84177
84232
  if (!source)
@@ -84418,6 +84473,7 @@ ${this.attributes_.map(
84418
84473
  * 创建图层
84419
84474
  */
84420
84475
  createLayer() {
84476
+ this.registerCustomProjection();
84421
84477
  this.vectorSource = new VectorSource$2({
84422
84478
  url: this.config.url,
84423
84479
  format: this.kmlFormat
@@ -84693,9 +84749,10 @@ ${this.attributes_.map(
84693
84749
  * 初始化GML格式处理器
84694
84750
  */
84695
84751
  initializeGMLFormat() {
84752
+ this.registerCustomProjection();
84696
84753
  const gmlConfig = this.config.gmlConfig || {};
84697
84754
  this.gmlFormat = new GML$1({
84698
- srsName: gmlConfig.srsName || "EPSG:4326"
84755
+ srsName: gmlConfig.srsName || this.config.projection || "EPSG:4326"
84699
84756
  });
84700
84757
  }
84701
84758
  /**
@@ -85071,13 +85128,20 @@ ${this.attributes_.map(
85071
85128
  * 从WKT字符串加载数据
85072
85129
  */
85073
85130
  loadWKTFromString(wktString) {
85131
+ var _a3;
85074
85132
  if (!this.wktFormat || !this.vectorSource)
85075
85133
  return;
85134
+ this.registerCustomProjection();
85135
+ const dataProjection = this.config.projection || "EPSG:4326";
85136
+ const featureProjection = ((_a3 = this.map) == null ? void 0 : _a3.getView().getProjection().getCode()) || "EPSG:4326";
85076
85137
  try {
85077
85138
  const wktLines = wktString.split("\n").filter((line2) => line2.trim());
85078
85139
  wktLines.forEach((line2, index2) => {
85079
85140
  try {
85080
- const geometry2 = this.wktFormat.readGeometry(line2.trim());
85141
+ const geometry2 = this.wktFormat.readGeometry(line2.trim(), {
85142
+ dataProjection,
85143
+ featureProjection
85144
+ });
85081
85145
  const feature2 = new ol$1.Feature({
85082
85146
  geometry: geometry2,
85083
85147
  id: `wkt_feature_${index2}`,
@@ -85163,10 +85227,16 @@ ${this.attributes_.map(
85163
85227
  * 添加WKT几何
85164
85228
  */
85165
85229
  addWKTGeometry(wktString, properties) {
85230
+ var _a3;
85166
85231
  if (!this.wktFormat || !this.vectorSource)
85167
85232
  return null;
85233
+ const dataProjection = this.config.projection || "EPSG:4326";
85234
+ const featureProjection = ((_a3 = this.map) == null ? void 0 : _a3.getView().getProjection().getCode()) || "EPSG:4326";
85168
85235
  try {
85169
- const geometry2 = this.wktFormat.readGeometry(wktString);
85236
+ const geometry2 = this.wktFormat.readGeometry(wktString, {
85237
+ dataProjection,
85238
+ featureProjection
85239
+ });
85170
85240
  const feature2 = new ol$1.Feature({
85171
85241
  geometry: geometry2,
85172
85242
  wkt: wktString,
@@ -466232,6 +466302,7 @@ ${this.attributes_.map(
466232
466302
  * 创建天地图XYZ数据源
466233
466303
  */
466234
466304
  createTiandituSource() {
466305
+ this.registerCustomProjection();
466235
466306
  const url = this.processUrl(this.config.url || "");
466236
466307
  const xyzOptions = {
466237
466308
  url,
@@ -466628,6 +466699,7 @@ ${this.attributes_.map(
466628
466699
  * 创建矢量瓦片数据源
466629
466700
  */
466630
466701
  createVectorTileSource() {
466702
+ this.registerCustomProjection();
466631
466703
  const config = this.config;
466632
466704
  const format2 = this.createFormat();
466633
466705
  const sourceOptions = {
@@ -466676,7 +466748,7 @@ ${this.attributes_.map(
466676
466748
  });
466677
466749
  case "geojson":
466678
466750
  return new GeoJSON$4({
466679
- dataProjection: config.dataProjection || "EPSG:4326",
466751
+ dataProjection: config.dataProjection || config.projection || "EPSG:4326",
466680
466752
  featureProjection: config.featureProjection || "EPSG:4326"
466681
466753
  });
466682
466754
  default:
@@ -467148,6 +467220,8 @@ ${this.attributes_.map(
467148
467220
  __publicField(this, "storage");
467149
467221
  // 存储baseLayers配置,用于判断图层是否为底图
467150
467222
  __publicField(this, "baseLayerIds", /* @__PURE__ */ new Set());
467223
+ // 存储共享图层组信息
467224
+ __publicField(this, "sharedLayerGroups", /* @__PURE__ */ new Map());
467151
467225
  this.map = map2;
467152
467226
  this.eventBus = eventBus;
467153
467227
  this.storage = storage2;
@@ -467157,6 +467231,7 @@ ${this.attributes_.map(
467157
467231
  * 添加图层(支持按需加载)
467158
467232
  */
467159
467233
  async addLayer(config) {
467234
+ var _a3, _b3;
467160
467235
  try {
467161
467236
  const layerId = config.id || `layer_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
467162
467237
  if (this.layerHandlers.has(layerId) || this.pendingLayerConfigs.has(layerId)) {
@@ -467171,7 +467246,11 @@ ${this.attributes_.map(
467171
467246
  opacity: config.opacity ?? 1,
467172
467247
  zIndex: config.zIndex ?? 0
467173
467248
  };
467174
- if (fullConfig.type === "group" && (fullConfig.children || fullConfig.layers)) {
467249
+ const isGroup = fullConfig.type === "group" || (((_a3 = fullConfig.children) == null ? void 0 : _a3.length) ?? 0) > 0 || (((_b3 = fullConfig.layers) == null ? void 0 : _b3.length) ?? 0) > 0;
467250
+ if (isGroup) {
467251
+ if (fullConfig.type !== "group") {
467252
+ fullConfig.type = "group";
467253
+ }
467175
467254
  return this.addLayerGroup(fullConfig);
467176
467255
  }
467177
467256
  if (fullConfig.visible && this.isBasemapLayer(layerId)) {
@@ -467283,6 +467362,174 @@ ${this.attributes_.map(
467283
467362
  console.error("执行定位动画失败:", error2);
467284
467363
  }
467285
467364
  }
467365
+ /**
467366
+ * 设置共享图层样式函数
467367
+ */
467368
+ setupSharedLayerStyle(layer2, reuseId) {
467369
+ if (!(layer2 instanceof VectorLayer$3)) {
467370
+ return;
467371
+ }
467372
+ const originalStyleFunction = layer2.getStyleFunction();
467373
+ layer2.setStyle((function(feature2, resolution) {
467374
+ const group2 = this.sharedLayerGroups.get(reuseId);
467375
+ if (!group2)
467376
+ return null;
467377
+ let matched = false;
467378
+ let styleToUse = null;
467379
+ for (const layerId of group2.logicalLayers) {
467380
+ const config = this.layerConfigs.get(layerId);
467381
+ if (config && config.visible) {
467382
+ try {
467383
+ if (this.checkFeatureFilter(feature2, config.filters)) {
467384
+ matched = true;
467385
+ const handler = this.layerHandlers.get(layerId);
467386
+ if (handler) {
467387
+ const isFirst = group2.logicalLayers.values().next().value === layerId;
467388
+ if (isFirst) {
467389
+ if (originalStyleFunction) {
467390
+ styleToUse = originalStyleFunction(feature2, resolution);
467391
+ }
467392
+ } else {
467393
+ const logicalLayer = handler.getLayer();
467394
+ if (logicalLayer && logicalLayer instanceof VectorLayer$3 && logicalLayer !== layer2) {
467395
+ const styleFunc = logicalLayer.getStyleFunction();
467396
+ if (styleFunc) {
467397
+ styleToUse = styleFunc(feature2, resolution);
467398
+ }
467399
+ } else {
467400
+ if (originalStyleFunction) {
467401
+ styleToUse = originalStyleFunction(feature2, resolution);
467402
+ }
467403
+ }
467404
+ }
467405
+ if (styleToUse || matched) {
467406
+ break;
467407
+ }
467408
+ }
467409
+ }
467410
+ } catch (e3) {
467411
+ console.error("Error checking feature filter:", e3);
467412
+ }
467413
+ }
467414
+ }
467415
+ if (matched) {
467416
+ if (styleToUse)
467417
+ return styleToUse;
467418
+ if (originalStyleFunction)
467419
+ return originalStyleFunction(feature2, resolution);
467420
+ return void 0;
467421
+ }
467422
+ return null;
467423
+ }).bind(this));
467424
+ }
467425
+ /**
467426
+ * 更新共享图层状态(处理WMS参数更新或Vector重绘)
467427
+ */
467428
+ updateSharedLayerState(reuseId) {
467429
+ const group2 = this.sharedLayerGroups.get(reuseId);
467430
+ if (!group2)
467431
+ return;
467432
+ const layer2 = group2.physicalLayer;
467433
+ const source = layer2.getSource();
467434
+ if (source && typeof source.updateParams === "function") {
467435
+ const visibleLayers = Array.from(group2.logicalLayers).filter((id2) => {
467436
+ const config = this.layerConfigs.get(id2);
467437
+ return config && config.visible;
467438
+ });
467439
+ const wmsLayersList = [];
467440
+ const cqlFilterList = [];
467441
+ visibleLayers.forEach((id2) => {
467442
+ var _a3, _b3;
467443
+ const config = this.layerConfigs.get(id2);
467444
+ if (config) {
467445
+ const layers = config.wmsLayers || ((_b3 = (_a3 = config.config) == null ? void 0 : _a3.wms) == null ? void 0 : _b3.layers);
467446
+ if (layers) {
467447
+ wmsLayersList.push(layers);
467448
+ let cql = "";
467449
+ if (config.filters && config.filters.length > 0) {
467450
+ const conditions = config.filters.filter((f2) => f2.enabled && f2.type === FilterType.ATTRIBUTE).map((f2) => {
467451
+ const attrFilter = f2;
467452
+ let val = attrFilter.value;
467453
+ if (typeof val === "string") {
467454
+ val = `'${val}'`;
467455
+ }
467456
+ switch (attrFilter.operator) {
467457
+ case FilterOperator.EQUAL:
467458
+ return `${attrFilter.property}=${val}`;
467459
+ case FilterOperator.NOT_EQUAL:
467460
+ return `${attrFilter.property}<>${val}`;
467461
+ case FilterOperator.GREATER_THAN:
467462
+ return `${attrFilter.property}>${val}`;
467463
+ case FilterOperator.LESS_THAN:
467464
+ return `${attrFilter.property}<${val}`;
467465
+ case FilterOperator.GREATER_EQUAL:
467466
+ return `${attrFilter.property}>=${val}`;
467467
+ case FilterOperator.LESS_EQUAL:
467468
+ return `${attrFilter.property}<=${val}`;
467469
+ case FilterOperator.LIKE:
467470
+ return `${attrFilter.property} LIKE ${val}`;
467471
+ case FilterOperator.IN:
467472
+ if (Array.isArray(attrFilter.value)) {
467473
+ const inVals = attrFilter.value.map((v5) => typeof v5 === "string" ? `'${v5}'` : v5).join(",");
467474
+ return `${attrFilter.property} IN (${inVals})`;
467475
+ }
467476
+ return `${attrFilter.property} IN (${attrFilter.value})`;
467477
+ default:
467478
+ return "";
467479
+ }
467480
+ }).filter((c2) => c2 !== "");
467481
+ if (conditions.length > 0) {
467482
+ cql = conditions.join(" AND ");
467483
+ }
467484
+ }
467485
+ cqlFilterList.push(cql === "" ? "INCLUDE" : cql);
467486
+ }
467487
+ }
467488
+ });
467489
+ if (wmsLayersList.length > 0) {
467490
+ const newLayersParam = wmsLayersList.join(",");
467491
+ const newCqlFilterParam = cqlFilterList.join(";");
467492
+ const params2 = { "LAYERS": newLayersParam };
467493
+ if (cqlFilterList.some((c2) => c2 !== "INCLUDE")) {
467494
+ params2["CQL_FILTER"] = newCqlFilterParam;
467495
+ } else {
467496
+ params2["CQL_FILTER"] = null;
467497
+ }
467498
+ source.updateParams(params2);
467499
+ console.log(`共享WMS图层 ${reuseId} 更新参数: LAYERS=${newLayersParam}, CQL_FILTER=${newCqlFilterParam}`);
467500
+ return;
467501
+ }
467502
+ }
467503
+ layer2.changed();
467504
+ }
467505
+ /**
467506
+ * 检查要素是否匹配过滤条件
467507
+ */
467508
+ checkFeatureFilter(feature2, filters) {
467509
+ if (!filters || filters.length === 0) {
467510
+ return true;
467511
+ }
467512
+ for (const filter2 of filters) {
467513
+ if (!filter2.enabled)
467514
+ continue;
467515
+ if (filter2.type === FilterType.ATTRIBUTE) {
467516
+ const props = feature2.getProperties();
467517
+ const value = props[filter2.property];
467518
+ const targetValue = filter2.value;
467519
+ switch (filter2.operator) {
467520
+ case FilterOperator.EQUAL:
467521
+ if (value != targetValue)
467522
+ return false;
467523
+ break;
467524
+ case FilterOperator.NOT_EQUAL:
467525
+ if (value == targetValue)
467526
+ return false;
467527
+ break;
467528
+ }
467529
+ }
467530
+ }
467531
+ return true;
467532
+ }
467286
467533
  /**
467287
467534
  * 获取缓动函数
467288
467535
  */
@@ -467313,19 +467560,44 @@ ${this.attributes_.map(
467313
467560
  * 异步添加图层
467314
467561
  */
467315
467562
  async addLayerAsync(fullConfig, handler) {
467316
- var _a3;
467563
+ var _a3, _b3;
467317
467564
  try {
467318
467565
  const layer2 = await handler.getLayerAsync();
467319
467566
  layer2.set("layerId", fullConfig.id);
467320
467567
  this.layerHandlers.set(fullConfig.id, handler);
467321
467568
  this.layerConfigs.set(fullConfig.id, fullConfig);
467322
467569
  console.log("kjthis.layerConfigs:", this.layerConfigs);
467323
- this.map.addLayer(layer2);
467570
+ let isReuse = false;
467571
+ if (fullConfig.reuseId) {
467572
+ const reuseId = fullConfig.reuseId;
467573
+ let group2 = this.sharedLayerGroups.get(reuseId);
467574
+ if (group2) {
467575
+ console.log(`图层 ${fullConfig.id} 复用物理图层 ${reuseId}`);
467576
+ group2.logicalLayers.add(fullConfig.id);
467577
+ isReuse = true;
467578
+ this.updateSharedLayerState(reuseId);
467579
+ } else {
467580
+ console.log(`图层 ${fullConfig.id} 创建共享物理图层 ${reuseId}`);
467581
+ this.sharedLayerGroups.set(reuseId, {
467582
+ physicalLayer: layer2,
467583
+ logicalLayers: /* @__PURE__ */ new Set([fullConfig.id])
467584
+ });
467585
+ this.setupSharedLayerStyle(layer2, reuseId);
467586
+ this.map.addLayer(layer2);
467587
+ }
467588
+ } else {
467589
+ this.map.addLayer(layer2);
467590
+ }
467324
467591
  if (fullConfig.zIndex !== void 0) {
467325
- handler.setZIndex(fullConfig.zIndex);
467592
+ if (fullConfig.reuseId && this.sharedLayerGroups.has(fullConfig.reuseId)) {
467593
+ const group2 = this.sharedLayerGroups.get(fullConfig.reuseId);
467594
+ group2.physicalLayer.setZIndex(fullConfig.zIndex);
467595
+ } else {
467596
+ handler.setZIndex(fullConfig.zIndex);
467597
+ }
467326
467598
  console.log(`图层 ${fullConfig.id} 设置 zIndex: ${fullConfig.zIndex}`);
467327
467599
  }
467328
- if ("applyLayerStyles" in handler) {
467600
+ if ("applyLayerStyles" in handler && !isReuse) {
467329
467601
  setTimeout(() => {
467330
467602
  handler.applyLayerStyles();
467331
467603
  }, 50);
@@ -467339,7 +467611,9 @@ ${this.attributes_.map(
467339
467611
  layerConfig: fullConfig
467340
467612
  });
467341
467613
  if (((_a3 = fullConfig.locationAnimation) == null ? void 0 : _a3.enabled) && fullConfig.visible) {
467342
- this.handleLocationAnimation(layer2, fullConfig);
467614
+ if (!isReuse || !((_b3 = this.sharedLayerGroups.get(fullConfig.reuseId)) == null ? void 0 : _b3.physicalLayer.getVisible())) {
467615
+ this.handleLocationAnimation(fullConfig.reuseId ? this.sharedLayerGroups.get(fullConfig.reuseId).physicalLayer : layer2, fullConfig);
467616
+ }
467343
467617
  }
467344
467618
  return true;
467345
467619
  } catch (error2) {
@@ -467364,7 +467638,7 @@ ${this.attributes_.map(
467364
467638
  const childLayers = [];
467365
467639
  if (groupConfig.children) {
467366
467640
  for (const childConfig of groupConfig.children) {
467367
- const childLayerId = `${groupConfig.id}_child_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
467641
+ const childLayerId = childConfig.id || `${groupConfig.id}_child_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
467368
467642
  const childFullConfig = {
467369
467643
  ...childConfig,
467370
467644
  id: childLayerId,
@@ -467377,9 +467651,10 @@ ${this.attributes_.map(
467377
467651
  }
467378
467652
  }
467379
467653
  }
467654
+ const layersList = [];
467380
467655
  if (groupConfig.layers) {
467381
467656
  for (const layerConfig of groupConfig.layers) {
467382
- const layerLayerId = `${groupConfig.id}_layer_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
467657
+ const layerLayerId = layerConfig.id || `${groupConfig.id}_layer_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
467383
467658
  const layerFullConfig = {
467384
467659
  ...layerConfig,
467385
467660
  id: layerLayerId,
@@ -467388,10 +467663,14 @@ ${this.attributes_.map(
467388
467663
  opacity: layerConfig.opacity ?? groupConfig.opacity
467389
467664
  };
467390
467665
  if (this.addLayer(layerFullConfig)) {
467666
+ layersList.push(layerFullConfig);
467391
467667
  }
467392
467668
  }
467393
467669
  }
467394
467670
  groupConfig.children = childLayers;
467671
+ if (layersList.length > 0) {
467672
+ groupConfig.layers = layersList;
467673
+ }
467395
467674
  this.layerConfigs.set(groupConfig.id, groupConfig);
467396
467675
  this.saveLayerConfigs();
467397
467676
  this.eventBus.emit("layer-added", {
@@ -467418,15 +467697,26 @@ ${this.attributes_.map(
467418
467697
  console.warn(`未找到图层配置: ${layerId}`);
467419
467698
  return false;
467420
467699
  }
467421
- if (handler && this.layerConfigs.has(layerId)) {
467422
- if (config.type === "group" && config.children) {
467423
- for (const child of config.children) {
467424
- this.removeLayer(child.id);
467700
+ if ((handler || config.type === "group") && this.layerConfigs.has(layerId)) {
467701
+ if (config.type === "group") {
467702
+ if (config.children) {
467703
+ for (const child of config.children) {
467704
+ this.removeLayer(child.id);
467705
+ }
467425
467706
  }
467426
- } else {
467707
+ if (config.layers) {
467708
+ for (const layer2 of config.layers) {
467709
+ this.removeLayer(layer2.id);
467710
+ }
467711
+ }
467712
+ if (handler)
467713
+ handler.destroy();
467714
+ } else if (handler) {
467427
467715
  handler.destroy();
467428
467716
  }
467429
- this.layerHandlers.delete(layerId);
467717
+ if (handler) {
467718
+ this.layerHandlers.delete(layerId);
467719
+ }
467430
467720
  this.layerConfigs.delete(layerId);
467431
467721
  }
467432
467722
  this.pendingLayerConfigs.delete(layerId);
@@ -467498,7 +467788,7 @@ ${this.attributes_.map(
467498
467788
  console.warn(`图层配置不存在: ${layerId}`);
467499
467789
  return false;
467500
467790
  }
467501
- if (config.type === "group" && config.children) {
467791
+ if (config.type === "group" && (config.children || config.layers)) {
467502
467792
  return await this.setGroupLayerVisible(layerId, visible);
467503
467793
  }
467504
467794
  if (visible && !this.layerHandlers.has(layerId)) {
@@ -467513,28 +467803,58 @@ ${this.attributes_.map(
467513
467803
  if (visible && this.isBasemapLayer(layerId)) {
467514
467804
  await this.hideOtherBasemaps(layerId);
467515
467805
  }
467516
- handler.setVisible(visible);
467517
467806
  config.visible = visible;
467518
- this.saveLayerConfigs();
467519
467807
  if (this.pendingLayerConfigs.has(layerId)) {
467520
467808
  this.pendingLayerConfigs.set(layerId, config);
467521
467809
  }
467522
- if (visible) {
467523
- const layer2 = handler.getLayer();
467524
- const animCfg = config.locationAnimation;
467525
- if (animCfg && animCfg.enabled) {
467526
- this.handleLocationAnimation(layer2, config);
467527
- } else if (config.fitToExtent) {
467528
- const defaultAnim = {
467529
- enabled: true,
467530
- duration: 1e3,
467531
- easing: "ease-out",
467532
- maxZoom: 16,
467533
- padding: [50, 50, 50, 50]
467534
- };
467535
- this.performLocationAnimation(layer2, config, defaultAnim);
467810
+ this.layerConfigs.set(layerId, config);
467811
+ if (config.reuseId && this.sharedLayerGroups.has(config.reuseId)) {
467812
+ const group2 = this.sharedLayerGroups.get(config.reuseId);
467813
+ const anyVisible = Array.from(group2.logicalLayers).some((id2) => {
467814
+ const c2 = this.layerConfigs.get(id2);
467815
+ return c2 && c2.visible;
467816
+ });
467817
+ group2.physicalLayer.setVisible(anyVisible);
467818
+ this.updateSharedLayerState(config.reuseId);
467819
+ console.log(`共享图层 ${config.reuseId} 逻辑图层 ${layerId} 可见性设为 ${visible}, 物理图层可见性: ${anyVisible}`);
467820
+ if (visible) {
467821
+ if (anyVisible) {
467822
+ const layer2 = group2.physicalLayer;
467823
+ const animCfg = config.locationAnimation;
467824
+ if (animCfg && animCfg.enabled) {
467825
+ this.handleLocationAnimation(layer2, config);
467826
+ } else if (config.fitToExtent) {
467827
+ const defaultAnim = {
467828
+ enabled: true,
467829
+ duration: 1e3,
467830
+ easing: "ease-out",
467831
+ maxZoom: 16,
467832
+ padding: [50, 50, 50, 50]
467833
+ };
467834
+ this.performLocationAnimation(layer2, config, defaultAnim);
467835
+ }
467836
+ }
467837
+ }
467838
+ } else {
467839
+ handler.setVisible(visible);
467840
+ if (visible) {
467841
+ const layer2 = handler.getLayer();
467842
+ const animCfg = config.locationAnimation;
467843
+ if (animCfg && animCfg.enabled) {
467844
+ this.handleLocationAnimation(layer2, config);
467845
+ } else if (config.fitToExtent) {
467846
+ const defaultAnim = {
467847
+ enabled: true,
467848
+ duration: 1e3,
467849
+ easing: "ease-out",
467850
+ maxZoom: 16,
467851
+ padding: [50, 50, 50, 50]
467852
+ };
467853
+ this.performLocationAnimation(layer2, config, defaultAnim);
467854
+ }
467536
467855
  }
467537
467856
  }
467857
+ this.saveLayerConfigs();
467538
467858
  this.eventBus.emit("layer-visibility-changed", {
467539
467859
  layerId,
467540
467860
  visible,
@@ -467586,10 +467906,9 @@ ${this.attributes_.map(
467586
467906
  }
467587
467907
  }
467588
467908
  if (groupConfig.layers) {
467589
- const allConfigs = new Map([...this.layerConfigs, ...this.pendingLayerConfigs]);
467590
- for (const [layerId, config] of allConfigs) {
467591
- if (layerId.startsWith(`${groupLayerId}_layer_`)) {
467592
- const result = await this.setLayerVisible(layerId, visible);
467909
+ for (const layerConfig of groupConfig.layers) {
467910
+ if (layerConfig.id) {
467911
+ const result = await this.setLayerVisible(layerConfig.id, visible);
467593
467912
  results.push(result);
467594
467913
  }
467595
467914
  }
@@ -467841,7 +468160,6 @@ ${this.attributes_.map(
467841
468160
  * 按需加载图层(原loadLayerConfigs的单个图层版本)
467842
468161
  */
467843
468162
  async loadLayerOnDemand(layerId) {
467844
- var _a3;
467845
468163
  try {
467846
468164
  if (this.layerHandlers.has(layerId)) {
467847
468165
  return true;
@@ -467853,23 +468171,15 @@ ${this.attributes_.map(
467853
468171
  }
467854
468172
  const handler = layerFactory.createLayerHandler(config);
467855
468173
  handler.setMap(this.map);
467856
- const layer2 = await ((_a3 = handler.getLayerAsync) == null ? void 0 : _a3.call(handler)) || handler.getLayer();
467857
- layer2.set("layerId", config.id);
467858
- this.layerHandlers.set(config.id, handler);
467859
- this.layerConfigs.set(config.id, config);
467860
- this.map.addLayer(layer2);
467861
- if (config.zIndex !== void 0) {
467862
- handler.setZIndex(config.zIndex);
467863
- console.log(`按需加载图层 ${layerId} 设置 zIndex: ${config.zIndex}`);
467864
- }
467865
- this.pendingLayerConfigs.delete(layerId);
467866
- if ("applyLayerStyles" in handler) {
467867
- setTimeout(() => {
467868
- handler.applyLayerStyles();
467869
- }, 50);
468174
+ const success = await this.addLayerAsync(config, handler);
468175
+ if (success) {
468176
+ this.pendingLayerConfigs.delete(layerId);
468177
+ console.log(`图层 ${layerId} 按需加载完成`);
468178
+ return true;
468179
+ } else {
468180
+ console.error(`按需加载图层 ${layerId} 失败`);
468181
+ return false;
467870
468182
  }
467871
- console.log(`图层 ${layerId} 按需加载完成`);
467872
- return true;
467873
468183
  } catch (error2) {
467874
468184
  console.error(`按需加载图层 ${layerId} 失败:`, error2);
467875
468185
  return false;
@@ -469883,7 +470193,11 @@ ${this.attributes_.map(
469883
470193
  initMap(targetId) {
469884
470194
  var _a3;
469885
470195
  const projection2 = this.config.projection || "EPSG:4326";
469886
- if (projection2 === "EPSG:4490") {
470196
+ if (this.config.projectionDefinition) {
470197
+ proj4$1.defs(projection2, this.config.projectionDefinition);
470198
+ register$3(proj4$1);
470199
+ }
470200
+ if (projection2 === "EPSG:4490" && !this.config.projectionDefinition) {
469887
470201
  setupEPSG4490();
469888
470202
  }
469889
470203
  const center2 = this.config.center || [116.404, 39.915];
@@ -480279,8 +480593,12 @@ ${this.attributes_.map(
480279
480593
  __publicField(this, "defaultCheckedKeys", vue.computed(() => {
480280
480594
  const checkedKeys = [];
480281
480595
  const collectVisibleIds = (layer2) => {
480282
- if (layer2.visible && layer2.type !== "group") {
480283
- checkedKeys.push(layer2.id);
480596
+ if (layer2.visible) {
480597
+ const isGroup = layer2.type === "group";
480598
+ const hasChildren = layer2.children && Array.isArray(layer2.children) && layer2.children.length > 0;
480599
+ if (!isGroup || isGroup && !hasChildren) {
480600
+ checkedKeys.push(layer2.id);
480601
+ }
480284
480602
  }
480285
480603
  if (layer2.children && Array.isArray(layer2.children)) {
480286
480604
  layer2.children.forEach((child) => collectVisibleIds(child));
@@ -480321,10 +480639,11 @@ ${this.attributes_.map(
480321
480639
  * @returns 树节点数据
480322
480640
  */
480323
480641
  buildLayerNode(layer2) {
480642
+ const isGroup = layer2.type === "group" || layer2.children && Array.isArray(layer2.children) && layer2.children.length > 0;
480324
480643
  const node2 = {
480325
480644
  id: layer2.id,
480326
480645
  label: layer2.name,
480327
- type: "layer",
480646
+ type: isGroup ? "group" : "layer",
480328
480647
  layerType: layer2.type,
480329
480648
  layerData: layer2
480330
480649
  };
@@ -481591,7 +481910,7 @@ ${this.attributes_.map(
481591
481910
  }
481592
481911
  const willCheck = checkedKeys ? checkedKeys.includes(data2.id) : !defaultCheckedKeys.value.includes(data2.id);
481593
481912
  const toggleNodeAndChildren = (node2, checked) => {
481594
- if (node2.type === "layer" && node2.layerData) {
481913
+ if ((node2.type === "layer" || node2.type === "group") && node2.layerData) {
481595
481914
  node2.layerData.visible = checked;
481596
481915
  handleLayerVisibilityChange(node2.layerData);
481597
481916
  if (node2.layerData.type === "group") {