vue-openlayers-plugin 1.0.35 → 1.0.37

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.
@@ -464048,6 +464048,189 @@ class TileSuperMapRestHandler extends BaseLayer$2 {
464048
464048
  }
464049
464049
  }
464050
464050
  }
464051
+ const _TiandituLayerHandler = class _TiandituLayerHandler extends BaseLayer$2 {
464052
+ createLayer() {
464053
+ const source = this.createTiandituSource();
464054
+ const tileLayer = new TileLayer$2({
464055
+ source,
464056
+ className: this.config.cssClass || this.config.className || void 0
464057
+ });
464058
+ return tileLayer;
464059
+ }
464060
+ /**
464061
+ * 创建天地图XYZ数据源
464062
+ */
464063
+ createTiandituSource() {
464064
+ const url = this.processUrl(this.config.url || "");
464065
+ const xyzOptions = {
464066
+ url,
464067
+ crossOrigin: "anonymous",
464068
+ // 天地图默认使用EPSG:4326投影
464069
+ projection: get$b("EPSG:4326")
464070
+ };
464071
+ if (this.config.projection) {
464072
+ const projection2 = get$b(this.config.projection);
464073
+ if (projection2) {
464074
+ xyzOptions.projection = projection2;
464075
+ }
464076
+ }
464077
+ return new XYZ$3(xyzOptions);
464078
+ }
464079
+ /**
464080
+ * 处理天地图URL,自动转换为代理URL或处理CORS问题
464081
+ */
464082
+ processUrl(originalUrl) {
464083
+ if (!originalUrl) {
464084
+ throw new Error("天地图URL不能为空");
464085
+ }
464086
+ if (!this.isTiandituUrl(originalUrl)) {
464087
+ console.warn("URL不是天地图服务URL,将直接使用原始URL");
464088
+ return originalUrl;
464089
+ }
464090
+ if (this.isDevelopmentMode()) {
464091
+ return this.convertToProxyUrl(originalUrl);
464092
+ }
464093
+ return originalUrl;
464094
+ }
464095
+ /**
464096
+ * 检查是否是天地图URL
464097
+ */
464098
+ isTiandituUrl(url) {
464099
+ return _TiandituLayerHandler.TIANDITU_DOMAINS.some(
464100
+ (domain) => url.includes(domain)
464101
+ );
464102
+ }
464103
+ /**
464104
+ * 检查是否是开发模式
464105
+ */
464106
+ isDevelopmentMode() {
464107
+ return process.env.NODE_ENV === "development" || window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1";
464108
+ }
464109
+ /**
464110
+ * 将天地图URL转换为代理URL
464111
+ */
464112
+ convertToProxyUrl(originalUrl) {
464113
+ const urlObj = new URL(originalUrl);
464114
+ const pathParts = urlObj.pathname.split("/");
464115
+ const serviceType = pathParts.find(
464116
+ (part) => Object.values(_TiandituLayerHandler.TIANDITU_SERVICES).includes(part)
464117
+ );
464118
+ if (!serviceType) {
464119
+ console.warn("无法识别天地图服务类型,使用默认代理路径");
464120
+ return `/api/tianditu${urlObj.pathname}${urlObj.search}`;
464121
+ }
464122
+ const proxyPath = `/api/tianditu/${serviceType}/wmts`;
464123
+ const queryString = urlObj.search;
464124
+ return `${proxyPath}${queryString}`;
464125
+ }
464126
+ /**
464127
+ * 获取天地图服务类型
464128
+ */
464129
+ getServiceType() {
464130
+ if (!this.config.url)
464131
+ return null;
464132
+ const urlObj = new URL(this.config.url);
464133
+ const pathParts = urlObj.pathname.split("/");
464134
+ return pathParts.find(
464135
+ (part) => Object.values(_TiandituLayerHandler.TIANDITU_SERVICES).includes(part)
464136
+ ) || null;
464137
+ }
464138
+ /**
464139
+ * 设置天地图密钥
464140
+ */
464141
+ setTiandituKey(key) {
464142
+ if (!this.config.url)
464143
+ return;
464144
+ const urlObj = new URL(this.config.url);
464145
+ urlObj.searchParams.set("tk", key);
464146
+ this.config.url = urlObj.toString();
464147
+ this.layer = null;
464148
+ }
464149
+ /**
464150
+ * 获取天地图密钥
464151
+ */
464152
+ getTiandituKey() {
464153
+ if (!this.config.url)
464154
+ return null;
464155
+ const urlObj = new URL(this.config.url);
464156
+ return urlObj.searchParams.get("tk");
464157
+ }
464158
+ /**
464159
+ * 设置URL
464160
+ */
464161
+ setUrl(url) {
464162
+ this.config.url = url;
464163
+ const layer2 = this.getLayer();
464164
+ const source = layer2.getSource();
464165
+ if (source) {
464166
+ const processedUrl = this.processUrl(url);
464167
+ source.setUrl(processedUrl);
464168
+ }
464169
+ }
464170
+ /**
464171
+ * 刷新图层
464172
+ */
464173
+ refresh() {
464174
+ const layer2 = this.getLayer();
464175
+ const source = layer2.getSource();
464176
+ if (source) {
464177
+ source.refresh();
464178
+ }
464179
+ }
464180
+ /**
464181
+ * 获取支持的天地图服务类型
464182
+ */
464183
+ static getSupportedServices() {
464184
+ return { ..._TiandituLayerHandler.TIANDITU_SERVICES };
464185
+ }
464186
+ /**
464187
+ * 获取天地图域名列表
464188
+ */
464189
+ static getTiandituDomains() {
464190
+ return [..._TiandituLayerHandler.TIANDITU_DOMAINS];
464191
+ }
464192
+ /**
464193
+ * 创建标准天地图URL
464194
+ */
464195
+ static createTiandituUrl(serviceType, options = {}) {
464196
+ const {
464197
+ tk = "YOUR_TIANDITU_KEY",
464198
+ domain = "t{0-7}.tianditu.gov.cn",
464199
+ format: format2 = "tiles",
464200
+ style = "default"
464201
+ } = options;
464202
+ const service = _TiandituLayerHandler.TIANDITU_SERVICES[serviceType];
464203
+ if (!service) {
464204
+ throw new Error(`不支持的天地图服务类型: ${serviceType}`);
464205
+ }
464206
+ return `https://${domain}/${service}/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=${service}&STYLE=${style}&TILEMATRIXSET=w&FORMAT=image/png&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=${tk}`;
464207
+ }
464208
+ };
464209
+ __publicField(_TiandituLayerHandler, "TIANDITU_DOMAINS", [
464210
+ "t0.tianditu.gov.cn",
464211
+ "t1.tianditu.gov.cn",
464212
+ "t2.tianditu.gov.cn",
464213
+ "t3.tianditu.gov.cn",
464214
+ "t4.tianditu.gov.cn",
464215
+ "t5.tianditu.gov.cn",
464216
+ "t6.tianditu.gov.cn",
464217
+ "t7.tianditu.gov.cn"
464218
+ ]);
464219
+ __publicField(_TiandituLayerHandler, "TIANDITU_SERVICES", {
464220
+ "img": "img_w",
464221
+ // 卫星影像
464222
+ "vec": "vec_w",
464223
+ // 矢量地图
464224
+ "cva": "cva_w",
464225
+ // 矢量注记
464226
+ "cia": "cia_w",
464227
+ // 影像注记
464228
+ "ter": "ter_w",
464229
+ // 地形图
464230
+ "cta": "cta_w"
464231
+ // 地形注记
464232
+ });
464233
+ let TiandituLayerHandler = _TiandituLayerHandler;
464051
464234
  class CanvasLayerHandler extends BaseLayer$2 {
464052
464235
  constructor() {
464053
464236
  super(...arguments);
@@ -464485,8 +464668,13 @@ const _LayerFactory = class _LayerFactory {
464485
464668
  this.layerHandlers.set("tilesupermaprest", TileSuperMapRestHandler);
464486
464669
  this.layerHandlers.set("osm", TileLayerHandler);
464487
464670
  this.layerHandlers.set("xyz", TileLayerHandler);
464488
- this.layerHandlers.set("tianditu-img", TileLayerHandler);
464489
- this.layerHandlers.set("tianditu-vec", TileLayerHandler);
464671
+ this.layerHandlers.set("tianditu", TiandituLayerHandler);
464672
+ this.layerHandlers.set("tianditu-img", TiandituLayerHandler);
464673
+ this.layerHandlers.set("tianditu-vec", TiandituLayerHandler);
464674
+ this.layerHandlers.set("tianditu-cva", TiandituLayerHandler);
464675
+ this.layerHandlers.set("tianditu-cia", TiandituLayerHandler);
464676
+ this.layerHandlers.set("tianditu-ter", TiandituLayerHandler);
464677
+ this.layerHandlers.set("tianditu-cta", TiandituLayerHandler);
464490
464678
  this.layerHandlers.set("gaode-img", TileLayerHandler);
464491
464679
  this.layerHandlers.set("gaode-vec", TileLayerHandler);
464492
464680
  this.layerHandlers.set("baidu-img", TileLayerHandler);
@@ -464629,10 +464817,12 @@ class LayerManager {
464629
464817
  __publicField(this, "map");
464630
464818
  __publicField(this, "layerHandlers", /* @__PURE__ */ new Map());
464631
464819
  __publicField(this, "layerConfigs", /* @__PURE__ */ new Map());
464632
- // 存储未加载的图层配置(仅配置,未创建实例)
464820
+ // 用于存储未加载的图层配置
464633
464821
  __publicField(this, "pendingLayerConfigs", /* @__PURE__ */ new Map());
464634
464822
  __publicField(this, "eventBus");
464635
464823
  __publicField(this, "storage");
464824
+ // 存储baseLayers配置,用于判断图层是否为底图
464825
+ __publicField(this, "baseLayerIds", /* @__PURE__ */ new Set());
464636
464826
  this.map = map2;
464637
464827
  this.eventBus = eventBus;
464638
464828
  this.storage = storage2;
@@ -464659,6 +464849,9 @@ class LayerManager {
464659
464849
  if (fullConfig.type === "group" && fullConfig.children) {
464660
464850
  return this.addLayerGroup(fullConfig);
464661
464851
  }
464852
+ if (fullConfig.visible && this.isBasemapLayer(layerId)) {
464853
+ await this.hideOtherBasemapsOnInit(layerId);
464854
+ }
464662
464855
  if (fullConfig.visible) {
464663
464856
  const handler = layerFactory.createLayerHandler(fullConfig);
464664
464857
  handler.setMap(this.map);
@@ -464825,8 +465018,8 @@ class LayerManager {
464825
465018
  const childFullConfig = {
464826
465019
  ...childConfig,
464827
465020
  id: childLayerId,
464828
- visible: childConfig.visible ?? (groupConfig.visible ?? false),
464829
- // 确保默认为false
465021
+ visible: groupConfig.visible ?? false,
465022
+ // 子图层的可见性完全跟随组图层
464830
465023
  opacity: childConfig.opacity ?? groupConfig.opacity
464831
465024
  };
464832
465025
  if (this.addLayer(childFullConfig)) {
@@ -464918,11 +465111,32 @@ class LayerManager {
464918
465111
  getLayerHandler(layerId) {
464919
465112
  return this.layerHandlers.get(layerId);
464920
465113
  }
465114
+ /**
465115
+ * 设置底图图层ID列表(用于底图互斥判断)
465116
+ */
465117
+ setBaseLayerIds(baseLayerIds) {
465118
+ this.baseLayerIds = new Set(baseLayerIds);
465119
+ console.log("LayerManager: 设置底图ID列表:", Array.from(this.baseLayerIds));
465120
+ }
465121
+ /**
465122
+ * 判断图层是否为底图
465123
+ */
465124
+ isBasemapLayer(layerId) {
465125
+ return this.baseLayerIds.has(layerId);
465126
+ }
464921
465127
  /**
464922
465128
  * 设置图层可见性(支持按需加载)
464923
465129
  */
464924
465130
  async setLayerVisible(layerId, visible) {
464925
465131
  try {
465132
+ let config = this.layerConfigs.get(layerId) || this.pendingLayerConfigs.get(layerId);
465133
+ if (!config) {
465134
+ console.warn(`图层配置不存在: ${layerId}`);
465135
+ return false;
465136
+ }
465137
+ if (config.type === "group" && config.children) {
465138
+ return await this.setGroupLayerVisible(layerId, visible);
465139
+ }
464926
465140
  if (visible && !this.layerHandlers.has(layerId)) {
464927
465141
  const loaded = await this.loadLayerOnDemand(layerId);
464928
465142
  if (!loaded) {
@@ -464931,8 +465145,10 @@ class LayerManager {
464931
465145
  }
464932
465146
  }
464933
465147
  const handler = this.layerHandlers.get(layerId);
464934
- let config = this.layerConfigs.get(layerId) || this.pendingLayerConfigs.get(layerId);
464935
465148
  if (handler && config) {
465149
+ if (visible && this.isBasemapLayer(layerId)) {
465150
+ await this.hideOtherBasemaps(layerId);
465151
+ }
464936
465152
  handler.setVisible(visible);
464937
465153
  config.visible = visible;
464938
465154
  this.saveLayerConfigs();
@@ -464966,6 +465182,95 @@ class LayerManager {
464966
465182
  return false;
464967
465183
  }
464968
465184
  }
465185
+ /**
465186
+ * 设置组图层的可见性(同时控制所有子图层)
465187
+ */
465188
+ async setGroupLayerVisible(groupLayerId, visible) {
465189
+ try {
465190
+ const groupConfig = this.layerConfigs.get(groupLayerId) || this.pendingLayerConfigs.get(groupLayerId);
465191
+ if (!groupConfig || !groupConfig.children) {
465192
+ console.warn(`组图层配置不存在或无子图层: ${groupLayerId}`);
465193
+ return false;
465194
+ }
465195
+ if (visible && this.isBasemapLayer(groupLayerId)) {
465196
+ await this.hideOtherBasemaps(groupLayerId);
465197
+ }
465198
+ groupConfig.visible = visible;
465199
+ const results = [];
465200
+ for (const childConfig of groupConfig.children) {
465201
+ if (childConfig.id) {
465202
+ const result = await this.setLayerVisible(childConfig.id, visible);
465203
+ results.push(result);
465204
+ }
465205
+ }
465206
+ this.saveLayerConfigs();
465207
+ this.eventBus.emit("layer-visibility-changed", {
465208
+ layerId: groupLayerId,
465209
+ visible,
465210
+ layerName: groupConfig.name,
465211
+ layerType: groupConfig.type
465212
+ });
465213
+ console.log(`组图层 ${groupLayerId} (${groupConfig.name}) 可见性设置为: ${visible}`);
465214
+ return results.every((result) => result);
465215
+ } catch (error2) {
465216
+ console.error("设置组图层可见性失败:", error2);
465217
+ return false;
465218
+ }
465219
+ }
465220
+ /**
465221
+ * 隐藏除指定底图外的其他底图(底图互斥逻辑)
465222
+ */
465223
+ async hideOtherBasemaps(currentBasemapId) {
465224
+ try {
465225
+ const allConfigs = [...this.layerConfigs.values(), ...this.pendingLayerConfigs.values()];
465226
+ const basemapConfigs = allConfigs.filter(
465227
+ (config) => this.isBasemapLayer(config.id) && config.id !== currentBasemapId
465228
+ );
465229
+ for (const config of basemapConfigs) {
465230
+ if (config.visible) {
465231
+ const handler = this.layerHandlers.get(config.id);
465232
+ if (handler) {
465233
+ handler.setVisible(false);
465234
+ }
465235
+ config.visible = false;
465236
+ if (this.pendingLayerConfigs.has(config.id)) {
465237
+ this.pendingLayerConfigs.set(config.id, config);
465238
+ }
465239
+ console.log(`底图互斥:隐藏底图 ${config.id} (${config.name})`);
465240
+ }
465241
+ }
465242
+ console.log(`底图互斥:显示底图 ${currentBasemapId}`);
465243
+ } catch (error2) {
465244
+ console.error("底图互斥处理失败:", error2);
465245
+ }
465246
+ }
465247
+ /**
465248
+ * 初始化时的底图互斥处理(处理配置中多个底图都设置为visible的情况)
465249
+ */
465250
+ async hideOtherBasemapsOnInit(currentBasemapId) {
465251
+ try {
465252
+ const allConfigs = [...this.layerConfigs.values(), ...this.pendingLayerConfigs.values()];
465253
+ const basemapConfigs = allConfigs.filter(
465254
+ (config) => this.isBasemapLayer(config.id) && config.id !== currentBasemapId && config.visible
465255
+ );
465256
+ for (const config of basemapConfigs) {
465257
+ const handler = this.layerHandlers.get(config.id);
465258
+ if (handler) {
465259
+ handler.setVisible(false);
465260
+ }
465261
+ config.visible = false;
465262
+ if (this.pendingLayerConfigs.has(config.id)) {
465263
+ this.pendingLayerConfigs.set(config.id, config);
465264
+ }
465265
+ console.log(`初始化底图互斥:隐藏底图 ${config.id} (${config.name})`);
465266
+ }
465267
+ if (basemapConfigs.length > 0) {
465268
+ console.log(`初始化底图互斥:保留底图 ${currentBasemapId} 为可见状态`);
465269
+ }
465270
+ } catch (error2) {
465271
+ console.error("初始化底图互斥处理失败:", error2);
465272
+ }
465273
+ }
464969
465274
  /**
464970
465275
  * 设置图层透明度
464971
465276
  */
@@ -476285,7 +476590,11 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
476285
476590
  }
476286
476591
  try {
476287
476592
  const configLayers = getAllConfigLayers();
476288
- const baseLayers = configLayers.filter((layer2) => layer2.isBasemap === true);
476593
+ if (config.value.baseLayers && config.value.baseLayers.length > 0) {
476594
+ const baseLayerIds = config.value.baseLayers.map((layer2) => layer2.id);
476595
+ layerManager.value.setBaseLayerIds(baseLayerIds);
476596
+ }
476597
+ const baseLayers = config.value.baseLayers || [];
476289
476598
  if (baseLayers.length > 0) {
476290
476599
  let lastVisibleBaseLayerIndex = -1;
476291
476600
  for (let i = baseLayers.length - 1; i >= 0; i--) {
@@ -476816,7 +477125,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
476816
477125
  };
476817
477126
  }
476818
477127
  });
476819
- const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-6929b38c"]]);
477128
+ const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-c66f28f2"]]);
476820
477129
  const _hoisted_1$4 = {
476821
477130
  key: 2,
476822
477131
  class: "tooltip-content"
@@ -487898,7 +488207,7 @@ function(t3) {
487898
488207
  */
487899
488208
  function(t3) {
487900
488209
  function e8() {
487901
- return (n.canvg ? Promise.resolve(n.canvg) : import("./index.es-9e1aa406.mjs")).catch(function(t4) {
488210
+ return (n.canvg ? Promise.resolve(n.canvg) : import("./index.es-943e7a9a.mjs")).catch(function(t4) {
487902
488211
  return Promise.reject(new Error("Could not load canvg: " + t4));
487903
488212
  }).then(function(t4) {
487904
488213
  return t4.default ? t4.default : t4;
@@ -1,4 +1,4 @@
1
- import { c as commonjsGlobal, R as RGBColor, r as requestAnimationFrame, _ as _asyncToGenerator, a as _, p as processCanvasRGBA, b as _defineProperty } from "./index-d683decb.mjs";
1
+ import { c as commonjsGlobal, R as RGBColor, r as requestAnimationFrame, _ as _asyncToGenerator, a as _, p as processCanvasRGBA, b as _defineProperty } from "./index-5e089533.mjs";
2
2
  import "vue";
3
3
  import "ol";
4
4
  var check = function(it) {
package/lib/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { z, B, d, C, D, a2, a3, u, y, I, H, Z, $, L, J, K, a4, h, M, a0, a1, X, Y, U, W, Q, S, P, A, F, G, N, O, e, T, E, V, x, j, o, t, f, k, g, w, q, m, n, a5, i, s, l, v } from "./index-d683decb.mjs";
1
+ import { z, B, d, C, D, a2, a3, u, y, I, H, Z, $, L, J, K, a4, h, M, a0, a1, X, Y, U, W, Q, S, P, A, F, G, N, O, e, T, E, V, x, j, o, t, f, k, g, w, q, m, n, a5, i, s, l, v } from "./index-5e089533.mjs";
2
2
  import "vue";
3
3
  import "ol";
4
4
  export {