vue-openlayers-plugin 1.0.32 → 1.0.34

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 (33) hide show
  1. package/lib/{index-1335ec37.mjs → index-d683decb.mjs} +1325 -291
  2. package/lib/{index.es-a8e2a821.mjs → index.es-9e1aa406.mjs} +1 -1
  3. package/lib/index.esm.js +1 -1
  4. package/lib/index.umd.js +1328 -294
  5. package/lib/style.css +76 -74
  6. package/package.json +1 -1
  7. package/types/src/components/CustomOpenlayer/components/MapContainer.vue.d.ts +2 -0
  8. package/types/src/components/CustomOpenlayer/components/MapContainer.vue.d.ts.map +1 -1
  9. package/types/src/components/CustomOpenlayer/components/MapPopup/BasePopup.vue.d.ts.map +1 -1
  10. package/types/src/components/CustomOpenlayer/index.vue.d.ts.map +1 -1
  11. package/types/src/components/CustomOpenlayer/types/index.d.ts +89 -172
  12. package/types/src/components/CustomOpenlayer/types/index.d.ts.map +1 -1
  13. package/types/src/components/CustomOpenlayer/utils/eventManager.d.ts +0 -15
  14. package/types/src/components/CustomOpenlayer/utils/eventManager.d.ts.map +1 -1
  15. package/types/src/components/CustomOpenlayer/utils/layerManager.d.ts +8 -8
  16. package/types/src/components/CustomOpenlayer/utils/layerManager.d.ts.map +1 -1
  17. package/types/src/components/CustomOpenlayer/utils/layers/BaseLayer.d.ts.map +1 -1
  18. package/types/src/components/CustomOpenlayer/utils/layers/CanvasLayerHandler.d.ts +2 -1
  19. package/types/src/components/CustomOpenlayer/utils/layers/CanvasLayerHandler.d.ts.map +1 -1
  20. package/types/src/components/CustomOpenlayer/utils/layers/ClusterLayerHandler.d.ts.map +1 -1
  21. package/types/src/components/CustomOpenlayer/utils/layers/GMLLayerHandler.d.ts.map +1 -1
  22. package/types/src/components/CustomOpenlayer/utils/layers/GeoJSONLayerHandler.d.ts +0 -1
  23. package/types/src/components/CustomOpenlayer/utils/layers/GeoJSONLayerHandler.d.ts.map +1 -1
  24. package/types/src/components/CustomOpenlayer/utils/layers/SuperMapServiceTester.d.ts +54 -0
  25. package/types/src/components/CustomOpenlayer/utils/layers/SuperMapServiceTester.d.ts.map +1 -0
  26. package/types/src/components/CustomOpenlayer/utils/layers/TileSuperMapRestHandler.d.ts +116 -0
  27. package/types/src/components/CustomOpenlayer/utils/layers/TileSuperMapRestHandler.d.ts.map +1 -1
  28. package/types/src/components/CustomOpenlayer/utils/layers/WMSLayerHandler.d.ts +14 -1
  29. package/types/src/components/CustomOpenlayer/utils/layers/WMSLayerHandler.d.ts.map +1 -1
  30. package/types/src/components/CustomOpenlayer/utils/mapManager.d.ts.map +1 -1
  31. package/types/src/components/CustomOpenlayer/utils/storage.d.ts +62 -0
  32. package/types/src/components/CustomOpenlayer/utils/storage.d.ts.map +1 -1
  33. package/types/tsconfig.tsbuildinfo +1 -1
@@ -41751,7 +41751,7 @@ function checkProj$1(item) {
41751
41751
  item
41752
41752
  );
41753
41753
  }
41754
- function proj4$2(fromProjOrToProj, toProjOrCoord, coord) {
41754
+ function proj4$3(fromProjOrToProj, toProjOrCoord, coord) {
41755
41755
  var fromProj;
41756
41756
  var toProj;
41757
41757
  var single = false;
@@ -45755,7 +45755,7 @@ function includedProjections$1(proj42) {
45755
45755
  proj42.Proj.projections.add(eqearth$1);
45756
45756
  proj42.Proj.projections.add(bonne$1);
45757
45757
  }
45758
- const proj4$1 = Object.assign(proj4$2, {
45758
+ const proj4$1 = Object.assign(proj4$3, {
45759
45759
  defaultDatum: "WGS84",
45760
45760
  Proj: Projection$3,
45761
45761
  WGS84: new Projection$3("WGS84"),
@@ -45768,6 +45768,10 @@ const proj4$1 = Object.assign(proj4$2, {
45768
45768
  version: "__VERSION__"
45769
45769
  });
45770
45770
  includedProjections$1(proj4$1);
45771
+ const proj4$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
45772
+ __proto__: null,
45773
+ default: proj4$1
45774
+ }, Symbol.toStringTag, { value: "Module" }));
45771
45775
  let registered$1 = null;
45772
45776
  function register$3(proj42) {
45773
45777
  registered$1 = proj42;
@@ -45854,11 +45858,9 @@ class EventManager {
45854
45858
  "map:contextmenu",
45855
45859
  "map:pointermove",
45856
45860
  "map:moveend",
45857
- "map:zoomchange",
45858
- "map:featureinfo"
45861
+ "map:zoomchange"
45859
45862
  ],
45860
- debounceDelay: config.debounceDelay ?? 100,
45861
- enableFeatureInfo: config.enableFeatureInfo ?? true
45863
+ debounceDelay: config.debounceDelay ?? 100
45862
45864
  };
45863
45865
  this.mittEmitter = this.config.mittInstance || mitt();
45864
45866
  this.lastZoom = this.map.getView().getZoom() || 0;
@@ -45880,9 +45882,6 @@ class EventManager {
45880
45882
  pixel,
45881
45883
  originalEvent: event.originalEvent
45882
45884
  });
45883
- if (this.config.enableFeatureInfo) {
45884
- this.handleFeatureInfoQuery(coordinate, pixel);
45885
- }
45886
45885
  });
45887
45886
  }
45888
45887
  if (enabledEvents.includes("map:dblclick")) {
@@ -45959,23 +45958,6 @@ class EventManager {
45959
45958
  this.map.on(eventType, handler);
45960
45959
  this.listeners.set(key, () => this.map.un(eventType, handler));
45961
45960
  }
45962
- /**
45963
- * 处理要素信息查询
45964
- */
45965
- async handleFeatureInfoQuery(coordinate, pixel) {
45966
- try {
45967
- const layerData = await this.layerManager.getFeatureInfoAtCoordinate(coordinate, {});
45968
- if (layerData.length > 0) {
45969
- this.emit("map:featureinfo", {
45970
- coordinate,
45971
- pixel,
45972
- layerData
45973
- });
45974
- }
45975
- } catch (error2) {
45976
- console.warn("获取要素信息失败:", error2);
45977
- }
45978
- }
45979
45961
  /**
45980
45962
  * 防抖处理
45981
45963
  */
@@ -46030,12 +46012,6 @@ class EventManager {
46030
46012
  getMittEmitter() {
46031
46013
  return this.mittEmitter;
46032
46014
  }
46033
- /**
46034
- * 手动触发要素信息查询
46035
- */
46036
- async queryFeatureInfo(coordinate, pixel) {
46037
- return await this.layerManager.getFeatureInfoAtCoordinate(coordinate, {});
46038
- }
46039
46015
  /**
46040
46016
  * 更新配置
46041
46017
  */
@@ -69065,23 +69041,218 @@ function getUnitOptions(type) {
69065
69041
  return [{ value: "auto", label: "自动" }];
69066
69042
  }
69067
69043
  }
69044
+ const STORAGE_CONFIG = {
69045
+ MAX_MEASUREMENTS: 200,
69046
+ // 最大测量结果数量(降低到200)
69047
+ MAX_LAYER_CONFIGS: 50,
69048
+ // 最大图层配置数量(降低到50)
69049
+ QUOTA_WARNING_THRESHOLD: 0.6,
69050
+ // 配额警告阈值(60%)
69051
+ AUTO_CLEANUP_THRESHOLD: 0.7,
69052
+ // 自动清理阈值(70%)
69053
+ COMPRESSION_ENABLED: true,
69054
+ // 是否启用压缩
69055
+ BATCH_CLEANUP_SIZE: 20
69056
+ // 批量清理数量(降低到20)
69057
+ };
69058
+ class DataCompressor {
69059
+ static compress(data) {
69060
+ try {
69061
+ return btoa(encodeURIComponent(data));
69062
+ } catch {
69063
+ return data;
69064
+ }
69065
+ }
69066
+ static decompress(compressedData) {
69067
+ try {
69068
+ return decodeURIComponent(atob(compressedData));
69069
+ } catch {
69070
+ return compressedData;
69071
+ }
69072
+ }
69073
+ }
69068
69074
  class MapStorage {
69075
+ // 防止递归清理
69069
69076
  constructor(instanceId) {
69070
69077
  __publicField(this, "storageKeys");
69071
69078
  __publicField(this, "instanceId");
69079
+ __publicField(this, "isCleaningUp", false);
69072
69080
  this.instanceId = instanceId || "default";
69073
69081
  this.storageKeys = {
69074
69082
  MEASUREMENTS: `${this.instanceId}_openlayer_measurements`,
69075
69083
  LAYER_CONFIGS: `${this.instanceId}_openlayer_layer_configs`,
69076
69084
  MAP_STATE: `${this.instanceId}_openlayer_map_state`
69077
69085
  };
69086
+ this.initCleanup();
69087
+ }
69088
+ /**
69089
+ * 初始化清理过量数据
69090
+ */
69091
+ initCleanup() {
69092
+ try {
69093
+ const measurementsData = localStorage.getItem(this.storageKeys.MEASUREMENTS);
69094
+ if (measurementsData) {
69095
+ const decompressed = DataCompressor.decompress(measurementsData);
69096
+ const measurements = JSON.parse(decompressed);
69097
+ if (measurements.length > STORAGE_CONFIG.MAX_MEASUREMENTS) {
69098
+ const cleanedMeasurements = measurements.sort((a3, b10) => (b10.timestamp || 0) - (a3.timestamp || 0)).slice(0, STORAGE_CONFIG.MAX_MEASUREMENTS);
69099
+ const compressed = DataCompressor.compress(JSON.stringify(cleanedMeasurements));
69100
+ localStorage.setItem(this.storageKeys.MEASUREMENTS, compressed);
69101
+ console.log(`初始化清理测量结果:${measurements.length} -> ${cleanedMeasurements.length}`);
69102
+ }
69103
+ }
69104
+ const layerConfigsData = localStorage.getItem(this.storageKeys.LAYER_CONFIGS);
69105
+ if (layerConfigsData) {
69106
+ const decompressed = DataCompressor.decompress(layerConfigsData);
69107
+ const layerConfigs = JSON.parse(decompressed);
69108
+ if (layerConfigs.length > STORAGE_CONFIG.MAX_LAYER_CONFIGS) {
69109
+ const cleanedConfigs = layerConfigs.slice(0, STORAGE_CONFIG.MAX_LAYER_CONFIGS);
69110
+ const compressed = DataCompressor.compress(JSON.stringify(cleanedConfigs));
69111
+ localStorage.setItem(this.storageKeys.LAYER_CONFIGS, compressed);
69112
+ console.log(`初始化清理图层配置:${layerConfigs.length} -> ${cleanedConfigs.length}`);
69113
+ }
69114
+ }
69115
+ } catch (error2) {
69116
+ console.error("初始化清理失败:", error2);
69117
+ }
69118
+ }
69119
+ /**
69120
+ * 检查localStorage配额使用情况
69121
+ */
69122
+ checkStorageQuota() {
69123
+ let used = 0;
69124
+ const available = 5 * 1024 * 1024;
69125
+ try {
69126
+ for (let key in localStorage) {
69127
+ if (localStorage.hasOwnProperty(key)) {
69128
+ used += localStorage[key].length + key.length;
69129
+ }
69130
+ }
69131
+ } catch {
69132
+ used = 0;
69133
+ }
69134
+ return {
69135
+ used,
69136
+ available,
69137
+ percentage: available > 0 ? used / available : 0
69138
+ };
69139
+ }
69140
+ /**
69141
+ * 自动清理旧数据
69142
+ */
69143
+ autoCleanup() {
69144
+ if (this.isCleaningUp) {
69145
+ console.warn("清理操作正在进行中,跳过重复调用");
69146
+ return;
69147
+ }
69148
+ this.isCleaningUp = true;
69149
+ try {
69150
+ const quota = this.checkStorageQuota();
69151
+ if (quota.percentage >= STORAGE_CONFIG.AUTO_CLEANUP_THRESHOLD) {
69152
+ console.warn("存储空间不足,开始自动清理旧数据");
69153
+ try {
69154
+ const measurementsData = localStorage.getItem(this.storageKeys.MEASUREMENTS);
69155
+ if (measurementsData) {
69156
+ const decompressed = DataCompressor.decompress(measurementsData);
69157
+ const measurements = JSON.parse(decompressed);
69158
+ if (measurements.length > STORAGE_CONFIG.BATCH_CLEANUP_SIZE) {
69159
+ const cleanedMeasurements = measurements.sort((a3, b10) => (b10.timestamp || 0) - (a3.timestamp || 0)).slice(0, STORAGE_CONFIG.MAX_MEASUREMENTS - STORAGE_CONFIG.BATCH_CLEANUP_SIZE);
69160
+ const compressed = DataCompressor.compress(JSON.stringify(cleanedMeasurements));
69161
+ localStorage.setItem(this.storageKeys.MEASUREMENTS, compressed);
69162
+ console.log(`清理测量结果:${measurements.length} -> ${cleanedMeasurements.length}`);
69163
+ }
69164
+ }
69165
+ } catch (error2) {
69166
+ console.error("清理测量结果失败:", error2);
69167
+ }
69168
+ try {
69169
+ const layerConfigsData = localStorage.getItem(this.storageKeys.LAYER_CONFIGS);
69170
+ if (layerConfigsData) {
69171
+ const decompressed = DataCompressor.decompress(layerConfigsData);
69172
+ const layerConfigs = JSON.parse(decompressed);
69173
+ if (layerConfigs.length > STORAGE_CONFIG.BATCH_CLEANUP_SIZE) {
69174
+ const cleanedConfigs = layerConfigs.slice(0, STORAGE_CONFIG.MAX_LAYER_CONFIGS - STORAGE_CONFIG.BATCH_CLEANUP_SIZE);
69175
+ const compressed = DataCompressor.compress(JSON.stringify(cleanedConfigs));
69176
+ localStorage.setItem(this.storageKeys.LAYER_CONFIGS, compressed);
69177
+ console.log(`清理图层配置:${layerConfigs.length} -> ${cleanedConfigs.length}`);
69178
+ }
69179
+ }
69180
+ } catch (error2) {
69181
+ console.error("清理图层配置失败:", error2);
69182
+ }
69183
+ }
69184
+ } finally {
69185
+ this.isCleaningUp = false;
69186
+ }
69187
+ }
69188
+ /**
69189
+ * 安全存储数据(带配额检查)
69190
+ */
69191
+ safeSetItem(key, value) {
69192
+ try {
69193
+ if (!this.isCleaningUp) {
69194
+ const quota = this.checkStorageQuota();
69195
+ if (quota.percentage >= STORAGE_CONFIG.QUOTA_WARNING_THRESHOLD) {
69196
+ console.warn(`存储空间使用率已达${Math.round(quota.percentage * 100)}%`);
69197
+ if (quota.percentage >= STORAGE_CONFIG.AUTO_CLEANUP_THRESHOLD) {
69198
+ this.autoCleanup();
69199
+ }
69200
+ }
69201
+ }
69202
+ const compressedValue = DataCompressor.compress(value);
69203
+ localStorage.setItem(key, compressedValue);
69204
+ return true;
69205
+ } catch (error2) {
69206
+ if (error2 instanceof DOMException && error2.code === 22) {
69207
+ console.error("存储配额已满,尝试清理后重试");
69208
+ if (!this.isCleaningUp) {
69209
+ this.autoCleanup();
69210
+ try {
69211
+ const compressedValue = DataCompressor.compress(value);
69212
+ localStorage.setItem(key, compressedValue);
69213
+ return true;
69214
+ } catch {
69215
+ console.error("清理后仍无法存储,数据过大或配额不足");
69216
+ return false;
69217
+ }
69218
+ } else {
69219
+ console.error("清理过程中存储失败,跳过重试");
69220
+ return false;
69221
+ }
69222
+ }
69223
+ console.error("存储失败:", error2);
69224
+ return false;
69225
+ }
69226
+ }
69227
+ /**
69228
+ * 安全获取数据(带解压缩)
69229
+ */
69230
+ safeGetItem(key) {
69231
+ try {
69232
+ const item = localStorage.getItem(key);
69233
+ if (item) {
69234
+ return DataCompressor.decompress(item);
69235
+ }
69236
+ return null;
69237
+ } catch (error2) {
69238
+ console.error("获取数据失败:", error2);
69239
+ return null;
69240
+ }
69078
69241
  }
69079
69242
  /**
69080
69243
  * 保存测量结果
69081
69244
  */
69082
69245
  saveMeasurements(measurements) {
69083
69246
  try {
69084
- localStorage.setItem(this.storageKeys.MEASUREMENTS, JSON.stringify(measurements));
69247
+ let limitedMeasurements = measurements.sort((a3, b10) => (b10.timestamp || 0) - (a3.timestamp || 0)).slice(0, STORAGE_CONFIG.MAX_MEASUREMENTS);
69248
+ limitedMeasurements = limitedMeasurements.map((m2) => ({
69249
+ ...m2,
69250
+ timestamp: m2.timestamp || Date.now()
69251
+ }));
69252
+ const success = this.safeSetItem(this.storageKeys.MEASUREMENTS, JSON.stringify(limitedMeasurements));
69253
+ if (!success) {
69254
+ console.error("保存测量结果失败: 存储空间不足");
69255
+ }
69085
69256
  } catch (error2) {
69086
69257
  console.error("保存测量结果失败:", error2);
69087
69258
  }
@@ -69091,7 +69262,7 @@ class MapStorage {
69091
69262
  */
69092
69263
  getMeasurements() {
69093
69264
  try {
69094
- const data = localStorage.getItem(this.storageKeys.MEASUREMENTS);
69265
+ const data = this.safeGetItem(this.storageKeys.MEASUREMENTS);
69095
69266
  return data ? JSON.parse(data) : [];
69096
69267
  } catch (error2) {
69097
69268
  console.error("获取测量结果失败:", error2);
@@ -69124,18 +69295,31 @@ class MapStorage {
69124
69295
  */
69125
69296
  saveLayerConfigs(configs) {
69126
69297
  try {
69127
- const configsToSave = configs.map((config) => ({
69128
- id: config.id,
69129
- name: config.name,
69130
- type: config.type,
69131
- url: config.url,
69132
- visible: config.visible,
69133
- opacity: config.opacity,
69134
- zIndex: config.zIndex,
69135
- legend: config.legend,
69136
- metadata: config.metadata
69137
- }));
69138
- localStorage.setItem(this.storageKeys.LAYER_CONFIGS, JSON.stringify(configsToSave));
69298
+ const limitedConfigs = configs.slice(0, STORAGE_CONFIG.MAX_LAYER_CONFIGS);
69299
+ const configsToSave = limitedConfigs.map((config) => {
69300
+ const optimizedConfig = {
69301
+ id: config.id,
69302
+ name: config.name,
69303
+ type: config.type,
69304
+ visible: config.visible
69305
+ };
69306
+ if (config.url)
69307
+ optimizedConfig.url = config.url;
69308
+ if (config.opacity !== void 0 && config.opacity !== 1)
69309
+ optimizedConfig.opacity = config.opacity;
69310
+ if (config.zIndex !== void 0 && config.zIndex !== 0)
69311
+ optimizedConfig.zIndex = config.zIndex;
69312
+ if (config.legend)
69313
+ optimizedConfig.legend = config.legend;
69314
+ if (config.metadata && Object.keys(config.metadata).length > 0) {
69315
+ optimizedConfig.metadata = config.metadata;
69316
+ }
69317
+ return optimizedConfig;
69318
+ });
69319
+ const success = this.safeSetItem(this.storageKeys.LAYER_CONFIGS, JSON.stringify(configsToSave));
69320
+ if (!success) {
69321
+ console.error("保存图层配置失败: 存储空间不足");
69322
+ }
69139
69323
  } catch (error2) {
69140
69324
  console.error("保存图层配置失败:", error2);
69141
69325
  }
@@ -69145,7 +69329,7 @@ class MapStorage {
69145
69329
  */
69146
69330
  getLayerConfigs() {
69147
69331
  try {
69148
- const data = localStorage.getItem(this.storageKeys.LAYER_CONFIGS);
69332
+ const data = this.safeGetItem(this.storageKeys.LAYER_CONFIGS);
69149
69333
  return data ? JSON.parse(data) : [];
69150
69334
  } catch (error2) {
69151
69335
  console.error("获取图层配置失败:", error2);
@@ -69158,7 +69342,10 @@ class MapStorage {
69158
69342
  saveMapState(center2, zoom, rotation = 0) {
69159
69343
  try {
69160
69344
  const state = { center: center2, zoom, rotation, timestamp: Date.now() };
69161
- localStorage.setItem(this.storageKeys.MAP_STATE, JSON.stringify(state));
69345
+ const success = this.safeSetItem(this.storageKeys.MAP_STATE, JSON.stringify(state));
69346
+ if (!success) {
69347
+ console.error("保存地图状态失败: 存储空间不足");
69348
+ }
69162
69349
  } catch (error2) {
69163
69350
  console.error("保存地图状态失败:", error2);
69164
69351
  }
@@ -69168,7 +69355,7 @@ class MapStorage {
69168
69355
  */
69169
69356
  getMapState() {
69170
69357
  try {
69171
- const data = localStorage.getItem(this.storageKeys.MAP_STATE);
69358
+ const data = this.safeGetItem(this.storageKeys.MAP_STATE);
69172
69359
  return data ? JSON.parse(data) : null;
69173
69360
  } catch (error2) {
69174
69361
  console.error("获取地图状态失败:", error2);
@@ -69196,10 +69383,101 @@ class MapStorage {
69196
69383
  });
69197
69384
  return Math.round(total / 1024 * 100) / 100;
69198
69385
  }
69386
+ /**
69387
+ * 获取详细的存储状态信息
69388
+ */
69389
+ getStorageStatus() {
69390
+ const quota = this.checkStorageQuota();
69391
+ const measurements = this.getMeasurements();
69392
+ const layerConfigs = this.getLayerConfigs();
69393
+ const warnings = [];
69394
+ if (quota.percentage >= STORAGE_CONFIG.QUOTA_WARNING_THRESHOLD) {
69395
+ warnings.push(`存储空间使用率已达${Math.round(quota.percentage * 100)}%`);
69396
+ }
69397
+ if (measurements.length >= STORAGE_CONFIG.MAX_MEASUREMENTS * 0.8) {
69398
+ warnings.push(`测量结果数量接近上限 (${measurements.length}/${STORAGE_CONFIG.MAX_MEASUREMENTS})`);
69399
+ }
69400
+ if (layerConfigs.length >= STORAGE_CONFIG.MAX_LAYER_CONFIGS * 0.8) {
69401
+ warnings.push(`图层配置数量接近上限 (${layerConfigs.length}/${STORAGE_CONFIG.MAX_LAYER_CONFIGS})`);
69402
+ }
69403
+ return {
69404
+ quota,
69405
+ instanceSize: this.getStorageSize(),
69406
+ measurementCount: measurements.length,
69407
+ layerConfigCount: layerConfigs.length,
69408
+ compressionEnabled: STORAGE_CONFIG.COMPRESSION_ENABLED,
69409
+ warnings
69410
+ };
69411
+ }
69412
+ /**
69413
+ * 手动清理存储
69414
+ */
69415
+ manualCleanup(options = {}) {
69416
+ const {
69417
+ clearMeasurements = false,
69418
+ clearLayerConfigs = false,
69419
+ clearMapState = false,
69420
+ keepRecentCount = 50
69421
+ } = options;
69422
+ if (clearMeasurements) {
69423
+ if (keepRecentCount > 0) {
69424
+ const measurements = this.getMeasurements();
69425
+ const recentMeasurements = measurements.sort((a3, b10) => (b10.timestamp || 0) - (a3.timestamp || 0)).slice(0, keepRecentCount);
69426
+ this.saveMeasurements(recentMeasurements);
69427
+ } else {
69428
+ this.clearMeasurements();
69429
+ }
69430
+ }
69431
+ if (clearLayerConfigs) {
69432
+ if (keepRecentCount > 0) {
69433
+ const layerConfigs = this.getLayerConfigs();
69434
+ const recentConfigs = layerConfigs.slice(0, keepRecentCount);
69435
+ this.saveLayerConfigs(recentConfigs);
69436
+ } else {
69437
+ localStorage.removeItem(this.storageKeys.LAYER_CONFIGS);
69438
+ }
69439
+ }
69440
+ if (clearMapState) {
69441
+ localStorage.removeItem(this.storageKeys.MAP_STATE);
69442
+ }
69443
+ }
69444
+ /**
69445
+ * 导出存储数据(用于备份)
69446
+ */
69447
+ exportData() {
69448
+ return {
69449
+ measurements: this.getMeasurements(),
69450
+ layerConfigs: this.getLayerConfigs(),
69451
+ mapState: this.getMapState(),
69452
+ exportTime: Date.now()
69453
+ };
69454
+ }
69455
+ /**
69456
+ * 导入存储数据(用于恢复)
69457
+ */
69458
+ importData(data) {
69459
+ try {
69460
+ if (data.measurements) {
69461
+ this.saveMeasurements(data.measurements);
69462
+ }
69463
+ if (data.layerConfigs) {
69464
+ this.saveLayerConfigs(data.layerConfigs);
69465
+ }
69466
+ if (data.mapState) {
69467
+ const { center: center2, zoom, rotation } = data.mapState;
69468
+ this.saveMapState(center2, zoom, rotation);
69469
+ }
69470
+ return true;
69471
+ } catch (error2) {
69472
+ console.error("导入数据失败:", error2);
69473
+ return false;
69474
+ }
69475
+ }
69199
69476
  }
69200
69477
  function createMapStorage(instanceId) {
69201
69478
  return new MapStorage(instanceId);
69202
69479
  }
69480
+ new MapStorage("global");
69203
69481
  class MeasurementTool {
69204
69482
  constructor(map2, storage2, options = {}) {
69205
69483
  __publicField(this, "map");
@@ -69299,7 +69577,7 @@ class MeasurementTool {
69299
69577
  }
69300
69578
  // 清除特定要素的测量结果标注
69301
69579
  clearFeatureTooltips(feature2) {
69302
- const featureId2 = feature2.getId() || feature2.ol_uid;
69580
+ const featureId2 = feature2.getId && feature2.getId() || feature2.ol_uid || feature2.get("id");
69303
69581
  const nodesToRemove = this.nodeMarkers.filter((node) => {
69304
69582
  const nodeFeatureId = node.get("parentFeatureId");
69305
69583
  return nodeFeatureId === featureId2;
@@ -69426,7 +69704,7 @@ class MeasurementTool {
69426
69704
  const tooltip = this.createSegmentTooltipOverlay(center2, areaText);
69427
69705
  tooltips.push(tooltip);
69428
69706
  this.map.addOverlay(tooltip);
69429
- const featureId2 = feature2.getId() || feature2.ol_uid;
69707
+ const featureId2 = feature2.getId && feature2.getId() || feature2.ol_uid || feature2.get("id");
69430
69708
  const tooltipElement = tooltip.getElement();
69431
69709
  this.areaTooltips.push({
69432
69710
  element: tooltipElement,
@@ -69443,7 +69721,7 @@ class MeasurementTool {
69443
69721
  const tooltip = this.createSegmentTooltipOverlay(vertex, angleText);
69444
69722
  tooltips.push(tooltip);
69445
69723
  this.map.addOverlay(tooltip);
69446
- const featureId2 = feature2.getId() || feature2.ol_uid;
69724
+ const featureId2 = feature2.getId && feature2.getId() || feature2.ol_uid || feature2.get("id");
69447
69725
  const tooltipElement = tooltip.getElement();
69448
69726
  this.angleTooltips.push({
69449
69727
  element: tooltipElement,
@@ -81149,7 +81427,7 @@ let BaseLayer$2 = class BaseLayer2 {
81149
81427
  const styles = customCss.split(";").filter((style) => style.trim());
81150
81428
  styles.forEach((style) => {
81151
81429
  const [property, value] = style.split(":").map((s2) => s2.trim());
81152
- if (property && value) {
81430
+ if (property && value && canvas) {
81153
81431
  canvas.style[property] = value;
81154
81432
  }
81155
81433
  });
@@ -81179,17 +81457,20 @@ let BaseLayer$2 = class BaseLayer2 {
81179
81457
  * 清除图层样式
81180
81458
  */
81181
81459
  clearLayerStyles() {
81182
- var _a3, _b3;
81183
81460
  if (!this.layer)
81184
81461
  return;
81185
- const canvas = (_b3 = (_a3 = this.layer.getRenderer()) == null ? void 0 : _a3.getCanvas) == null ? void 0 : _b3.call(_a3);
81462
+ const renderer = this.layer.getRenderer();
81463
+ let canvas = null;
81464
+ if (renderer && typeof renderer.getCanvas === "function") {
81465
+ canvas = renderer.getCanvas();
81466
+ }
81186
81467
  if (canvas) {
81187
81468
  if (this.config.customCss) {
81188
81469
  const customCss = this.config.customCss;
81189
81470
  const styles = customCss.split(";").filter((style) => style.trim());
81190
81471
  styles.forEach((style) => {
81191
81472
  const [property] = style.split(":").map((s2) => s2.trim());
81192
- if (property) {
81473
+ if (property && canvas) {
81193
81474
  canvas.style[property] = "";
81194
81475
  }
81195
81476
  });
@@ -81458,18 +81739,121 @@ class WMSLayerHandler extends BaseLayer$2 {
81458
81739
  getFeatureInfoUrl(coordinate, resolution, projection2, params2) {
81459
81740
  const layer2 = this.getLayer();
81460
81741
  const source = layer2.getSource();
81461
- if (source && this.map) {
81462
- return source.getFeatureInfoUrl(
81742
+ if (!source)
81743
+ return void 0;
81744
+ return source.getFeatureInfoUrl(
81745
+ coordinate,
81746
+ resolution,
81747
+ projection2,
81748
+ {
81749
+ "INFO_FORMAT": "application/json",
81750
+ "FEATURE_COUNT": 10,
81751
+ ...params2
81752
+ }
81753
+ );
81754
+ }
81755
+ /**
81756
+ * 通过坐标获取要素信息
81757
+ */
81758
+ async getFeatureInfoAtCoordinate(coordinate, options = {}) {
81759
+ const {
81760
+ infoFormat = "application/json",
81761
+ featureCount = 10,
81762
+ resolution,
81763
+ projection: projection2 = "EPSG:3857"
81764
+ } = options;
81765
+ try {
81766
+ const map2 = this.map;
81767
+ if (!map2) {
81768
+ console.warn("地图实例未初始化");
81769
+ return [];
81770
+ }
81771
+ const view = map2.getView();
81772
+ const currentResolution = resolution || view.getResolution();
81773
+ const currentProjection = view.getProjection().getCode();
81774
+ if (!currentResolution) {
81775
+ console.warn("无法获取地图分辨率");
81776
+ return [];
81777
+ }
81778
+ const url = this.getFeatureInfoUrl(
81463
81779
  coordinate,
81464
- resolution,
81465
- projection2,
81780
+ currentResolution,
81781
+ currentProjection,
81466
81782
  {
81467
- "INFO_FORMAT": "application/json",
81468
- ...params2
81783
+ "INFO_FORMAT": infoFormat,
81784
+ "FEATURE_COUNT": featureCount
81469
81785
  }
81470
- ) || void 0;
81786
+ );
81787
+ if (!url) {
81788
+ console.warn("无法构建GetFeatureInfo请求URL");
81789
+ return [];
81790
+ }
81791
+ console.log("WMS GetFeatureInfo请求URL:", url);
81792
+ const response = await fetch(url);
81793
+ if (!response.ok) {
81794
+ throw new Error(`HTTP error! status: ${response.status}`);
81795
+ }
81796
+ const data = await response.json();
81797
+ const features2 = this.parseFeatureInfoResponse(data);
81798
+ return features2.map((feature2) => {
81799
+ const properties = feature2.properties || {};
81800
+ return {
81801
+ ...feature2,
81802
+ properties: {
81803
+ ...properties,
81804
+ layerId: this.config.id,
81805
+ layerName: this.config.name,
81806
+ layerType: "wms"
81807
+ },
81808
+ // 添加OpenLayers Feature兼容方法
81809
+ getProperties: () => ({
81810
+ ...properties,
81811
+ layerId: this.config.id,
81812
+ layerName: this.config.name,
81813
+ layerType: "wms"
81814
+ }),
81815
+ get: (key) => properties[key],
81816
+ setProperties: (props) => {
81817
+ Object.assign(properties, props);
81818
+ }
81819
+ };
81820
+ });
81821
+ } catch (error2) {
81822
+ console.error("WMS GetFeatureInfo查询失败:", error2);
81823
+ return [];
81471
81824
  }
81472
- return void 0;
81825
+ }
81826
+ /**
81827
+ * 解析GetFeatureInfo响应数据
81828
+ */
81829
+ parseFeatureInfoResponse(data) {
81830
+ const features2 = [];
81831
+ try {
81832
+ if (data.type === "FeatureCollection" && data.features) {
81833
+ return data.features;
81834
+ }
81835
+ if (data.type === "Feature") {
81836
+ return [data];
81837
+ }
81838
+ if (Array.isArray(data)) {
81839
+ return data;
81840
+ }
81841
+ if (typeof data === "object" && data !== null) {
81842
+ for (const key in data) {
81843
+ if (Array.isArray(data[key])) {
81844
+ return data[key];
81845
+ }
81846
+ }
81847
+ return [{
81848
+ type: "Feature",
81849
+ properties: data,
81850
+ geometry: null
81851
+ }];
81852
+ }
81853
+ } catch (error2) {
81854
+ console.error("解析WMS响应数据失败:", error2);
81855
+ }
81856
+ return features2;
81473
81857
  }
81474
81858
  }
81475
81859
  class WMTSLayerHandler extends BaseLayer$2 {
@@ -82481,8 +82865,7 @@ class GeoJSONLayerHandler extends BaseLayer$2 {
82481
82865
  view.fit(extent3, {
82482
82866
  padding: fitOptions.padding,
82483
82867
  maxZoom: fitOptions.maxZoom,
82484
- duration: fitOptions.duration,
82485
- minZoom: fitOptions.minZoom
82868
+ duration: fitOptions.duration
82486
82869
  });
82487
82870
  console.log(`已定位到 ${features2.length} 个 GeoJSON 要素`);
82488
82871
  }
@@ -82810,7 +83193,7 @@ class KMLLayerHandler extends BaseLayer$2 {
82810
83193
  }
82811
83194
  class GMLLayerHandler extends BaseLayer$2 {
82812
83195
  constructor(config, map2) {
82813
- super(config, map2);
83196
+ super(config);
82814
83197
  __publicField(this, "vectorSource", null);
82815
83198
  __publicField(this, "gmlFormat", null);
82816
83199
  this.initializeGMLFormat();
@@ -82825,21 +83208,18 @@ class GMLLayerHandler extends BaseLayer$2 {
82825
83208
  case "2":
82826
83209
  case "2.0":
82827
83210
  this.gmlFormat = new GML$1({
82828
- className: gmlConfig.className,
82829
83211
  srsName: gmlConfig.srsName || "EPSG:4326"
82830
83212
  });
82831
83213
  break;
82832
83214
  case "3":
82833
83215
  case "3.0":
82834
83216
  this.gmlFormat = new GML3$1({
82835
- className: gmlConfig.className,
82836
83217
  srsName: gmlConfig.srsName || "EPSG:4326"
82837
83218
  });
82838
83219
  break;
82839
83220
  case "3.2":
82840
83221
  default:
82841
83222
  this.gmlFormat = new GML32$1({
82842
- className: gmlConfig.className,
82843
83223
  srsName: gmlConfig.srsName || "EPSG:4326"
82844
83224
  });
82845
83225
  break;
@@ -83694,7 +84074,7 @@ class ClusterLayerHandler extends BaseLayer$2 {
83694
84074
  * 更新图层配置
83695
84075
  */
83696
84076
  updateLayerConfig(config) {
83697
- super.updateLayerConfig(config);
84077
+ super.updateConfig(config);
83698
84078
  if (config.clusterDistance !== void 0) {
83699
84079
  this.setDistance(config.clusterDistance);
83700
84080
  }
@@ -462706,9 +463086,56 @@ class TileSuperMapRestHandler extends BaseLayer$2 {
462706
463086
  __publicField(this, "styleApplyAttempts", 0);
462707
463087
  __publicField(this, "maxStyleApplyAttempts", 5);
462708
463088
  }
463089
+ /**
463090
+ * 转换SuperMap返回的数据格式为标准格式
463091
+ * 将fieldNames和fieldValues转换为标准的key-value properties格式
463092
+ * @param feature SuperMap返回的要素数据
463093
+ * @returns 转换后的标准格式数据
463094
+ */
463095
+ transformSupermapFeature(feature2) {
463096
+ console.log("transformSupermapFeature 输入:", feature2);
463097
+ console.log("输入类型:", typeof feature2);
463098
+ console.log("是否有fieldNames:", !!feature2.fieldNames);
463099
+ console.log("是否有fieldValues:", !!feature2.fieldValues);
463100
+ console.log("fieldNames类型:", Array.isArray(feature2.fieldNames) ? "array" : typeof feature2.fieldNames);
463101
+ console.log("fieldValues类型:", Array.isArray(feature2.fieldValues) ? "array" : typeof feature2.fieldValues);
463102
+ const hasFieldNames = feature2.fieldNames && (Array.isArray(feature2.fieldNames) || feature2.fieldNames.length !== void 0);
463103
+ const hasFieldValues = feature2.fieldValues && (Array.isArray(feature2.fieldValues) || feature2.fieldValues.length !== void 0);
463104
+ console.log("hasFieldNames:", hasFieldNames);
463105
+ console.log("hasFieldValues:", hasFieldValues);
463106
+ if (hasFieldNames && hasFieldValues) {
463107
+ const properties = {};
463108
+ console.log("开始转换 fieldNames:", feature2.fieldNames);
463109
+ console.log("开始转换 fieldValues:", feature2.fieldValues);
463110
+ const fieldNames2 = Array.isArray(feature2.fieldNames) ? feature2.fieldNames : Object.values(feature2.fieldNames || {});
463111
+ const fieldValues = Array.isArray(feature2.fieldValues) ? feature2.fieldValues : Object.values(feature2.fieldValues || {});
463112
+ console.log("转换后的fieldNames数组:", fieldNames2);
463113
+ console.log("转换后的fieldValues数组:", fieldValues);
463114
+ fieldNames2.forEach((fieldName, index2) => {
463115
+ if (index2 < fieldValues.length) {
463116
+ properties[fieldName] = fieldValues[index2];
463117
+ console.log(`转换字段: ${fieldName} = ${fieldValues[index2]}`);
463118
+ }
463119
+ });
463120
+ console.log("转换后的 properties:", properties);
463121
+ const result = {
463122
+ ...feature2,
463123
+ properties,
463124
+ // 保留原始的fieldNames和fieldValues以备需要
463125
+ _original: {
463126
+ fieldNames: feature2.fieldNames,
463127
+ fieldValues: feature2.fieldValues
463128
+ }
463129
+ };
463130
+ console.log("transformSupermapFeature 输出:", result);
463131
+ return result;
463132
+ }
463133
+ console.log("不是SuperMap格式,直接返回:", feature2);
463134
+ return feature2;
463135
+ }
462709
463136
  setupEPSG4490() {
462710
- proj4$1.defs("EPSG:4490", "+proj=longlat +ellps=GRS80 +no_defs +type=crs");
462711
- register$3(proj4$1);
463137
+ (void 0)("EPSG:4490", "+proj=longlat +ellps=GRS80 +no_defs +type=crs");
463138
+ register$3(proj4$2);
462712
463139
  console.log("EPSG:4490投影已注册");
462713
463140
  }
462714
463141
  async createLayer() {
@@ -462851,8 +463278,11 @@ class TileSuperMapRestHandler extends BaseLayer$2 {
462851
463278
  let mapJsonUrl = config.url;
462852
463279
  if (mapJsonUrl.includes("/rest/maps/")) {
462853
463280
  const match2 = mapJsonUrl.match(/(.*\/rest\/maps\/[^/]+)/);
462854
- if (match2) {
463281
+ if (match2 && match2.length > 1) {
462855
463282
  mapJsonUrl = match2[1] + ".json";
463283
+ } else {
463284
+ console.warn("无法从URL中提取map.json路径,跳过元数据获取");
463285
+ return sourceOptions;
462856
463286
  }
462857
463287
  }
462858
463288
  console.log(`正在获取SuperMap服务元数据: ${mapJsonUrl}`);
@@ -463014,7 +463444,12 @@ class TileSuperMapRestHandler extends BaseLayer$2 {
463014
463444
  const source = (_a3 = this.layer) == null ? void 0 : _a3.getSource();
463015
463445
  if (source) {
463016
463446
  let needsRecreate = false;
463017
- const recreateConfigs = ["format", "transparent", "cacheEnabled", "autoFetchMetadata"];
463447
+ const recreateConfigs = [
463448
+ "format",
463449
+ "transparent",
463450
+ "cacheEnabled",
463451
+ "autoFetchMetadata"
463452
+ ];
463018
463453
  for (const key of recreateConfigs) {
463019
463454
  if (newConfig[key] !== void 0 && newConfig[key] !== this.config[key]) {
463020
463455
  needsRecreate = true;
@@ -463050,6 +463485,568 @@ class TileSuperMapRestHandler extends BaseLayer$2 {
463050
463485
  console.error("重新创建SuperMap图层失败:", error2);
463051
463486
  }
463052
463487
  }
463488
+ /**
463489
+ * 根据地图当前分辨率动态计算点选容差
463490
+ * @param map OpenLayers Map 对象
463491
+ * @param baseTolerance 基础容差(地图坐标系单位,默认为 5)
463492
+ * @returns number 动态计算后的 tolerance
463493
+ */
463494
+ getDynamicTolerance(baseTolerance = 500) {
463495
+ if (!this.map || !this.map.getView)
463496
+ return baseTolerance;
463497
+ const resolution = this.map.getView().getResolution();
463498
+ if (!resolution)
463499
+ return baseTolerance;
463500
+ const dynamicTolerance = baseTolerance * resolution;
463501
+ return dynamicTolerance;
463502
+ }
463503
+ /**
463504
+ * 点选查询要素(类似 WMS GetFeatureInfo)
463505
+ * @param lon 经度
463506
+ * @param lat 纬度
463507
+ * @param options 查询选项
463508
+ * @returns Promise<any[]> 查询到的要素数组
463509
+ */
463510
+ async queryFeatureByPointOL(lon2, lat2, options = {}) {
463511
+ const {
463512
+ datasetNames = ["hms:Football_field"],
463513
+ serviceUrl = "http://172.16.201.151/iserver/services/data-hms-public/rest/data",
463514
+ tolerance: tolerance2 = 0.027,
463515
+ vectorLayer = null
463516
+ } = options;
463517
+ const point2 = new Point$b([lon2, lat2]);
463518
+ let smGeom = Util2.toSuperMapGeometry(point2);
463519
+ if (!smGeom) {
463520
+ const SuperMap2 = window.SuperMap || globalThis.SuperMap;
463521
+ if (SuperMap2 && SuperMap2.Geometry && typeof SuperMap2.Geometry.Point === "function") {
463522
+ smGeom = new SuperMap2.Geometry.Point(lon2, lat2);
463523
+ } else {
463524
+ console.warn("无法构造 SuperMap.Geometry.Point");
463525
+ return [];
463526
+ }
463527
+ }
463528
+ const queryParams = new GetFeaturesByGeometryParameters({
463529
+ datasetNames,
463530
+ geometry: smGeom,
463531
+ spatialQueryMode: "INTERSECT"
463532
+ // WMS 点选风格就是 INTERSECT
463533
+ // tolerance 参数在此版本中不支持,已移除
463534
+ });
463535
+ return new Promise((resolve, reject2) => {
463536
+ new FeatureService2(serviceUrl).getFeaturesByGeometry(
463537
+ queryParams,
463538
+ (result) => {
463539
+ var _a3, _b3, _c2;
463540
+ if (result.error) {
463541
+ console.error("iServer 错误:", result.error);
463542
+ reject2(result.error);
463543
+ return;
463544
+ }
463545
+ const rawFeatures = ((_b3 = (_a3 = result.result) == null ? void 0 : _a3.features) == null ? void 0 : _b3.features) || [];
463546
+ console.log("SuperMap查询结果:", result);
463547
+ console.log("原始要素数组:", rawFeatures);
463548
+ const features2 = rawFeatures.map((feature2) => {
463549
+ console.log("转换前的SuperMap要素:", feature2);
463550
+ console.log("要素的fieldNames:", feature2.fieldNames);
463551
+ console.log("要素的fieldValues:", feature2.fieldValues);
463552
+ const transformedFeature = this.transformSupermapFeature(feature2);
463553
+ console.log("转换后的标准要素:", transformedFeature);
463554
+ console.log("转换后的properties:", transformedFeature.properties);
463555
+ return transformedFeature;
463556
+ });
463557
+ if (vectorLayer) {
463558
+ (_c2 = vectorLayer.getSource()) == null ? void 0 : _c2.clear();
463559
+ features2.forEach((f2) => {
463560
+ var _a4;
463561
+ const olFeat = new Feature$6(Util2.toSuperMapGeometry(f2.geometry));
463562
+ olFeat.setProperties(f2.properties || {});
463563
+ (_a4 = vectorLayer.getSource()) == null ? void 0 : _a4.addFeature(olFeat);
463564
+ });
463565
+ }
463566
+ resolve(features2);
463567
+ }
463568
+ );
463569
+ });
463570
+ }
463571
+ /**
463572
+ * 通过缓冲区查询要素的公共方法
463573
+ * @param lon 经度
463574
+ * @param lat 纬度
463575
+ * @param options 查询选项
463576
+ * @returns Promise<Feature[]> 查询到的要素数组
463577
+ */
463578
+ async getFeaturesByBuffer(lon2 = 93.53179023100006, lat2 = 42.81598224900006, options = {}) {
463579
+ try {
463580
+ const {
463581
+ bufferDistance = 0.027,
463582
+ datasetNames = ["hms:Football_field"],
463583
+ serviceUrl = "http://172.16.201.151/iserver/services/data-hms-public/rest/data",
463584
+ vectorLayer = null
463585
+ } = options;
463586
+ const olPoint = new Point$b([lon2, lat2]);
463587
+ let smGeom = Util2.toSuperMapGeometry(olPoint);
463588
+ console.log("Util.toSuperMapGeometry ->", smGeom);
463589
+ if (!smGeom) {
463590
+ const SuperMap2 = window.SuperMap || globalThis.SuperMap;
463591
+ if (SuperMap2 && SuperMap2.Geometry && typeof SuperMap2.Geometry.Point === "function") {
463592
+ smGeom = new SuperMap2.Geometry.Point(lon2, lat2);
463593
+ console.log("使用全局 SuperMap.Geometry.Point 构建 smGeom:", smGeom);
463594
+ } else {
463595
+ console.warn(
463596
+ "无法取得全局 SuperMap,无法构造 SuperMap.Geometry.Point。建议使用方案A的 REST 调用绕开。"
463597
+ );
463598
+ }
463599
+ }
463600
+ if (!smGeom) {
463601
+ console.error(
463602
+ "无法构建 SuperMap Geometry(smGeom 为 null)。请使用方案A 或检查 iClient 的引入方式。"
463603
+ );
463604
+ return [];
463605
+ }
463606
+ const bufferParams = new GetFeaturesByBufferParameters({
463607
+ datasetNames,
463608
+ bufferDistance,
463609
+ // 举例(300m ≈ 0.0027°),注意单位和坐标系一致
463610
+ geometry: smGeom,
463611
+ spatialQueryMode: "INTERSECT"
463612
+ });
463613
+ return new Promise((resolve, reject2) => {
463614
+ new FeatureService2(serviceUrl).getFeaturesByBuffer(
463615
+ bufferParams,
463616
+ (serviceResult) => {
463617
+ var _a3, _b3, _c2, _d;
463618
+ console.log("serviceResult:", serviceResult);
463619
+ if (serviceResult.error) {
463620
+ console.error("iServer error:", serviceResult.error);
463621
+ reject2(new Error("iServer 返回错误,详见控制台"));
463622
+ return;
463623
+ }
463624
+ const rawFeatures = ((_b3 = (_a3 = serviceResult.result) == null ? void 0 : _a3.features) == null ? void 0 : _b3.features) || [];
463625
+ const feats = rawFeatures.map((f2) => {
463626
+ const transformedFeature = this.transformSupermapFeature(f2);
463627
+ console.log("Buffer查询 - 转换前的SuperMap数据:", f2);
463628
+ console.log("Buffer查询 - 转换后的标准数据:", transformedFeature);
463629
+ const olFeat = new Feature$6(Util2.toSuperMapGeometry(f2.geometry));
463630
+ olFeat.setProperties(transformedFeature.properties || {});
463631
+ return olFeat;
463632
+ });
463633
+ if (vectorLayer) {
463634
+ (_c2 = vectorLayer.getSource()) == null ? void 0 : _c2.clear();
463635
+ if (feats.length) {
463636
+ (_d = vectorLayer.getSource()) == null ? void 0 : _d.addFeatures(feats);
463637
+ }
463638
+ }
463639
+ console.log("查询并绘制完成,count:", feats.length);
463640
+ resolve(feats);
463641
+ }
463642
+ );
463643
+ });
463644
+ } catch (err2) {
463645
+ console.error("queryBuffer 捕获异常:", err2);
463646
+ throw new Error("查询异常,详见控制台");
463647
+ }
463648
+ }
463649
+ // ✅ 构建数据服务 URL(适配 map-hmsmap 服务)
463650
+ buildDataServerUrl(baseUrl) {
463651
+ const mapServiceMatch = baseUrl.match(/services\/map-(.+?)\/rest/);
463652
+ if (!mapServiceMatch) {
463653
+ throw new Error("无法从地图服务 URL 推导数据服务地址");
463654
+ }
463655
+ const workspaceName = mapServiceMatch[1];
463656
+ return `${baseUrl.split("/services")[0]}/services/data-${workspaceName}/rest`;
463657
+ }
463658
+ // ✅ 获取默认数据集(示例)
463659
+ getDefaultDatasets() {
463660
+ return ["football_field@hmsmap"];
463661
+ }
463662
+ /**
463663
+ * 通过边界范围查询要素
463664
+ * @param bounds 边界范围 [minX, minY, maxX, maxY]
463665
+ * @param options 查询选项
463666
+ * @returns Promise<any[]> 查询结果
463667
+ */
463668
+ async getFeaturesByBounds(bounds2, options = {}) {
463669
+ var _a3;
463670
+ const config = this.config;
463671
+ if (!config.url) {
463672
+ console.warn("SuperMap图层缺少服务URL,无法进行要素查询");
463673
+ return [];
463674
+ }
463675
+ const {
463676
+ maxFeatures = 100,
463677
+ datasetNames,
463678
+ returnContent = true,
463679
+ targetProjection
463680
+ } = options;
463681
+ try {
463682
+ const mapProjection = (_a3 = this.map) == null ? void 0 : _a3.getView().getProjection();
463683
+ const projectionCode = targetProjection || (mapProjection == null ? void 0 : mapProjection.getCode()) || "EPSG:4326";
463684
+ let transformedBounds = bounds2;
463685
+ if (mapProjection && targetProjection && mapProjection.getCode() !== targetProjection) {
463686
+ const bottomLeft = transform$l(
463687
+ [bounds2[0], bounds2[1]],
463688
+ mapProjection.getCode(),
463689
+ targetProjection
463690
+ );
463691
+ const topRight = transform$l(
463692
+ [bounds2[2], bounds2[3]],
463693
+ mapProjection.getCode(),
463694
+ targetProjection
463695
+ );
463696
+ transformedBounds = [
463697
+ bottomLeft[0],
463698
+ bottomLeft[1],
463699
+ topRight[0],
463700
+ topRight[1]
463701
+ ];
463702
+ }
463703
+ const serviceUrl = this.buildDataServiceUrl(config.url);
463704
+ console.log(`开始SuperMap边界查询:`, {
463705
+ bounds: transformedBounds,
463706
+ serviceUrl,
463707
+ projection: projectionCode
463708
+ });
463709
+ const boundsParams = new GetFeaturesByBoundsParameters({
463710
+ datasetNames: datasetNames || this.extractDatasetNames(config.url),
463711
+ bounds: transformedBounds,
463712
+ maxFeatures,
463713
+ returnContent
463714
+ });
463715
+ const boundsService = new GetFeaturesByBoundsService(serviceUrl);
463716
+ return new Promise((resolve, reject2) => {
463717
+ boundsService.getFeaturesByBounds(
463718
+ boundsParams,
463719
+ (serviceResult) => {
463720
+ var _a4;
463721
+ if (serviceResult.type === "processCompleted") {
463722
+ const result = serviceResult.result;
463723
+ if (result && result.features) {
463724
+ console.log(
463725
+ `SuperMap边界查询成功,找到 ${result.features.length} 个要素`
463726
+ );
463727
+ resolve(result.features);
463728
+ } else {
463729
+ console.log("SuperMap边界查询完成,但未找到要素");
463730
+ resolve([]);
463731
+ }
463732
+ } else {
463733
+ console.error("SuperMap边界查询失败:", serviceResult.error);
463734
+ reject2(
463735
+ new Error(((_a4 = serviceResult.error) == null ? void 0 : _a4.errorMsg) || "边界查询失败")
463736
+ );
463737
+ }
463738
+ }
463739
+ );
463740
+ });
463741
+ } catch (error2) {
463742
+ console.error("SuperMap边界查询异常:", error2);
463743
+ return [];
463744
+ }
463745
+ }
463746
+ /**
463747
+ * 通过几何对象查询要素
463748
+ * @param geometry OpenLayers几何对象
463749
+ * @param options 查询选项
463750
+ * @returns Promise<any[]> 查询结果
463751
+ */
463752
+ async getFeaturesByGeometry(geometry2, options = {}) {
463753
+ const config = this.config;
463754
+ if (!config.url) {
463755
+ console.warn("SuperMap图层缺少服务URL,无法进行要素查询");
463756
+ return [];
463757
+ }
463758
+ const {
463759
+ maxFeatures = 100,
463760
+ datasetNames,
463761
+ returnContent = true,
463762
+ spatialQueryMode = "INTERSECT",
463763
+ targetProjection
463764
+ } = options;
463765
+ try {
463766
+ const serviceUrl = this.buildDataServiceUrl(config.url);
463767
+ console.log(`开始SuperMap几何查询:`, {
463768
+ geometryType: geometry2.getType(),
463769
+ spatialQueryMode,
463770
+ serviceUrl
463771
+ });
463772
+ const geometryParams = new GetFeaturesByGeometryParameters({
463773
+ datasetNames: datasetNames || this.extractDatasetNames(config.url),
463774
+ geometry: geometry2,
463775
+ maxFeatures,
463776
+ returnContent,
463777
+ spatialQueryMode
463778
+ });
463779
+ const geometryService = new GetFeaturesByGeometryService(serviceUrl);
463780
+ return new Promise((resolve, reject2) => {
463781
+ geometryService.getFeaturesByGeometry(
463782
+ geometryParams,
463783
+ (serviceResult) => {
463784
+ var _a3;
463785
+ if (serviceResult.type === "processCompleted") {
463786
+ const result = serviceResult.result;
463787
+ if (result && result.features) {
463788
+ console.log(
463789
+ `SuperMap几何查询成功,找到 ${result.features.length} 个要素`
463790
+ );
463791
+ resolve(result.features);
463792
+ } else {
463793
+ console.log("SuperMap几何查询完成,但未找到要素");
463794
+ resolve([]);
463795
+ }
463796
+ } else {
463797
+ console.error("SuperMap几何查询失败:", serviceResult.error);
463798
+ reject2(
463799
+ new Error(((_a3 = serviceResult.error) == null ? void 0 : _a3.errorMsg) || "几何查询失败")
463800
+ );
463801
+ }
463802
+ }
463803
+ );
463804
+ });
463805
+ } catch (error2) {
463806
+ console.error("SuperMap几何查询异常:", error2);
463807
+ return [];
463808
+ }
463809
+ }
463810
+ /**
463811
+ * 通过SQL条件查询要素
463812
+ * @param sqlCondition SQL查询条件
463813
+ * @param options 查询选项
463814
+ * @returns Promise<any[]> 查询结果
463815
+ */
463816
+ async getFeaturesBySQL(sqlCondition, options = {}) {
463817
+ const config = this.config;
463818
+ if (!config.url) {
463819
+ console.warn("SuperMap图层缺少服务URL,无法进行要素查询");
463820
+ return [];
463821
+ }
463822
+ const {
463823
+ maxFeatures = 100,
463824
+ datasetNames,
463825
+ returnContent = true,
463826
+ targetProjection
463827
+ } = options;
463828
+ try {
463829
+ const serviceUrl = this.buildDataServiceUrl(config.url);
463830
+ console.log(`开始SuperMap SQL查询:`, {
463831
+ sqlCondition,
463832
+ serviceUrl
463833
+ });
463834
+ const sqlParams = new GetFeaturesBySQLParameters({
463835
+ datasetNames: datasetNames || this.extractDatasetNames(config.url),
463836
+ queryParameter: {
463837
+ name: "sqlQuery",
463838
+ attributeFilter: sqlCondition
463839
+ },
463840
+ maxFeatures,
463841
+ returnContent
463842
+ });
463843
+ const sqlService = new GetFeaturesBySQLService(serviceUrl);
463844
+ return new Promise((resolve, reject2) => {
463845
+ sqlService.getFeaturesBySQL(sqlParams, (serviceResult) => {
463846
+ var _a3;
463847
+ if (serviceResult.type === "processCompleted") {
463848
+ const result = serviceResult.result;
463849
+ if (result && result.features) {
463850
+ console.log(
463851
+ `SuperMap SQL查询成功,找到 ${result.features.length} 个要素`
463852
+ );
463853
+ resolve(result.features);
463854
+ } else {
463855
+ console.log("SuperMap SQL查询完成,但未找到要素");
463856
+ resolve([]);
463857
+ }
463858
+ } else {
463859
+ console.error("SuperMap SQL查询失败:", serviceResult.error);
463860
+ reject2(new Error(((_a3 = serviceResult.error) == null ? void 0 : _a3.errorMsg) || "SQL查询失败"));
463861
+ }
463862
+ });
463863
+ });
463864
+ } catch (error2) {
463865
+ console.error("SuperMap SQL查询异常:", error2);
463866
+ return [];
463867
+ }
463868
+ }
463869
+ /**
463870
+ * 通过要素ID查询要素
463871
+ * @param featureIds 要素ID数组
463872
+ * @param options 查询选项
463873
+ * @returns Promise<any[]> 查询结果
463874
+ */
463875
+ async getFeaturesByIDs(featureIds, options = {}) {
463876
+ const config = this.config;
463877
+ if (!config.url) {
463878
+ console.warn("SuperMap图层缺少服务URL,无法进行要素查询");
463879
+ return [];
463880
+ }
463881
+ const { datasetNames, returnContent = true, targetProjection } = options;
463882
+ try {
463883
+ const serviceUrl = this.buildDataServiceUrl(config.url);
463884
+ console.log(`开始SuperMap ID查询:`, {
463885
+ featureIds,
463886
+ serviceUrl
463887
+ });
463888
+ const idsParams = new GetFeaturesByIDsParameters({
463889
+ datasetNames: datasetNames || this.extractDatasetNames(config.url),
463890
+ IDs: featureIds,
463891
+ returnContent
463892
+ });
463893
+ const idsService = new GetFeaturesByIDsService(serviceUrl);
463894
+ return new Promise((resolve, reject2) => {
463895
+ idsService.getFeaturesByIDs(idsParams, (serviceResult) => {
463896
+ var _a3;
463897
+ if (serviceResult.type === "processCompleted") {
463898
+ const result = serviceResult.result;
463899
+ if (result && result.features) {
463900
+ console.log(
463901
+ `SuperMap ID查询成功,找到 ${result.features.length} 个要素`
463902
+ );
463903
+ resolve(result.features);
463904
+ } else {
463905
+ console.log("SuperMap ID查询完成,但未找到要素");
463906
+ resolve([]);
463907
+ }
463908
+ } else {
463909
+ console.error("SuperMap ID查询失败:", serviceResult.error);
463910
+ reject2(new Error(((_a3 = serviceResult.error) == null ? void 0 : _a3.errorMsg) || "ID查询失败"));
463911
+ }
463912
+ });
463913
+ });
463914
+ } catch (error2) {
463915
+ console.error("SuperMap ID查询异常:", error2);
463916
+ return [];
463917
+ }
463918
+ }
463919
+ /**
463920
+ * 构建数据服务URL
463921
+ * @param mapUrl 地图服务URL
463922
+ * @returns 数据服务URL
463923
+ */
463924
+ buildDataServiceUrl(mapUrl) {
463925
+ try {
463926
+ const url = new URL(mapUrl);
463927
+ if (url.pathname.includes("/rest/data")) {
463928
+ console.log(`已经是数据服务URL: ${mapUrl}`);
463929
+ return mapUrl;
463930
+ }
463931
+ if (url.pathname.includes("/rest/maps/")) {
463932
+ const dataServiceUrl = mapUrl.replace(
463933
+ /\/rest\/maps\/.*$/,
463934
+ "/rest/data"
463935
+ );
463936
+ console.log(`构建数据服务URL: ${mapUrl} -> ${dataServiceUrl}`);
463937
+ return dataServiceUrl;
463938
+ }
463939
+ const pathParts = url.pathname.split("/").filter((part) => part);
463940
+ const servicesIndex = pathParts.findIndex((part) => part === "services");
463941
+ if (servicesIndex !== -1 && servicesIndex + 1 < pathParts.length) {
463942
+ const serviceName = pathParts[servicesIndex + 1];
463943
+ const basePath = pathParts.slice(0, servicesIndex + 2).join("/");
463944
+ const dataServiceUrl = `${url.protocol}//${url.host}/${basePath}/rest/data`;
463945
+ console.log(
463946
+ `从服务名称构建数据服务URL: ${mapUrl} -> ${dataServiceUrl}`
463947
+ );
463948
+ return dataServiceUrl;
463949
+ }
463950
+ throw new Error(`无法解析SuperMap服务URL格式: ${mapUrl}`);
463951
+ } catch (error2) {
463952
+ console.error("构建数据服务URL失败:", error2);
463953
+ return mapUrl;
463954
+ }
463955
+ }
463956
+ /**
463957
+ * 从地图服务URL中提取数据集名称
463958
+ * @param mapUrl 地图服务URL
463959
+ * @returns 数据集名称数组
463960
+ */
463961
+ extractDatasetNames(mapUrl) {
463962
+ try {
463963
+ const url = new URL(mapUrl);
463964
+ const pathParts = url.pathname.split("/").filter((part) => part);
463965
+ const mapsIndex = pathParts.findIndex((part) => part === "maps");
463966
+ if (mapsIndex !== -1 && mapsIndex + 1 < pathParts.length) {
463967
+ const mapName = pathParts[mapsIndex + 1];
463968
+ console.log(`从URL提取到地图名称: ${mapName}`);
463969
+ return [mapName];
463970
+ }
463971
+ const config = this.config;
463972
+ if (config.datasetNames && Array.isArray(config.datasetNames)) {
463973
+ console.log(`使用配置中的数据集名称: ${config.datasetNames}`);
463974
+ return config.datasetNames;
463975
+ }
463976
+ console.warn("无法确定数据集名称,将查询所有可用数据集");
463977
+ return [];
463978
+ } catch (error2) {
463979
+ console.error("提取数据集名称失败:", error2);
463980
+ return [];
463981
+ }
463982
+ }
463983
+ /**
463984
+ * 为popup等功能提供的便捷方法:通过点击坐标获取要素信息
463985
+ * @param coordinate 点击坐标
463986
+ * @param options 查询选项
463987
+ * @returns Promise<any[]> 要素信息数组
463988
+ */
463989
+ async getFeatureInfoAtCoordinate(coordinate, options = {}) {
463990
+ var _a3, _b3, _c2, _d, _e2, _f;
463991
+ const {
463992
+ bufferDistance = 100,
463993
+ maxFeatures = options.featureCount || 10,
463994
+ queryMethod
463995
+ } = options;
463996
+ try {
463997
+ let features2 = [];
463998
+ const finalQueryMethod = queryMethod || ((_a3 = this.config.supermapConfig) == null ? void 0 : _a3.queryMethod) || "point";
463999
+ console.log(`使用查询方式: ${finalQueryMethod}`);
464000
+ if (finalQueryMethod === "buffer") {
464001
+ const configuredBufferDistance = ((_b3 = this.config.supermapConfig) == null ? void 0 : _b3.bufferDistance) || bufferDistance;
464002
+ features2 = await this.getFeaturesByBuffer(
464003
+ coordinate[0],
464004
+ coordinate[1],
464005
+ {
464006
+ bufferDistance: configuredBufferDistance / 1e3,
464007
+ // 转换为度数单位
464008
+ datasetNames: (_c2 = this.config.supermapConfig) == null ? void 0 : _c2.datasetNames,
464009
+ serviceUrl: (_d = this.config.supermapConfig) == null ? void 0 : _d.featureServiceUrl
464010
+ }
464011
+ );
464012
+ } else {
464013
+ features2 = await this.queryFeatureByPointOL(
464014
+ coordinate[0],
464015
+ coordinate[1],
464016
+ {
464017
+ datasetNames: (_e2 = this.config.supermapConfig) == null ? void 0 : _e2.datasetNames,
464018
+ serviceUrl: (_f = this.config.supermapConfig) == null ? void 0 : _f.featureServiceUrl
464019
+ // tolerance 参数已移除,使用默认值
464020
+ }
464021
+ );
464022
+ }
464023
+ return features2.slice(0, maxFeatures).map((feature2) => {
464024
+ if (feature2 && typeof feature2.getProperties === "function") {
464025
+ const properties = feature2.getProperties() || {};
464026
+ feature2.setProperties({
464027
+ ...properties,
464028
+ layerId: this.config.id,
464029
+ layerName: this.config.name,
464030
+ layerType: "supermap-rest"
464031
+ });
464032
+ return feature2;
464033
+ } else {
464034
+ return {
464035
+ ...feature2,
464036
+ properties: {
464037
+ ...feature2.properties || {},
464038
+ layerId: this.config.id,
464039
+ layerName: this.config.name,
464040
+ layerType: "supermap-rest"
464041
+ }
464042
+ };
464043
+ }
464044
+ });
464045
+ } catch (error2) {
464046
+ console.error("获取要素信息失败:", error2);
464047
+ return [];
464048
+ }
464049
+ }
463053
464050
  }
463054
464051
  class CanvasLayerHandler extends BaseLayer$2 {
463055
464052
  constructor() {
@@ -463202,7 +464199,7 @@ class CanvasLayerHandler extends BaseLayer$2 {
463202
464199
  * 更新图层配置
463203
464200
  */
463204
464201
  updateLayerConfig(config) {
463205
- super.updateLayerConfig(config);
464202
+ super.updateConfig(config);
463206
464203
  if (config.canvasConfig) {
463207
464204
  this.updateCanvasConfig(config.canvasConfig);
463208
464205
  }
@@ -463921,176 +464918,6 @@ class LayerManager {
463921
464918
  getLayerHandler(layerId) {
463922
464919
  return this.layerHandlers.get(layerId);
463923
464920
  }
463924
- /**
463925
- * 根据坐标获取图层要素信息(用于tooltip)
463926
- */
463927
- async getFeatureInfoAtCoordinate(coordinate, options = {}) {
463928
- const results = [];
463929
- const { layers, infoFormat = "application/json", featureCount = 10 } = options;
463930
- const view = this.map.getView();
463931
- const resolution = view.getResolution();
463932
- const projection2 = view.getProjection();
463933
- for (const [layerId, config] of this.layerConfigs) {
463934
- if (!config.visible)
463935
- continue;
463936
- if (layers && layers.length > 0 && !layers.includes(layerId)) {
463937
- continue;
463938
- }
463939
- const handler = this.layerHandlers.get(layerId);
463940
- if (!handler)
463941
- continue;
463942
- try {
463943
- const featureInfoConfig = config.featureInfo;
463944
- if (featureInfoConfig == null ? void 0 : featureInfoConfig.enabled) {
463945
- if (featureInfoConfig.customApi) {
463946
- try {
463947
- const customApi = featureInfoConfig.customApi;
463948
- const requestUrl = customApi.url;
463949
- const method = customApi.method || "GET";
463950
- const requestParams = {};
463951
- if (customApi.params) {
463952
- if (customApi.params.coordinate) {
463953
- requestParams[customApi.params.coordinate] = coordinate;
463954
- }
463955
- if (customApi.params.layer) {
463956
- requestParams[customApi.params.layer] = layerId;
463957
- }
463958
- Object.keys(customApi.params).forEach((key) => {
463959
- if (key !== "coordinate" && key !== "layer") {
463960
- requestParams[key] = customApi.params[key];
463961
- }
463962
- });
463963
- }
463964
- const requestOptions = {
463965
- method,
463966
- headers: {
463967
- "Content-Type": "application/json"
463968
- }
463969
- };
463970
- let finalUrl = requestUrl;
463971
- if (method.toUpperCase() === "POST") {
463972
- requestOptions.body = JSON.stringify(requestParams);
463973
- } else {
463974
- const urlParams = new URLSearchParams();
463975
- Object.keys(requestParams).forEach((key) => {
463976
- if (Array.isArray(requestParams[key])) {
463977
- urlParams.append(key, requestParams[key].join(","));
463978
- } else {
463979
- urlParams.append(key, String(requestParams[key]));
463980
- }
463981
- });
463982
- finalUrl = `${requestUrl}?${urlParams.toString()}`;
463983
- }
463984
- const response = await fetch(finalUrl, requestOptions);
463985
- if (response.ok) {
463986
- let data = await response.json();
463987
- if (customApi.responseHandler) {
463988
- try {
463989
- const handlerFunc = new Function("data", `return (${customApi.responseHandler})(data)`);
463990
- data = handlerFunc(data);
463991
- } catch (error2) {
463992
- console.warn("自定义响应处理函数执行失败:", error2);
463993
- }
463994
- }
463995
- const features2 = Array.isArray(data) ? data : data.features || [];
463996
- if (features2.length > 0) {
463997
- results.push({
463998
- layerId,
463999
- layerName: config.name,
464000
- features: features2
464001
- });
464002
- continue;
464003
- }
464004
- }
464005
- } catch (error2) {
464006
- console.warn(`自定义接口查询失败 (${layerId}):`, error2);
464007
- }
464008
- }
464009
- }
464010
- if (config.type === "wms" || config.type === "tile") {
464011
- const layer2 = handler.getLayer();
464012
- const source = layer2.getSource();
464013
- if (source && typeof source.getFeatureInfoUrl === "function") {
464014
- const featureInfoParams = {
464015
- "INFO_FORMAT": infoFormat,
464016
- "FEATURE_COUNT": featureCount,
464017
- ...(featureInfoConfig == null ? void 0 : featureInfoConfig.params) || {}
464018
- };
464019
- const url = source.getFeatureInfoUrl(
464020
- coordinate,
464021
- resolution,
464022
- projection2,
464023
- featureInfoParams
464024
- );
464025
- if (url) {
464026
- const response = await fetch(url);
464027
- if (response.ok) {
464028
- const data = await response.json();
464029
- if (data.features && data.features.length > 0) {
464030
- results.push({
464031
- layerId,
464032
- layerName: config.name,
464033
- features: data.features
464034
- });
464035
- }
464036
- }
464037
- }
464038
- }
464039
- } else if (config.type === "wmts") {
464040
- if (featureInfoConfig == null ? void 0 : featureInfoConfig.enabled) {
464041
- }
464042
- } else if (config.type === "vector") {
464043
- if (featureInfoConfig == null ? void 0 : featureInfoConfig.enabled) {
464044
- const layer2 = handler.getLayer();
464045
- const pixel = this.map.getPixelFromCoordinate(coordinate);
464046
- const features2 = [];
464047
- this.map.forEachFeatureAtPixel(pixel, (feature2) => {
464048
- features2.push({
464049
- properties: feature2.getProperties(),
464050
- geometry: feature2.getGeometry()
464051
- });
464052
- }, { layerFilter: (l2) => l2 === layer2 });
464053
- if (features2.length > 0) {
464054
- results.push({
464055
- layerId,
464056
- layerName: config.name,
464057
- features: features2
464058
- });
464059
- }
464060
- }
464061
- } else if (config.type === "heatmap") {
464062
- if (featureInfoConfig == null ? void 0 : featureInfoConfig.enabled) {
464063
- const layer2 = handler.getLayer();
464064
- const source = layer2.getSource();
464065
- if (source && typeof source.getFeatures === "function") {
464066
- const pixel = this.map.getPixelFromCoordinate(coordinate);
464067
- const features2 = [];
464068
- this.map.forEachFeatureAtPixel(pixel, (feature2) => {
464069
- features2.push({
464070
- properties: feature2.getProperties(),
464071
- geometry: feature2.getGeometry()
464072
- });
464073
- }, { layerFilter: (l2) => l2 === layer2 });
464074
- if (features2.length > 0) {
464075
- results.push({
464076
- layerId,
464077
- layerName: config.name,
464078
- features: features2
464079
- });
464080
- }
464081
- }
464082
- }
464083
- } else if (["bing", "google", "arcgis", "mapbox", "xyz", "webgl", "canvas", "graticule"].includes(config.type)) {
464084
- if (featureInfoConfig == null ? void 0 : featureInfoConfig.enabled) {
464085
- console.log(`图层类型 ${config.type} 需要配置自定义接口来支持要素查询`);
464086
- }
464087
- }
464088
- } catch (error2) {
464089
- console.warn(`获取图层 ${layerId} 要素信息失败:`, error2);
464090
- }
464091
- }
464092
- return results;
464093
- }
464094
464921
  /**
464095
464922
  * 设置图层可见性(支持按需加载)
464096
464923
  */
@@ -464390,6 +465217,98 @@ class LayerManager {
464390
465217
  return false;
464391
465218
  }
464392
465219
  }
465220
+ /**
465221
+ * 根据坐标获取图层要素信息(用于tooltip)
465222
+ */
465223
+ async getFeatureInfoAtCoordinate(coordinate, options) {
465224
+ try {
465225
+ const results = [];
465226
+ const targetLayers = (options == null ? void 0 : options.layers) || Array.from(this.layerHandlers.keys());
465227
+ for (const layerId of targetLayers) {
465228
+ const handler = this.layerHandlers.get(layerId);
465229
+ const config = this.layerConfigs.get(layerId);
465230
+ if (!handler || !config || !config.visible) {
465231
+ continue;
465232
+ }
465233
+ try {
465234
+ if (config.type === "TileSuperMapRest" || config.type === "tilesupermaprest" || config.type === "TILESUPERMAPREST") {
465235
+ if ("getFeatureInfoAtCoordinate" in handler) {
465236
+ const features2 = await handler.getFeatureInfoAtCoordinate(
465237
+ coordinate,
465238
+ {
465239
+ bufferDistance: 80,
465240
+ // 默认5米缓冲区
465241
+ maxFeatures: (options == null ? void 0 : options.featureCount) || 10,
465242
+ returnContent: true
465243
+ }
465244
+ );
465245
+ if (features2 && features2.length > 0) {
465246
+ results.push({
465247
+ layerId,
465248
+ layerName: config.name,
465249
+ layerType: config.type,
465250
+ features: features2
465251
+ });
465252
+ }
465253
+ }
465254
+ } else if (config.type === "wms" || config.type === "WMS") {
465255
+ if ("getFeatureInfoAtCoordinate" in handler) {
465256
+ const features2 = await handler.getFeatureInfoAtCoordinate(
465257
+ coordinate,
465258
+ {
465259
+ infoFormat: (options == null ? void 0 : options.infoFormat) || "application/json",
465260
+ featureCount: (options == null ? void 0 : options.featureCount) || 10
465261
+ }
465262
+ );
465263
+ if (features2 && features2.length > 0) {
465264
+ results.push({
465265
+ layerId,
465266
+ layerName: config.name,
465267
+ layerType: config.type,
465268
+ features: features2
465269
+ });
465270
+ }
465271
+ }
465272
+ } else if (config.type === "vector" || config.type === "geojson") {
465273
+ const layer2 = handler.getLayer();
465274
+ if (layer2 && "getSource" in layer2) {
465275
+ const source = layer2.getSource();
465276
+ if (source && "getFeaturesAtCoordinate" in source) {
465277
+ const features2 = source.getFeaturesAtCoordinate(coordinate);
465278
+ if (features2 && features2.length > 0) {
465279
+ const processedFeatures = features2.slice(0, (options == null ? void 0 : options.featureCount) || 10).map((feature2) => {
465280
+ const properties = feature2.getProperties ? feature2.getProperties() : {};
465281
+ const enhancedProperties = {
465282
+ ...properties,
465283
+ layerId,
465284
+ layerName: config.name,
465285
+ layerType: config.type
465286
+ };
465287
+ if (feature2.setProperties) {
465288
+ feature2.setProperties(enhancedProperties);
465289
+ }
465290
+ return feature2;
465291
+ });
465292
+ results.push({
465293
+ layerId,
465294
+ layerName: config.name,
465295
+ layerType: config.type,
465296
+ features: processedFeatures
465297
+ });
465298
+ }
465299
+ }
465300
+ }
465301
+ }
465302
+ } catch (error2) {
465303
+ console.warn(`图层 ${layerId} 要素查询失败:`, error2);
465304
+ }
465305
+ }
465306
+ return results;
465307
+ } catch (error2) {
465308
+ console.error("获取要素信息失败:", error2);
465309
+ return [];
465310
+ }
465311
+ }
464393
465312
  /**
464394
465313
  * 销毁图层管理器
464395
465314
  */
@@ -464904,21 +465823,24 @@ class MapManager {
464904
465823
  }
464905
465824
  if (this.layerManager) {
464906
465825
  try {
464907
- const wmsFeatures = await this.layerManager.getFeatureInfoAtCoordinate(lonLatCoordinate);
464908
- if (wmsFeatures.length > 0) {
464909
- const wmsLayerData = wmsFeatures[0];
464910
- if (wmsLayerData.features && wmsLayerData.features.length > 0) {
464911
- const feature2 = wmsLayerData.features[0];
464912
- const layer2 = {
464913
- layerId: wmsLayerData.layerId,
464914
- layerName: wmsLayerData.layerName
464915
- };
464916
- this.emit("feature-click", feature2, layer2, lonLatCoordinate);
464917
- return;
465826
+ const featureInfoResults = await this.layerManager.getFeatureInfoAtCoordinate(
465827
+ lonLatCoordinate,
465828
+ {
465829
+ featureCount: 10
464918
465830
  }
465831
+ );
465832
+ if (featureInfoResults && featureInfoResults.length > 0) {
465833
+ const tooltipData = featureInfoResults.map((result) => ({
465834
+ layerId: result.layerId,
465835
+ layerName: result.layerName,
465836
+ features: result.features,
465837
+ coordinate: lonLatCoordinate
465838
+ }));
465839
+ this.emit("feature-info", tooltipData);
465840
+ return;
464919
465841
  }
464920
465842
  } catch (error2) {
464921
- console.warn("查询WMS图层要素信息失败:", error2);
465843
+ console.warn("查询图层要素信息失败:", error2);
464922
465844
  }
464923
465845
  }
464924
465846
  this.emit("map-click", {
@@ -465169,7 +466091,7 @@ class MapManager {
465169
466091
  if (!this.map)
465170
466092
  return;
465171
466093
  this.map.on("singleclick", async (evt) => {
465172
- var _a3, _b3, _c2, _d;
466094
+ var _a3, _b3, _c2;
465173
466095
  const coordinate = evt.coordinate;
465174
466096
  const pixel = evt.pixel;
465175
466097
  const view = this.map.getView();
@@ -465201,24 +466123,7 @@ class MapManager {
465201
466123
  }
465202
466124
  (_b3 = callbacks.onFeatureClick) == null ? void 0 : _b3.call(callbacks, feature2, layer2, lonLatCoordinate, mapCoordinate);
465203
466125
  } else {
465204
- try {
465205
- const wmsFeatures = await this.layerManager.getFeatureInfoAtCoordinate(coordinate);
465206
- if (wmsFeatures.length > 0) {
465207
- const wmsLayerData = wmsFeatures[0];
465208
- if (wmsLayerData.features && wmsLayerData.features.length > 0) {
465209
- const feature2 = wmsLayerData.features[0];
465210
- const layer2 = {
465211
- layerId: wmsLayerData.layerId,
465212
- layerName: wmsLayerData.layerName
465213
- };
465214
- (_c2 = callbacks.onFeatureClick) == null ? void 0 : _c2.call(callbacks, feature2, layer2, lonLatCoordinate, mapCoordinate);
465215
- return;
465216
- }
465217
- }
465218
- } catch (error2) {
465219
- console.warn("WMS GetFeatureInfo request failed:", error2);
465220
- }
465221
- (_d = callbacks.onMapClick) == null ? void 0 : _d.call(callbacks, {
466126
+ (_c2 = callbacks.onMapClick) == null ? void 0 : _c2.call(callbacks, {
465222
466127
  coordinate: lonLatCoordinate,
465223
466128
  mapCoordinate,
465224
466129
  pixel,
@@ -465348,7 +466253,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
465348
466253
  loading: { type: Boolean, default: false },
465349
466254
  userMarkers: {}
465350
466255
  },
465351
- emits: ["map-ready", "map-click", "map-dblclick", "map-contextmenu", "map-move", "zoom-change"],
466256
+ emits: ["map-ready", "map-click", "map-dblclick", "map-contextmenu", "map-move", "zoom-change", "feature-info"],
465352
466257
  setup(__props, { expose: __expose, emit: __emit }) {
465353
466258
  const props = __props;
465354
466259
  const emit = __emit;
@@ -465435,6 +466340,9 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
465435
466340
  emit("map-contextmenu", { coordinate, pixel });
465436
466341
  }
465437
466342
  });
466343
+ mapManager.value.on("feature-info", (data) => {
466344
+ emit("feature-info", data);
466345
+ });
465438
466346
  };
465439
466347
  const updateMapConfig = (config) => {
465440
466348
  if (!map2.value)
@@ -465506,7 +466414,7 @@ const _export_sfc = (sfc, props) => {
465506
466414
  }
465507
466415
  return target;
465508
466416
  };
465509
- const MapContainer = /* @__PURE__ */ _export_sfc(_sfc_main$q, [["__scopeId", "data-v-53c8deda"]]);
466417
+ const MapContainer = /* @__PURE__ */ _export_sfc(_sfc_main$q, [["__scopeId", "data-v-9900e920"]]);
465510
466418
  const _hoisted_1$n = ["href"];
465511
466419
  const _sfc_main$p = /* @__PURE__ */ defineComponent({
465512
466420
  __name: "index",
@@ -476245,19 +477153,25 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
476245
477153
  { "ol-popup-vertical": _ctx.config.vertical },
476246
477154
  _ctx.config.className
476247
477155
  ]),
476248
- style: normalizeStyle$1(popupStyle.value)
477156
+ style: normalizeStyle$1(popupStyle.value),
477157
+ onClick: _cache[0] || (_cache[0] = withModifiers(() => {
477158
+ }, ["stop"])),
477159
+ onMousedown: _cache[1] || (_cache[1] = withModifiers(() => {
477160
+ }, ["stop"])),
477161
+ onMouseup: _cache[2] || (_cache[2] = withModifiers(() => {
477162
+ }, ["stop"]))
476249
477163
  }, [
476250
- _cache[2] || (_cache[2] = createElementVNode("div", { class: "ol-popup-tip" }, null, -1)),
477164
+ _cache[5] || (_cache[5] = createElementVNode("div", { class: "ol-popup-tip" }, null, -1)),
476251
477165
  _ctx.config.showCloseButton !== false ? (openBlock(), createBlock(unref(ElButton), {
476252
477166
  key: 0,
476253
477167
  class: "ol-popup-closer",
476254
- onClick: handleClose,
477168
+ onClick: withModifiers(handleClose, ["stop"]),
476255
477169
  title: "关闭",
476256
477170
  text: "",
476257
477171
  circle: "",
476258
477172
  size: "small"
476259
477173
  }, {
476260
- default: withCtx(() => [..._cache[0] || (_cache[0] = [
477174
+ default: withCtx(() => [..._cache[3] || (_cache[3] = [
476261
477175
  createTextVNode(" × ", -1)
476262
477176
  ])]),
476263
477177
  _: 1
@@ -476272,16 +477186,16 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
476272
477186
  coordinate: _ctx.coordinate,
476273
477187
  config: _ctx.config
476274
477188
  }, () => [
476275
- _cache[1] || (_cache[1] = createElementVNode("div", { class: "ol-popup-default" }, [
477189
+ _cache[4] || (_cache[4] = createElementVNode("div", { class: "ol-popup-default" }, [
476276
477190
  createElementVNode("p", null, "请提供 popup 内容")
476277
477191
  ], -1))
476278
477192
  ], true)
476279
477193
  ], 512)
476280
- ], 6)) : createCommentVNode("", true);
477194
+ ], 38)) : createCommentVNode("", true);
476281
477195
  };
476282
477196
  }
476283
477197
  });
476284
- const BasePopup = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-ec278a8a"]]);
477198
+ const BasePopup = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-9a5b6333"]]);
476285
477199
  const _hoisted_1$3 = { class: "html-popup-content" };
476286
477200
  const _hoisted_2$3 = {
476287
477201
  key: 0,
@@ -476744,7 +477658,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
476744
477658
  setup(__props, { emit: __emit }) {
476745
477659
  const props = __props;
476746
477660
  const emit = __emit;
476747
- const currentView = ref(props.config.defaultView || "table");
477661
+ const currentView = ref(props.config.defaultView || "list");
476748
477662
  const searchQuery = ref("");
476749
477663
  const sortField = ref("");
476750
477664
  const sortOrder = ref("asc");
@@ -477090,7 +478004,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
477090
478004
  };
477091
478005
  }
477092
478006
  });
477093
- const ArrayPopup = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-4a372183"]]);
478007
+ const ArrayPopup = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-140dd964"]]);
477094
478008
  class PopupManager {
477095
478009
  constructor(map2, config = {}) {
477096
478010
  __publicField(this, "map");
@@ -477776,7 +478690,127 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
477776
478690
  emit("zoom-change", zoom, oldZoom);
477777
478691
  };
477778
478692
  const onFeatureInfo = (data) => {
477779
- emit("feature-info", data);
478693
+ if (data && data.length > 0) {
478694
+ const firstResult = data[0];
478695
+ const { layerId, layerName, features: features2, coordinate } = firstResult;
478696
+ if (features2 && features2.length > 0) {
478697
+ const feature2 = features2[0];
478698
+ const layerInfo = {
478699
+ layerId,
478700
+ layerName
478701
+ };
478702
+ emit("feature-click", feature2, layerInfo, coordinate);
478703
+ if (popupManager.value) {
478704
+ const allLayers = [...finalMapConfig.value.baseLayers || [], ...finalMapConfig.value.overlayLayers || [], ...finalMapConfig.value.vectorLayers || []];
478705
+ const targetLayer = allLayers.find((l2) => l2.id === layerId || l2.name === layerName);
478706
+ if (targetLayer && targetLayer.popup) {
478707
+ const popupConfig = targetLayer.popup;
478708
+ console.log("显示SuperMap图层popup:", { layerId, layerName, feature: feature2, coordinate });
478709
+ let properties;
478710
+ if (feature2 && typeof feature2.getProperties === "function") {
478711
+ properties = feature2.getProperties();
478712
+ console.log("OpenLayers Feature属性:", properties);
478713
+ } else if (feature2 && feature2.properties) {
478714
+ properties = feature2.properties;
478715
+ console.log("GeoJSON Feature属性:", properties);
478716
+ } else {
478717
+ properties = feature2;
478718
+ console.log("其他格式属性:", properties);
478719
+ }
478720
+ console.log("SuperMap要素属性数据:", properties);
478721
+ console.log("popup配置字段:", popupConfig.fields);
478722
+ let content2 = {};
478723
+ let hasValidFields = false;
478724
+ if (popupConfig.fields && Array.isArray(popupConfig.fields)) {
478725
+ popupConfig.fields.forEach((field) => {
478726
+ if (typeof field === "string") {
478727
+ const value = properties[field];
478728
+ console.log(`字段 ${field} 的值:`, value);
478729
+ if (value !== void 0 && value !== null) {
478730
+ content2[field] = value;
478731
+ hasValidFields = true;
478732
+ } else {
478733
+ content2[field] = "--";
478734
+ }
478735
+ } else if (field.name) {
478736
+ const displayName = field.label || field.name;
478737
+ const value = properties[field.name];
478738
+ console.log(`字段 ${field.name} (${displayName}) 的值:`, value);
478739
+ if (value !== void 0 && value !== null) {
478740
+ content2[displayName] = value;
478741
+ hasValidFields = true;
478742
+ } else {
478743
+ content2[displayName] = "--";
478744
+ }
478745
+ }
478746
+ });
478747
+ if (!hasValidFields && properties && Object.keys(properties).length > 0) {
478748
+ console.log("配置的字段无效,显示所有属性:", properties);
478749
+ content2 = { ...properties };
478750
+ }
478751
+ } else {
478752
+ content2 = properties;
478753
+ }
478754
+ console.log("最终popup内容:", content2);
478755
+ const getPopupType = (config) => {
478756
+ if (config.type) {
478757
+ return config.type;
478758
+ }
478759
+ if (config.fields && Array.isArray(config.fields)) {
478760
+ return "array";
478761
+ }
478762
+ if (config.htmlContent || config.content) {
478763
+ return "html";
478764
+ }
478765
+ if (config.images && Array.isArray(config.images)) {
478766
+ return "image";
478767
+ }
478768
+ return "array";
478769
+ };
478770
+ const popupType = getPopupType(popupConfig);
478771
+ let finalConfig = {
478772
+ title: popupConfig.title || layerName || "要素信息",
478773
+ showCloseButton: true,
478774
+ maxWidth: 300,
478775
+ maxHeight: 400,
478776
+ ...popupConfig
478777
+ };
478778
+ switch (popupType) {
478779
+ case "array":
478780
+ finalConfig = {
478781
+ ...finalConfig,
478782
+ type: "array",
478783
+ fields: popupConfig.fields || Object.keys(properties).map((key) => ({ name: key, label: key, type: "text" })),
478784
+ data: [properties],
478785
+ vertical: true
478786
+ };
478787
+ break;
478788
+ case "html":
478789
+ finalConfig = {
478790
+ ...finalConfig,
478791
+ type: "html",
478792
+ content: popupConfig.htmlContent || popupConfig.content || content2
478793
+ };
478794
+ break;
478795
+ case "image":
478796
+ finalConfig = {
478797
+ ...finalConfig,
478798
+ type: "image",
478799
+ images: popupConfig.images || []
478800
+ };
478801
+ break;
478802
+ default:
478803
+ finalConfig = {
478804
+ ...finalConfig,
478805
+ htmlContent: content2
478806
+ };
478807
+ break;
478808
+ }
478809
+ showPopup(popupType, finalConfig, coordinate);
478810
+ }
478811
+ }
478812
+ }
478813
+ }
477780
478814
  };
477781
478815
  const onFeatureClick = (feature2, layer2, clickCoordinate, mapCoordinate) => {
477782
478816
  let popupConfig = null;
@@ -478592,7 +479626,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
478592
479626
  };
478593
479627
  }
478594
479628
  });
478595
- const CustomOpenlayer = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-cb07ef9b"]]);
479629
+ const CustomOpenlayer = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-02822978"]]);
478596
479630
  var u8 = Uint8Array;
478597
479631
  var u16 = Uint16Array;
478598
479632
  var i32 = Int32Array;
@@ -486864,7 +487898,7 @@ function(t3) {
486864
487898
  */
486865
487899
  function(t3) {
486866
487900
  function e8() {
486867
- return (n.canvg ? Promise.resolve(n.canvg) : import("./index.es-a8e2a821.mjs")).catch(function(t4) {
487901
+ return (n.canvg ? Promise.resolve(n.canvg) : import("./index.es-9e1aa406.mjs")).catch(function(t4) {
486868
487902
  return Promise.reject(new Error("Could not load canvg: " + t4));
486869
487903
  }).then(function(t4) {
486870
487904
  return t4.default ? t4.default : t4;