vue-openlayers-plugin 1.0.31 → 1.0.33
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.
- package/lib/{index-5109705e.mjs → index-ce768f90.mjs} +1265 -310
- package/lib/{index.es-ab75e372.mjs → index.es-3480a166.mjs} +1 -1
- package/lib/index.esm.js +1 -1
- package/lib/index.umd.js +1269 -314
- package/lib/style.css +144 -103
- package/package.json +1 -1
- package/types/src/components/CustomOpenlayer/components/MapContainer.vue.d.ts +2 -0
- package/types/src/components/CustomOpenlayer/components/MapContainer.vue.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/components/MapPopup/ArrayPopup.vue.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/components/MapPopup/BasePopup.vue.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/components/MapPopup/PopupManager.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/components/MapPopup/types.d.ts +1 -0
- package/types/src/components/CustomOpenlayer/components/MapPopup/types.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/index.vue.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/types/index.d.ts +89 -172
- package/types/src/components/CustomOpenlayer/types/index.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/utils/eventManager.d.ts +0 -15
- package/types/src/components/CustomOpenlayer/utils/eventManager.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/utils/layerManager.d.ts +8 -8
- package/types/src/components/CustomOpenlayer/utils/layerManager.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/utils/layers/BaseLayer.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/utils/layers/CanvasLayerHandler.d.ts +2 -1
- package/types/src/components/CustomOpenlayer/utils/layers/CanvasLayerHandler.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/utils/layers/ClusterLayerHandler.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/utils/layers/GMLLayerHandler.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/utils/layers/GeoJSONLayerHandler.d.ts +0 -1
- package/types/src/components/CustomOpenlayer/utils/layers/GeoJSONLayerHandler.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/utils/layers/SuperMapServiceTester.d.ts +54 -0
- package/types/src/components/CustomOpenlayer/utils/layers/SuperMapServiceTester.d.ts.map +1 -0
- package/types/src/components/CustomOpenlayer/utils/layers/TileSuperMapRestHandler.d.ts +109 -0
- package/types/src/components/CustomOpenlayer/utils/layers/TileSuperMapRestHandler.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/utils/layers/WMSLayerHandler.d.ts +14 -1
- package/types/src/components/CustomOpenlayer/utils/layers/WMSLayerHandler.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/utils/mapManager.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/utils/storage.d.ts +62 -0
- package/types/src/components/CustomOpenlayer/utils/storage.d.ts.map +1 -1
- package/types/tsconfig.tsbuildinfo +1 -1
|
@@ -41751,7 +41751,7 @@ function checkProj$1(item) {
|
|
|
41751
41751
|
item
|
|
41752
41752
|
);
|
|
41753
41753
|
}
|
|
41754
|
-
function proj4$
|
|
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$
|
|
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
|
-
|
|
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 =
|
|
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
|
|
69128
|
-
|
|
69129
|
-
|
|
69130
|
-
|
|
69131
|
-
|
|
69132
|
-
|
|
69133
|
-
|
|
69134
|
-
|
|
69135
|
-
|
|
69136
|
-
|
|
69137
|
-
|
|
69138
|
-
|
|
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 =
|
|
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
|
-
|
|
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 =
|
|
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
|
|
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
|
|
81462
|
-
return
|
|
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
|
-
|
|
81465
|
-
|
|
81780
|
+
currentResolution,
|
|
81781
|
+
currentProjection,
|
|
81466
81782
|
{
|
|
81467
|
-
"INFO_FORMAT":
|
|
81468
|
-
|
|
81783
|
+
"INFO_FORMAT": infoFormat,
|
|
81784
|
+
"FEATURE_COUNT": featureCount
|
|
81785
|
+
}
|
|
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 [];
|
|
81824
|
+
}
|
|
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
|
+
}
|
|
81469
81846
|
}
|
|
81470
|
-
|
|
81847
|
+
return [{
|
|
81848
|
+
type: "Feature",
|
|
81849
|
+
properties: data,
|
|
81850
|
+
geometry: null
|
|
81851
|
+
}];
|
|
81852
|
+
}
|
|
81853
|
+
} catch (error2) {
|
|
81854
|
+
console.error("解析WMS响应数据失败:", error2);
|
|
81471
81855
|
}
|
|
81472
|
-
return
|
|
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
|
|
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.
|
|
84077
|
+
super.updateConfig(config);
|
|
83698
84078
|
if (config.clusterDistance !== void 0) {
|
|
83699
84079
|
this.setDistance(config.clusterDistance);
|
|
83700
84080
|
}
|
|
@@ -462707,8 +463087,8 @@ class TileSuperMapRestHandler extends BaseLayer$2 {
|
|
|
462707
463087
|
__publicField(this, "maxStyleApplyAttempts", 5);
|
|
462708
463088
|
}
|
|
462709
463089
|
setupEPSG4490() {
|
|
462710
|
-
|
|
462711
|
-
register$3(proj4$
|
|
463090
|
+
(void 0)("EPSG:4490", "+proj=longlat +ellps=GRS80 +no_defs +type=crs");
|
|
463091
|
+
register$3(proj4$2);
|
|
462712
463092
|
console.log("EPSG:4490投影已注册");
|
|
462713
463093
|
}
|
|
462714
463094
|
async createLayer() {
|
|
@@ -462851,8 +463231,11 @@ class TileSuperMapRestHandler extends BaseLayer$2 {
|
|
|
462851
463231
|
let mapJsonUrl = config.url;
|
|
462852
463232
|
if (mapJsonUrl.includes("/rest/maps/")) {
|
|
462853
463233
|
const match2 = mapJsonUrl.match(/(.*\/rest\/maps\/[^/]+)/);
|
|
462854
|
-
if (match2) {
|
|
463234
|
+
if (match2 && match2.length > 1) {
|
|
462855
463235
|
mapJsonUrl = match2[1] + ".json";
|
|
463236
|
+
} else {
|
|
463237
|
+
console.warn("无法从URL中提取map.json路径,跳过元数据获取");
|
|
463238
|
+
return sourceOptions;
|
|
462856
463239
|
}
|
|
462857
463240
|
}
|
|
462858
463241
|
console.log(`正在获取SuperMap服务元数据: ${mapJsonUrl}`);
|
|
@@ -463014,7 +463397,12 @@ class TileSuperMapRestHandler extends BaseLayer$2 {
|
|
|
463014
463397
|
const source = (_a3 = this.layer) == null ? void 0 : _a3.getSource();
|
|
463015
463398
|
if (source) {
|
|
463016
463399
|
let needsRecreate = false;
|
|
463017
|
-
const recreateConfigs = [
|
|
463400
|
+
const recreateConfigs = [
|
|
463401
|
+
"format",
|
|
463402
|
+
"transparent",
|
|
463403
|
+
"cacheEnabled",
|
|
463404
|
+
"autoFetchMetadata"
|
|
463405
|
+
];
|
|
463018
463406
|
for (const key of recreateConfigs) {
|
|
463019
463407
|
if (newConfig[key] !== void 0 && newConfig[key] !== this.config[key]) {
|
|
463020
463408
|
needsRecreate = true;
|
|
@@ -463050,6 +463438,539 @@ class TileSuperMapRestHandler extends BaseLayer$2 {
|
|
|
463050
463438
|
console.error("重新创建SuperMap图层失败:", error2);
|
|
463051
463439
|
}
|
|
463052
463440
|
}
|
|
463441
|
+
/**
|
|
463442
|
+
* 根据地图当前分辨率动态计算点选容差
|
|
463443
|
+
* @param map OpenLayers Map 对象
|
|
463444
|
+
* @param baseTolerance 基础容差(地图坐标系单位,默认为 5)
|
|
463445
|
+
* @returns number 动态计算后的 tolerance
|
|
463446
|
+
*/
|
|
463447
|
+
getDynamicTolerance(baseTolerance = 500) {
|
|
463448
|
+
if (!this.map || !this.map.getView)
|
|
463449
|
+
return baseTolerance;
|
|
463450
|
+
const resolution = this.map.getView().getResolution();
|
|
463451
|
+
if (!resolution)
|
|
463452
|
+
return baseTolerance;
|
|
463453
|
+
const dynamicTolerance = baseTolerance * resolution;
|
|
463454
|
+
return dynamicTolerance;
|
|
463455
|
+
}
|
|
463456
|
+
/**
|
|
463457
|
+
* 点选查询要素(类似 WMS GetFeatureInfo)
|
|
463458
|
+
* @param lon 经度
|
|
463459
|
+
* @param lat 纬度
|
|
463460
|
+
* @param options 查询选项
|
|
463461
|
+
* @returns Promise<any[]> 查询到的要素数组
|
|
463462
|
+
*/
|
|
463463
|
+
async queryFeatureByPointOL(lon2, lat2, options = {}) {
|
|
463464
|
+
const {
|
|
463465
|
+
datasetNames = ["hms:Football_field"],
|
|
463466
|
+
serviceUrl = "http://172.16.201.151/iserver/services/data-hms-public/rest/data",
|
|
463467
|
+
tolerance: tolerance2 = 0.027,
|
|
463468
|
+
vectorLayer = null
|
|
463469
|
+
} = options;
|
|
463470
|
+
const point2 = new Point$b([lon2, lat2]);
|
|
463471
|
+
let smGeom = Util2.toSuperMapGeometry(point2);
|
|
463472
|
+
if (!smGeom) {
|
|
463473
|
+
const SuperMap2 = window.SuperMap || globalThis.SuperMap;
|
|
463474
|
+
if (SuperMap2 && SuperMap2.Geometry && typeof SuperMap2.Geometry.Point === "function") {
|
|
463475
|
+
smGeom = new SuperMap2.Geometry.Point(lon2, lat2);
|
|
463476
|
+
} else {
|
|
463477
|
+
console.warn("无法构造 SuperMap.Geometry.Point");
|
|
463478
|
+
return [];
|
|
463479
|
+
}
|
|
463480
|
+
}
|
|
463481
|
+
const queryParams = new GetFeaturesByGeometryParameters({
|
|
463482
|
+
datasetNames,
|
|
463483
|
+
geometry: smGeom,
|
|
463484
|
+
spatialQueryMode: "INTERSECT"
|
|
463485
|
+
// WMS 点选风格就是 INTERSECT
|
|
463486
|
+
// tolerance 参数在此版本中不支持,已移除
|
|
463487
|
+
});
|
|
463488
|
+
return new Promise((resolve, reject2) => {
|
|
463489
|
+
new FeatureService2(serviceUrl).getFeaturesByGeometry(
|
|
463490
|
+
queryParams,
|
|
463491
|
+
(result) => {
|
|
463492
|
+
var _a3, _b3, _c2;
|
|
463493
|
+
if (result.error) {
|
|
463494
|
+
console.error("iServer 错误:", result.error);
|
|
463495
|
+
reject2(result.error);
|
|
463496
|
+
return;
|
|
463497
|
+
}
|
|
463498
|
+
const features2 = ((_b3 = (_a3 = result.result) == null ? void 0 : _a3.features) == null ? void 0 : _b3.features) || [];
|
|
463499
|
+
if (vectorLayer) {
|
|
463500
|
+
(_c2 = vectorLayer.getSource()) == null ? void 0 : _c2.clear();
|
|
463501
|
+
features2.forEach((f2) => {
|
|
463502
|
+
var _a4;
|
|
463503
|
+
const olFeat = new Feature$6(Util2.toSuperMapGeometry(f2.geometry));
|
|
463504
|
+
olFeat.setProperties(f2.properties || {});
|
|
463505
|
+
(_a4 = vectorLayer.getSource()) == null ? void 0 : _a4.addFeature(olFeat);
|
|
463506
|
+
});
|
|
463507
|
+
}
|
|
463508
|
+
resolve(features2);
|
|
463509
|
+
}
|
|
463510
|
+
);
|
|
463511
|
+
});
|
|
463512
|
+
}
|
|
463513
|
+
/**
|
|
463514
|
+
* 通过缓冲区查询要素的公共方法
|
|
463515
|
+
* @param lon 经度
|
|
463516
|
+
* @param lat 纬度
|
|
463517
|
+
* @param options 查询选项
|
|
463518
|
+
* @returns Promise<Feature[]> 查询到的要素数组
|
|
463519
|
+
*/
|
|
463520
|
+
async getFeaturesByBuffer(lon2 = 93.53179023100006, lat2 = 42.81598224900006, options = {}) {
|
|
463521
|
+
try {
|
|
463522
|
+
const {
|
|
463523
|
+
bufferDistance = 0.027,
|
|
463524
|
+
datasetNames = ["hms:Football_field"],
|
|
463525
|
+
serviceUrl = "http://172.16.201.151/iserver/services/data-hms-public/rest/data",
|
|
463526
|
+
vectorLayer = null
|
|
463527
|
+
} = options;
|
|
463528
|
+
const olPoint = new Point$b([lon2, lat2]);
|
|
463529
|
+
let smGeom = Util2.toSuperMapGeometry(olPoint);
|
|
463530
|
+
console.log("Util.toSuperMapGeometry ->", smGeom);
|
|
463531
|
+
if (!smGeom) {
|
|
463532
|
+
const SuperMap2 = window.SuperMap || globalThis.SuperMap;
|
|
463533
|
+
if (SuperMap2 && SuperMap2.Geometry && typeof SuperMap2.Geometry.Point === "function") {
|
|
463534
|
+
smGeom = new SuperMap2.Geometry.Point(lon2, lat2);
|
|
463535
|
+
console.log("使用全局 SuperMap.Geometry.Point 构建 smGeom:", smGeom);
|
|
463536
|
+
} else {
|
|
463537
|
+
console.warn(
|
|
463538
|
+
"无法取得全局 SuperMap,无法构造 SuperMap.Geometry.Point。建议使用方案A的 REST 调用绕开。"
|
|
463539
|
+
);
|
|
463540
|
+
}
|
|
463541
|
+
}
|
|
463542
|
+
if (!smGeom) {
|
|
463543
|
+
console.error(
|
|
463544
|
+
"无法构建 SuperMap Geometry(smGeom 为 null)。请使用方案A 或检查 iClient 的引入方式。"
|
|
463545
|
+
);
|
|
463546
|
+
return [];
|
|
463547
|
+
}
|
|
463548
|
+
const bufferParams = new GetFeaturesByBufferParameters({
|
|
463549
|
+
datasetNames,
|
|
463550
|
+
bufferDistance,
|
|
463551
|
+
// 举例(300m ≈ 0.0027°),注意单位和坐标系一致
|
|
463552
|
+
geometry: smGeom,
|
|
463553
|
+
spatialQueryMode: "INTERSECT"
|
|
463554
|
+
});
|
|
463555
|
+
return new Promise((resolve, reject2) => {
|
|
463556
|
+
new FeatureService2(serviceUrl).getFeaturesByBuffer(
|
|
463557
|
+
bufferParams,
|
|
463558
|
+
(serviceResult) => {
|
|
463559
|
+
var _a3, _b3, _c2, _d, _e2;
|
|
463560
|
+
console.log("serviceResult:", serviceResult);
|
|
463561
|
+
if (serviceResult.error) {
|
|
463562
|
+
console.error("iServer error:", serviceResult.error);
|
|
463563
|
+
reject2(new Error("iServer 返回错误,详见控制台"));
|
|
463564
|
+
return;
|
|
463565
|
+
}
|
|
463566
|
+
const feats = ((_c2 = (_b3 = (_a3 = serviceResult.result) == null ? void 0 : _a3.features) == null ? void 0 : _b3.features) == null ? void 0 : _c2.map(
|
|
463567
|
+
(f2) => new Feature$6(Util2.toSuperMapGeometry(f2.geometry))
|
|
463568
|
+
)) ?? [];
|
|
463569
|
+
if (vectorLayer) {
|
|
463570
|
+
(_d = vectorLayer.getSource()) == null ? void 0 : _d.clear();
|
|
463571
|
+
if (feats.length) {
|
|
463572
|
+
(_e2 = vectorLayer.getSource()) == null ? void 0 : _e2.addFeatures(feats);
|
|
463573
|
+
}
|
|
463574
|
+
}
|
|
463575
|
+
console.log("查询并绘制完成,count:", feats.length);
|
|
463576
|
+
resolve(feats);
|
|
463577
|
+
}
|
|
463578
|
+
);
|
|
463579
|
+
});
|
|
463580
|
+
} catch (err2) {
|
|
463581
|
+
console.error("queryBuffer 捕获异常:", err2);
|
|
463582
|
+
throw new Error("查询异常,详见控制台");
|
|
463583
|
+
}
|
|
463584
|
+
}
|
|
463585
|
+
// ✅ 构建数据服务 URL(适配 map-hmsmap 服务)
|
|
463586
|
+
buildDataServerUrl(baseUrl) {
|
|
463587
|
+
const mapServiceMatch = baseUrl.match(/services\/map-(.+?)\/rest/);
|
|
463588
|
+
if (!mapServiceMatch) {
|
|
463589
|
+
throw new Error("无法从地图服务 URL 推导数据服务地址");
|
|
463590
|
+
}
|
|
463591
|
+
const workspaceName = mapServiceMatch[1];
|
|
463592
|
+
return `${baseUrl.split("/services")[0]}/services/data-${workspaceName}/rest`;
|
|
463593
|
+
}
|
|
463594
|
+
// ✅ 获取默认数据集(示例)
|
|
463595
|
+
getDefaultDatasets() {
|
|
463596
|
+
return ["football_field@hmsmap"];
|
|
463597
|
+
}
|
|
463598
|
+
/**
|
|
463599
|
+
* 通过边界范围查询要素
|
|
463600
|
+
* @param bounds 边界范围 [minX, minY, maxX, maxY]
|
|
463601
|
+
* @param options 查询选项
|
|
463602
|
+
* @returns Promise<any[]> 查询结果
|
|
463603
|
+
*/
|
|
463604
|
+
async getFeaturesByBounds(bounds2, options = {}) {
|
|
463605
|
+
var _a3;
|
|
463606
|
+
const config = this.config;
|
|
463607
|
+
if (!config.url) {
|
|
463608
|
+
console.warn("SuperMap图层缺少服务URL,无法进行要素查询");
|
|
463609
|
+
return [];
|
|
463610
|
+
}
|
|
463611
|
+
const {
|
|
463612
|
+
maxFeatures = 100,
|
|
463613
|
+
datasetNames,
|
|
463614
|
+
returnContent = true,
|
|
463615
|
+
targetProjection
|
|
463616
|
+
} = options;
|
|
463617
|
+
try {
|
|
463618
|
+
const mapProjection = (_a3 = this.map) == null ? void 0 : _a3.getView().getProjection();
|
|
463619
|
+
const projectionCode = targetProjection || (mapProjection == null ? void 0 : mapProjection.getCode()) || "EPSG:4326";
|
|
463620
|
+
let transformedBounds = bounds2;
|
|
463621
|
+
if (mapProjection && targetProjection && mapProjection.getCode() !== targetProjection) {
|
|
463622
|
+
const bottomLeft = transform$l(
|
|
463623
|
+
[bounds2[0], bounds2[1]],
|
|
463624
|
+
mapProjection.getCode(),
|
|
463625
|
+
targetProjection
|
|
463626
|
+
);
|
|
463627
|
+
const topRight = transform$l(
|
|
463628
|
+
[bounds2[2], bounds2[3]],
|
|
463629
|
+
mapProjection.getCode(),
|
|
463630
|
+
targetProjection
|
|
463631
|
+
);
|
|
463632
|
+
transformedBounds = [
|
|
463633
|
+
bottomLeft[0],
|
|
463634
|
+
bottomLeft[1],
|
|
463635
|
+
topRight[0],
|
|
463636
|
+
topRight[1]
|
|
463637
|
+
];
|
|
463638
|
+
}
|
|
463639
|
+
const serviceUrl = this.buildDataServiceUrl(config.url);
|
|
463640
|
+
console.log(`开始SuperMap边界查询:`, {
|
|
463641
|
+
bounds: transformedBounds,
|
|
463642
|
+
serviceUrl,
|
|
463643
|
+
projection: projectionCode
|
|
463644
|
+
});
|
|
463645
|
+
const boundsParams = new GetFeaturesByBoundsParameters({
|
|
463646
|
+
datasetNames: datasetNames || this.extractDatasetNames(config.url),
|
|
463647
|
+
bounds: transformedBounds,
|
|
463648
|
+
maxFeatures,
|
|
463649
|
+
returnContent
|
|
463650
|
+
});
|
|
463651
|
+
const boundsService = new GetFeaturesByBoundsService(serviceUrl);
|
|
463652
|
+
return new Promise((resolve, reject2) => {
|
|
463653
|
+
boundsService.getFeaturesByBounds(
|
|
463654
|
+
boundsParams,
|
|
463655
|
+
(serviceResult) => {
|
|
463656
|
+
var _a4;
|
|
463657
|
+
if (serviceResult.type === "processCompleted") {
|
|
463658
|
+
const result = serviceResult.result;
|
|
463659
|
+
if (result && result.features) {
|
|
463660
|
+
console.log(
|
|
463661
|
+
`SuperMap边界查询成功,找到 ${result.features.length} 个要素`
|
|
463662
|
+
);
|
|
463663
|
+
resolve(result.features);
|
|
463664
|
+
} else {
|
|
463665
|
+
console.log("SuperMap边界查询完成,但未找到要素");
|
|
463666
|
+
resolve([]);
|
|
463667
|
+
}
|
|
463668
|
+
} else {
|
|
463669
|
+
console.error("SuperMap边界查询失败:", serviceResult.error);
|
|
463670
|
+
reject2(
|
|
463671
|
+
new Error(((_a4 = serviceResult.error) == null ? void 0 : _a4.errorMsg) || "边界查询失败")
|
|
463672
|
+
);
|
|
463673
|
+
}
|
|
463674
|
+
}
|
|
463675
|
+
);
|
|
463676
|
+
});
|
|
463677
|
+
} catch (error2) {
|
|
463678
|
+
console.error("SuperMap边界查询异常:", error2);
|
|
463679
|
+
return [];
|
|
463680
|
+
}
|
|
463681
|
+
}
|
|
463682
|
+
/**
|
|
463683
|
+
* 通过几何对象查询要素
|
|
463684
|
+
* @param geometry OpenLayers几何对象
|
|
463685
|
+
* @param options 查询选项
|
|
463686
|
+
* @returns Promise<any[]> 查询结果
|
|
463687
|
+
*/
|
|
463688
|
+
async getFeaturesByGeometry(geometry2, options = {}) {
|
|
463689
|
+
const config = this.config;
|
|
463690
|
+
if (!config.url) {
|
|
463691
|
+
console.warn("SuperMap图层缺少服务URL,无法进行要素查询");
|
|
463692
|
+
return [];
|
|
463693
|
+
}
|
|
463694
|
+
const {
|
|
463695
|
+
maxFeatures = 100,
|
|
463696
|
+
datasetNames,
|
|
463697
|
+
returnContent = true,
|
|
463698
|
+
spatialQueryMode = "INTERSECT",
|
|
463699
|
+
targetProjection
|
|
463700
|
+
} = options;
|
|
463701
|
+
try {
|
|
463702
|
+
const serviceUrl = this.buildDataServiceUrl(config.url);
|
|
463703
|
+
console.log(`开始SuperMap几何查询:`, {
|
|
463704
|
+
geometryType: geometry2.getType(),
|
|
463705
|
+
spatialQueryMode,
|
|
463706
|
+
serviceUrl
|
|
463707
|
+
});
|
|
463708
|
+
const geometryParams = new GetFeaturesByGeometryParameters({
|
|
463709
|
+
datasetNames: datasetNames || this.extractDatasetNames(config.url),
|
|
463710
|
+
geometry: geometry2,
|
|
463711
|
+
maxFeatures,
|
|
463712
|
+
returnContent,
|
|
463713
|
+
spatialQueryMode
|
|
463714
|
+
});
|
|
463715
|
+
const geometryService = new GetFeaturesByGeometryService(serviceUrl);
|
|
463716
|
+
return new Promise((resolve, reject2) => {
|
|
463717
|
+
geometryService.getFeaturesByGeometry(
|
|
463718
|
+
geometryParams,
|
|
463719
|
+
(serviceResult) => {
|
|
463720
|
+
var _a3;
|
|
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(((_a3 = serviceResult.error) == null ? void 0 : _a3.errorMsg) || "几何查询失败")
|
|
463736
|
+
);
|
|
463737
|
+
}
|
|
463738
|
+
}
|
|
463739
|
+
);
|
|
463740
|
+
});
|
|
463741
|
+
} catch (error2) {
|
|
463742
|
+
console.error("SuperMap几何查询异常:", error2);
|
|
463743
|
+
return [];
|
|
463744
|
+
}
|
|
463745
|
+
}
|
|
463746
|
+
/**
|
|
463747
|
+
* 通过SQL条件查询要素
|
|
463748
|
+
* @param sqlCondition SQL查询条件
|
|
463749
|
+
* @param options 查询选项
|
|
463750
|
+
* @returns Promise<any[]> 查询结果
|
|
463751
|
+
*/
|
|
463752
|
+
async getFeaturesBySQL(sqlCondition, 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
|
+
targetProjection
|
|
463763
|
+
} = options;
|
|
463764
|
+
try {
|
|
463765
|
+
const serviceUrl = this.buildDataServiceUrl(config.url);
|
|
463766
|
+
console.log(`开始SuperMap SQL查询:`, {
|
|
463767
|
+
sqlCondition,
|
|
463768
|
+
serviceUrl
|
|
463769
|
+
});
|
|
463770
|
+
const sqlParams = new GetFeaturesBySQLParameters({
|
|
463771
|
+
datasetNames: datasetNames || this.extractDatasetNames(config.url),
|
|
463772
|
+
queryParameter: {
|
|
463773
|
+
name: "sqlQuery",
|
|
463774
|
+
attributeFilter: sqlCondition
|
|
463775
|
+
},
|
|
463776
|
+
maxFeatures,
|
|
463777
|
+
returnContent
|
|
463778
|
+
});
|
|
463779
|
+
const sqlService = new GetFeaturesBySQLService(serviceUrl);
|
|
463780
|
+
return new Promise((resolve, reject2) => {
|
|
463781
|
+
sqlService.getFeaturesBySQL(sqlParams, (serviceResult) => {
|
|
463782
|
+
var _a3;
|
|
463783
|
+
if (serviceResult.type === "processCompleted") {
|
|
463784
|
+
const result = serviceResult.result;
|
|
463785
|
+
if (result && result.features) {
|
|
463786
|
+
console.log(
|
|
463787
|
+
`SuperMap SQL查询成功,找到 ${result.features.length} 个要素`
|
|
463788
|
+
);
|
|
463789
|
+
resolve(result.features);
|
|
463790
|
+
} else {
|
|
463791
|
+
console.log("SuperMap SQL查询完成,但未找到要素");
|
|
463792
|
+
resolve([]);
|
|
463793
|
+
}
|
|
463794
|
+
} else {
|
|
463795
|
+
console.error("SuperMap SQL查询失败:", serviceResult.error);
|
|
463796
|
+
reject2(new Error(((_a3 = serviceResult.error) == null ? void 0 : _a3.errorMsg) || "SQL查询失败"));
|
|
463797
|
+
}
|
|
463798
|
+
});
|
|
463799
|
+
});
|
|
463800
|
+
} catch (error2) {
|
|
463801
|
+
console.error("SuperMap SQL查询异常:", error2);
|
|
463802
|
+
return [];
|
|
463803
|
+
}
|
|
463804
|
+
}
|
|
463805
|
+
/**
|
|
463806
|
+
* 通过要素ID查询要素
|
|
463807
|
+
* @param featureIds 要素ID数组
|
|
463808
|
+
* @param options 查询选项
|
|
463809
|
+
* @returns Promise<any[]> 查询结果
|
|
463810
|
+
*/
|
|
463811
|
+
async getFeaturesByIDs(featureIds, options = {}) {
|
|
463812
|
+
const config = this.config;
|
|
463813
|
+
if (!config.url) {
|
|
463814
|
+
console.warn("SuperMap图层缺少服务URL,无法进行要素查询");
|
|
463815
|
+
return [];
|
|
463816
|
+
}
|
|
463817
|
+
const { datasetNames, returnContent = true, targetProjection } = options;
|
|
463818
|
+
try {
|
|
463819
|
+
const serviceUrl = this.buildDataServiceUrl(config.url);
|
|
463820
|
+
console.log(`开始SuperMap ID查询:`, {
|
|
463821
|
+
featureIds,
|
|
463822
|
+
serviceUrl
|
|
463823
|
+
});
|
|
463824
|
+
const idsParams = new GetFeaturesByIDsParameters({
|
|
463825
|
+
datasetNames: datasetNames || this.extractDatasetNames(config.url),
|
|
463826
|
+
IDs: featureIds,
|
|
463827
|
+
returnContent
|
|
463828
|
+
});
|
|
463829
|
+
const idsService = new GetFeaturesByIDsService(serviceUrl);
|
|
463830
|
+
return new Promise((resolve, reject2) => {
|
|
463831
|
+
idsService.getFeaturesByIDs(idsParams, (serviceResult) => {
|
|
463832
|
+
var _a3;
|
|
463833
|
+
if (serviceResult.type === "processCompleted") {
|
|
463834
|
+
const result = serviceResult.result;
|
|
463835
|
+
if (result && result.features) {
|
|
463836
|
+
console.log(
|
|
463837
|
+
`SuperMap ID查询成功,找到 ${result.features.length} 个要素`
|
|
463838
|
+
);
|
|
463839
|
+
resolve(result.features);
|
|
463840
|
+
} else {
|
|
463841
|
+
console.log("SuperMap ID查询完成,但未找到要素");
|
|
463842
|
+
resolve([]);
|
|
463843
|
+
}
|
|
463844
|
+
} else {
|
|
463845
|
+
console.error("SuperMap ID查询失败:", serviceResult.error);
|
|
463846
|
+
reject2(new Error(((_a3 = serviceResult.error) == null ? void 0 : _a3.errorMsg) || "ID查询失败"));
|
|
463847
|
+
}
|
|
463848
|
+
});
|
|
463849
|
+
});
|
|
463850
|
+
} catch (error2) {
|
|
463851
|
+
console.error("SuperMap ID查询异常:", error2);
|
|
463852
|
+
return [];
|
|
463853
|
+
}
|
|
463854
|
+
}
|
|
463855
|
+
/**
|
|
463856
|
+
* 构建数据服务URL
|
|
463857
|
+
* @param mapUrl 地图服务URL
|
|
463858
|
+
* @returns 数据服务URL
|
|
463859
|
+
*/
|
|
463860
|
+
buildDataServiceUrl(mapUrl) {
|
|
463861
|
+
try {
|
|
463862
|
+
const url = new URL(mapUrl);
|
|
463863
|
+
if (url.pathname.includes("/rest/data")) {
|
|
463864
|
+
console.log(`已经是数据服务URL: ${mapUrl}`);
|
|
463865
|
+
return mapUrl;
|
|
463866
|
+
}
|
|
463867
|
+
if (url.pathname.includes("/rest/maps/")) {
|
|
463868
|
+
const dataServiceUrl = mapUrl.replace(
|
|
463869
|
+
/\/rest\/maps\/.*$/,
|
|
463870
|
+
"/rest/data"
|
|
463871
|
+
);
|
|
463872
|
+
console.log(`构建数据服务URL: ${mapUrl} -> ${dataServiceUrl}`);
|
|
463873
|
+
return dataServiceUrl;
|
|
463874
|
+
}
|
|
463875
|
+
const pathParts = url.pathname.split("/").filter((part) => part);
|
|
463876
|
+
const servicesIndex = pathParts.findIndex((part) => part === "services");
|
|
463877
|
+
if (servicesIndex !== -1 && servicesIndex + 1 < pathParts.length) {
|
|
463878
|
+
const serviceName = pathParts[servicesIndex + 1];
|
|
463879
|
+
const basePath = pathParts.slice(0, servicesIndex + 2).join("/");
|
|
463880
|
+
const dataServiceUrl = `${url.protocol}//${url.host}/${basePath}/rest/data`;
|
|
463881
|
+
console.log(
|
|
463882
|
+
`从服务名称构建数据服务URL: ${mapUrl} -> ${dataServiceUrl}`
|
|
463883
|
+
);
|
|
463884
|
+
return dataServiceUrl;
|
|
463885
|
+
}
|
|
463886
|
+
throw new Error(`无法解析SuperMap服务URL格式: ${mapUrl}`);
|
|
463887
|
+
} catch (error2) {
|
|
463888
|
+
console.error("构建数据服务URL失败:", error2);
|
|
463889
|
+
return mapUrl;
|
|
463890
|
+
}
|
|
463891
|
+
}
|
|
463892
|
+
/**
|
|
463893
|
+
* 从地图服务URL中提取数据集名称
|
|
463894
|
+
* @param mapUrl 地图服务URL
|
|
463895
|
+
* @returns 数据集名称数组
|
|
463896
|
+
*/
|
|
463897
|
+
extractDatasetNames(mapUrl) {
|
|
463898
|
+
try {
|
|
463899
|
+
const url = new URL(mapUrl);
|
|
463900
|
+
const pathParts = url.pathname.split("/").filter((part) => part);
|
|
463901
|
+
const mapsIndex = pathParts.findIndex((part) => part === "maps");
|
|
463902
|
+
if (mapsIndex !== -1 && mapsIndex + 1 < pathParts.length) {
|
|
463903
|
+
const mapName = pathParts[mapsIndex + 1];
|
|
463904
|
+
console.log(`从URL提取到地图名称: ${mapName}`);
|
|
463905
|
+
return [mapName];
|
|
463906
|
+
}
|
|
463907
|
+
const config = this.config;
|
|
463908
|
+
if (config.datasetNames && Array.isArray(config.datasetNames)) {
|
|
463909
|
+
console.log(`使用配置中的数据集名称: ${config.datasetNames}`);
|
|
463910
|
+
return config.datasetNames;
|
|
463911
|
+
}
|
|
463912
|
+
console.warn("无法确定数据集名称,将查询所有可用数据集");
|
|
463913
|
+
return [];
|
|
463914
|
+
} catch (error2) {
|
|
463915
|
+
console.error("提取数据集名称失败:", error2);
|
|
463916
|
+
return [];
|
|
463917
|
+
}
|
|
463918
|
+
}
|
|
463919
|
+
/**
|
|
463920
|
+
* 为popup等功能提供的便捷方法:通过点击坐标获取要素信息
|
|
463921
|
+
* @param coordinate 点击坐标
|
|
463922
|
+
* @param options 查询选项
|
|
463923
|
+
* @returns Promise<any[]> 要素信息数组
|
|
463924
|
+
*/
|
|
463925
|
+
async getFeatureInfoAtCoordinate(coordinate, options = {}) {
|
|
463926
|
+
var _a3, _b3, _c2, _d, _e2, _f;
|
|
463927
|
+
const {
|
|
463928
|
+
bufferDistance = 100,
|
|
463929
|
+
maxFeatures = options.featureCount || 10,
|
|
463930
|
+
queryMethod
|
|
463931
|
+
} = options;
|
|
463932
|
+
try {
|
|
463933
|
+
let features2 = [];
|
|
463934
|
+
const finalQueryMethod = queryMethod || ((_a3 = this.config.supermapConfig) == null ? void 0 : _a3.queryMethod) || "point";
|
|
463935
|
+
console.log(`使用查询方式: ${finalQueryMethod}`);
|
|
463936
|
+
if (finalQueryMethod === "buffer") {
|
|
463937
|
+
const configuredBufferDistance = ((_b3 = this.config.supermapConfig) == null ? void 0 : _b3.bufferDistance) || bufferDistance;
|
|
463938
|
+
features2 = await this.getFeaturesByBuffer(
|
|
463939
|
+
coordinate[0],
|
|
463940
|
+
coordinate[1],
|
|
463941
|
+
{
|
|
463942
|
+
bufferDistance: configuredBufferDistance / 1e3,
|
|
463943
|
+
// 转换为度数单位
|
|
463944
|
+
datasetNames: (_c2 = this.config.supermapConfig) == null ? void 0 : _c2.datasetNames,
|
|
463945
|
+
serviceUrl: (_d = this.config.supermapConfig) == null ? void 0 : _d.featureServiceUrl
|
|
463946
|
+
}
|
|
463947
|
+
);
|
|
463948
|
+
} else {
|
|
463949
|
+
features2 = await this.queryFeatureByPointOL(
|
|
463950
|
+
coordinate[0],
|
|
463951
|
+
coordinate[1],
|
|
463952
|
+
{
|
|
463953
|
+
datasetNames: (_e2 = this.config.supermapConfig) == null ? void 0 : _e2.datasetNames,
|
|
463954
|
+
serviceUrl: (_f = this.config.supermapConfig) == null ? void 0 : _f.featureServiceUrl
|
|
463955
|
+
// tolerance 参数已移除,使用默认值
|
|
463956
|
+
}
|
|
463957
|
+
);
|
|
463958
|
+
}
|
|
463959
|
+
return features2.slice(0, maxFeatures).map((feature2) => {
|
|
463960
|
+
const properties = feature2.getProperties() || {};
|
|
463961
|
+
feature2.setProperties({
|
|
463962
|
+
...properties,
|
|
463963
|
+
layerId: this.config.id,
|
|
463964
|
+
layerName: this.config.name,
|
|
463965
|
+
layerType: "supermap-rest"
|
|
463966
|
+
});
|
|
463967
|
+
return feature2;
|
|
463968
|
+
});
|
|
463969
|
+
} catch (error2) {
|
|
463970
|
+
console.error("获取要素信息失败:", error2);
|
|
463971
|
+
return [];
|
|
463972
|
+
}
|
|
463973
|
+
}
|
|
463053
463974
|
}
|
|
463054
463975
|
class CanvasLayerHandler extends BaseLayer$2 {
|
|
463055
463976
|
constructor() {
|
|
@@ -463202,7 +464123,7 @@ class CanvasLayerHandler extends BaseLayer$2 {
|
|
|
463202
464123
|
* 更新图层配置
|
|
463203
464124
|
*/
|
|
463204
464125
|
updateLayerConfig(config) {
|
|
463205
|
-
super.
|
|
464126
|
+
super.updateConfig(config);
|
|
463206
464127
|
if (config.canvasConfig) {
|
|
463207
464128
|
this.updateCanvasConfig(config.canvasConfig);
|
|
463208
464129
|
}
|
|
@@ -463921,176 +464842,6 @@ class LayerManager {
|
|
|
463921
464842
|
getLayerHandler(layerId) {
|
|
463922
464843
|
return this.layerHandlers.get(layerId);
|
|
463923
464844
|
}
|
|
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
464845
|
/**
|
|
464095
464846
|
* 设置图层可见性(支持按需加载)
|
|
464096
464847
|
*/
|
|
@@ -464390,6 +465141,98 @@ class LayerManager {
|
|
|
464390
465141
|
return false;
|
|
464391
465142
|
}
|
|
464392
465143
|
}
|
|
465144
|
+
/**
|
|
465145
|
+
* 根据坐标获取图层要素信息(用于tooltip)
|
|
465146
|
+
*/
|
|
465147
|
+
async getFeatureInfoAtCoordinate(coordinate, options) {
|
|
465148
|
+
try {
|
|
465149
|
+
const results = [];
|
|
465150
|
+
const targetLayers = (options == null ? void 0 : options.layers) || Array.from(this.layerHandlers.keys());
|
|
465151
|
+
for (const layerId of targetLayers) {
|
|
465152
|
+
const handler = this.layerHandlers.get(layerId);
|
|
465153
|
+
const config = this.layerConfigs.get(layerId);
|
|
465154
|
+
if (!handler || !config || !config.visible) {
|
|
465155
|
+
continue;
|
|
465156
|
+
}
|
|
465157
|
+
try {
|
|
465158
|
+
if (config.type === "TileSuperMapRest" || config.type === "tilesupermaprest" || config.type === "TILESUPERMAPREST") {
|
|
465159
|
+
if ("getFeatureInfoAtCoordinate" in handler) {
|
|
465160
|
+
const features2 = await handler.getFeatureInfoAtCoordinate(
|
|
465161
|
+
coordinate,
|
|
465162
|
+
{
|
|
465163
|
+
bufferDistance: 80,
|
|
465164
|
+
// 默认5米缓冲区
|
|
465165
|
+
maxFeatures: (options == null ? void 0 : options.featureCount) || 10,
|
|
465166
|
+
returnContent: true
|
|
465167
|
+
}
|
|
465168
|
+
);
|
|
465169
|
+
if (features2 && features2.length > 0) {
|
|
465170
|
+
results.push({
|
|
465171
|
+
layerId,
|
|
465172
|
+
layerName: config.name,
|
|
465173
|
+
layerType: config.type,
|
|
465174
|
+
features: features2
|
|
465175
|
+
});
|
|
465176
|
+
}
|
|
465177
|
+
}
|
|
465178
|
+
} else if (config.type === "wms" || config.type === "WMS") {
|
|
465179
|
+
if ("getFeatureInfoAtCoordinate" in handler) {
|
|
465180
|
+
const features2 = await handler.getFeatureInfoAtCoordinate(
|
|
465181
|
+
coordinate,
|
|
465182
|
+
{
|
|
465183
|
+
infoFormat: (options == null ? void 0 : options.infoFormat) || "application/json",
|
|
465184
|
+
featureCount: (options == null ? void 0 : options.featureCount) || 10
|
|
465185
|
+
}
|
|
465186
|
+
);
|
|
465187
|
+
if (features2 && features2.length > 0) {
|
|
465188
|
+
results.push({
|
|
465189
|
+
layerId,
|
|
465190
|
+
layerName: config.name,
|
|
465191
|
+
layerType: config.type,
|
|
465192
|
+
features: features2
|
|
465193
|
+
});
|
|
465194
|
+
}
|
|
465195
|
+
}
|
|
465196
|
+
} else if (config.type === "vector" || config.type === "geojson") {
|
|
465197
|
+
const layer2 = handler.getLayer();
|
|
465198
|
+
if (layer2 && "getSource" in layer2) {
|
|
465199
|
+
const source = layer2.getSource();
|
|
465200
|
+
if (source && "getFeaturesAtCoordinate" in source) {
|
|
465201
|
+
const features2 = source.getFeaturesAtCoordinate(coordinate);
|
|
465202
|
+
if (features2 && features2.length > 0) {
|
|
465203
|
+
const processedFeatures = features2.slice(0, (options == null ? void 0 : options.featureCount) || 10).map((feature2) => {
|
|
465204
|
+
const properties = feature2.getProperties ? feature2.getProperties() : {};
|
|
465205
|
+
const enhancedProperties = {
|
|
465206
|
+
...properties,
|
|
465207
|
+
layerId,
|
|
465208
|
+
layerName: config.name,
|
|
465209
|
+
layerType: config.type
|
|
465210
|
+
};
|
|
465211
|
+
if (feature2.setProperties) {
|
|
465212
|
+
feature2.setProperties(enhancedProperties);
|
|
465213
|
+
}
|
|
465214
|
+
return feature2;
|
|
465215
|
+
});
|
|
465216
|
+
results.push({
|
|
465217
|
+
layerId,
|
|
465218
|
+
layerName: config.name,
|
|
465219
|
+
layerType: config.type,
|
|
465220
|
+
features: processedFeatures
|
|
465221
|
+
});
|
|
465222
|
+
}
|
|
465223
|
+
}
|
|
465224
|
+
}
|
|
465225
|
+
}
|
|
465226
|
+
} catch (error2) {
|
|
465227
|
+
console.warn(`图层 ${layerId} 要素查询失败:`, error2);
|
|
465228
|
+
}
|
|
465229
|
+
}
|
|
465230
|
+
return results;
|
|
465231
|
+
} catch (error2) {
|
|
465232
|
+
console.error("获取要素信息失败:", error2);
|
|
465233
|
+
return [];
|
|
465234
|
+
}
|
|
465235
|
+
}
|
|
464393
465236
|
/**
|
|
464394
465237
|
* 销毁图层管理器
|
|
464395
465238
|
*/
|
|
@@ -464904,21 +465747,24 @@ class MapManager {
|
|
|
464904
465747
|
}
|
|
464905
465748
|
if (this.layerManager) {
|
|
464906
465749
|
try {
|
|
464907
|
-
const
|
|
464908
|
-
|
|
464909
|
-
|
|
464910
|
-
|
|
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;
|
|
465750
|
+
const featureInfoResults = await this.layerManager.getFeatureInfoAtCoordinate(
|
|
465751
|
+
lonLatCoordinate,
|
|
465752
|
+
{
|
|
465753
|
+
featureCount: 10
|
|
464918
465754
|
}
|
|
465755
|
+
);
|
|
465756
|
+
if (featureInfoResults && featureInfoResults.length > 0) {
|
|
465757
|
+
const tooltipData = featureInfoResults.map((result) => ({
|
|
465758
|
+
layerId: result.layerId,
|
|
465759
|
+
layerName: result.layerName,
|
|
465760
|
+
features: result.features,
|
|
465761
|
+
coordinate: lonLatCoordinate
|
|
465762
|
+
}));
|
|
465763
|
+
this.emit("feature-info", tooltipData);
|
|
465764
|
+
return;
|
|
464919
465765
|
}
|
|
464920
465766
|
} catch (error2) {
|
|
464921
|
-
console.warn("
|
|
465767
|
+
console.warn("查询图层要素信息失败:", error2);
|
|
464922
465768
|
}
|
|
464923
465769
|
}
|
|
464924
465770
|
this.emit("map-click", {
|
|
@@ -465169,7 +466015,7 @@ class MapManager {
|
|
|
465169
466015
|
if (!this.map)
|
|
465170
466016
|
return;
|
|
465171
466017
|
this.map.on("singleclick", async (evt) => {
|
|
465172
|
-
var _a3, _b3, _c2
|
|
466018
|
+
var _a3, _b3, _c2;
|
|
465173
466019
|
const coordinate = evt.coordinate;
|
|
465174
466020
|
const pixel = evt.pixel;
|
|
465175
466021
|
const view = this.map.getView();
|
|
@@ -465201,24 +466047,7 @@ class MapManager {
|
|
|
465201
466047
|
}
|
|
465202
466048
|
(_b3 = callbacks.onFeatureClick) == null ? void 0 : _b3.call(callbacks, feature2, layer2, lonLatCoordinate, mapCoordinate);
|
|
465203
466049
|
} else {
|
|
465204
|
-
|
|
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, {
|
|
466050
|
+
(_c2 = callbacks.onMapClick) == null ? void 0 : _c2.call(callbacks, {
|
|
465222
466051
|
coordinate: lonLatCoordinate,
|
|
465223
466052
|
mapCoordinate,
|
|
465224
466053
|
pixel,
|
|
@@ -465348,7 +466177,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
465348
466177
|
loading: { type: Boolean, default: false },
|
|
465349
466178
|
userMarkers: {}
|
|
465350
466179
|
},
|
|
465351
|
-
emits: ["map-ready", "map-click", "map-dblclick", "map-contextmenu", "map-move", "zoom-change"],
|
|
466180
|
+
emits: ["map-ready", "map-click", "map-dblclick", "map-contextmenu", "map-move", "zoom-change", "feature-info"],
|
|
465352
466181
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
465353
466182
|
const props = __props;
|
|
465354
466183
|
const emit = __emit;
|
|
@@ -465435,6 +466264,9 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
465435
466264
|
emit("map-contextmenu", { coordinate, pixel });
|
|
465436
466265
|
}
|
|
465437
466266
|
});
|
|
466267
|
+
mapManager.value.on("feature-info", (data) => {
|
|
466268
|
+
emit("feature-info", data);
|
|
466269
|
+
});
|
|
465438
466270
|
};
|
|
465439
466271
|
const updateMapConfig = (config) => {
|
|
465440
466272
|
if (!map2.value)
|
|
@@ -465506,7 +466338,7 @@ const _export_sfc = (sfc, props) => {
|
|
|
465506
466338
|
}
|
|
465507
466339
|
return target;
|
|
465508
466340
|
};
|
|
465509
|
-
const MapContainer = /* @__PURE__ */ _export_sfc(_sfc_main$q, [["__scopeId", "data-v-
|
|
466341
|
+
const MapContainer = /* @__PURE__ */ _export_sfc(_sfc_main$q, [["__scopeId", "data-v-9900e920"]]);
|
|
465510
466342
|
const _hoisted_1$n = ["href"];
|
|
465511
466343
|
const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
465512
466344
|
__name: "index",
|
|
@@ -475444,6 +476276,10 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
475444
476276
|
};
|
|
475445
476277
|
const initializeLayerManager = () => {
|
|
475446
476278
|
if (layerManager.value) {
|
|
476279
|
+
if (map2.value && layerManager.value) {
|
|
476280
|
+
layerTreeManager.initialize(map2.value, layerManager.value);
|
|
476281
|
+
layerConfigManager.initialize(layerManager.value);
|
|
476282
|
+
}
|
|
475447
476283
|
nextTick(() => {
|
|
475448
476284
|
if (layerManager.value) {
|
|
475449
476285
|
layerManager.value.setLayersZIndexByOrder(1, 1);
|
|
@@ -475764,10 +476600,6 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
475764
476600
|
});
|
|
475765
476601
|
};
|
|
475766
476602
|
onMounted(() => {
|
|
475767
|
-
if (map2.value && layerManager.value) {
|
|
475768
|
-
layerTreeManager.initialize(map2.value, layerManager.value);
|
|
475769
|
-
layerConfigManager.initialize(layerManager.value);
|
|
475770
|
-
}
|
|
475771
476603
|
layerEventBus.on("basemap-changed", handleBasemapChanged);
|
|
475772
476604
|
layerEventBus.on("basemap-switch-request", handleBasemapSwitchRequest);
|
|
475773
476605
|
});
|
|
@@ -475908,7 +476740,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
475908
476740
|
};
|
|
475909
476741
|
}
|
|
475910
476742
|
});
|
|
475911
|
-
const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-
|
|
476743
|
+
const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-6929b38c"]]);
|
|
475912
476744
|
const _hoisted_1$4 = {
|
|
475913
476745
|
key: 2,
|
|
475914
476746
|
class: "tooltip-content"
|
|
@@ -476181,6 +477013,12 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
476181
477013
|
if (props.config.maxHeight) {
|
|
476182
477014
|
style.maxHeight = typeof props.config.maxHeight === "number" ? `${props.config.maxHeight}px` : props.config.maxHeight;
|
|
476183
477015
|
}
|
|
477016
|
+
if (props.config.vertical) {
|
|
477017
|
+
style.display = "flex";
|
|
477018
|
+
style.flexDirection = "column";
|
|
477019
|
+
style.minWidth = "200px";
|
|
477020
|
+
style.maxWidth = style.maxWidth || "300px";
|
|
477021
|
+
}
|
|
476184
477022
|
return style;
|
|
476185
477023
|
});
|
|
476186
477024
|
const handleClose = () => {
|
|
@@ -476236,21 +477074,28 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
476236
477074
|
class: normalizeClass([
|
|
476237
477075
|
"ol-popup",
|
|
476238
477076
|
`ol-popup-${position2.value}`,
|
|
477077
|
+
{ "ol-popup-vertical": _ctx.config.vertical },
|
|
476239
477078
|
_ctx.config.className
|
|
476240
477079
|
]),
|
|
476241
|
-
style: normalizeStyle$1(popupStyle.value)
|
|
477080
|
+
style: normalizeStyle$1(popupStyle.value),
|
|
477081
|
+
onClick: _cache[0] || (_cache[0] = withModifiers(() => {
|
|
477082
|
+
}, ["stop"])),
|
|
477083
|
+
onMousedown: _cache[1] || (_cache[1] = withModifiers(() => {
|
|
477084
|
+
}, ["stop"])),
|
|
477085
|
+
onMouseup: _cache[2] || (_cache[2] = withModifiers(() => {
|
|
477086
|
+
}, ["stop"]))
|
|
476242
477087
|
}, [
|
|
476243
|
-
_cache[
|
|
477088
|
+
_cache[5] || (_cache[5] = createElementVNode("div", { class: "ol-popup-tip" }, null, -1)),
|
|
476244
477089
|
_ctx.config.showCloseButton !== false ? (openBlock(), createBlock(unref(ElButton), {
|
|
476245
477090
|
key: 0,
|
|
476246
477091
|
class: "ol-popup-closer",
|
|
476247
|
-
onClick: handleClose,
|
|
477092
|
+
onClick: withModifiers(handleClose, ["stop"]),
|
|
476248
477093
|
title: "关闭",
|
|
476249
477094
|
text: "",
|
|
476250
477095
|
circle: "",
|
|
476251
477096
|
size: "small"
|
|
476252
477097
|
}, {
|
|
476253
|
-
default: withCtx(() => [..._cache[
|
|
477098
|
+
default: withCtx(() => [..._cache[3] || (_cache[3] = [
|
|
476254
477099
|
createTextVNode(" × ", -1)
|
|
476255
477100
|
])]),
|
|
476256
477101
|
_: 1
|
|
@@ -476265,16 +477110,16 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
476265
477110
|
coordinate: _ctx.coordinate,
|
|
476266
477111
|
config: _ctx.config
|
|
476267
477112
|
}, () => [
|
|
476268
|
-
_cache[
|
|
477113
|
+
_cache[4] || (_cache[4] = createElementVNode("div", { class: "ol-popup-default" }, [
|
|
476269
477114
|
createElementVNode("p", null, "请提供 popup 内容")
|
|
476270
477115
|
], -1))
|
|
476271
477116
|
], true)
|
|
476272
477117
|
], 512)
|
|
476273
|
-
],
|
|
477118
|
+
], 38)) : createCommentVNode("", true);
|
|
476274
477119
|
};
|
|
476275
477120
|
}
|
|
476276
477121
|
});
|
|
476277
|
-
const BasePopup = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-
|
|
477122
|
+
const BasePopup = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-9a5b6333"]]);
|
|
476278
477123
|
const _hoisted_1$3 = { class: "html-popup-content" };
|
|
476279
477124
|
const _hoisted_2$3 = {
|
|
476280
477125
|
key: 0,
|
|
@@ -477083,7 +477928,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
477083
477928
|
};
|
|
477084
477929
|
}
|
|
477085
477930
|
});
|
|
477086
|
-
const ArrayPopup = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
477931
|
+
const ArrayPopup = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-4a372183"]]);
|
|
477087
477932
|
class PopupManager {
|
|
477088
477933
|
constructor(map2, config = {}) {
|
|
477089
477934
|
__publicField(this, "map");
|
|
@@ -477095,6 +477940,11 @@ class PopupManager {
|
|
|
477095
477940
|
maxPopups: 5,
|
|
477096
477941
|
autoClose: true,
|
|
477097
477942
|
closeOnMapClick: true,
|
|
477943
|
+
defaultConfig: {
|
|
477944
|
+
vertical: true,
|
|
477945
|
+
maxHeight: 300,
|
|
477946
|
+
...config.defaultConfig
|
|
477947
|
+
},
|
|
477098
477948
|
...config
|
|
477099
477949
|
};
|
|
477100
477950
|
if (this.config.closeOnMapClick) {
|
|
@@ -477219,7 +478069,7 @@ class PopupManager {
|
|
|
477219
478069
|
switch (type) {
|
|
477220
478070
|
case "html":
|
|
477221
478071
|
app = createApp(HtmlPopup, {
|
|
477222
|
-
config,
|
|
478072
|
+
config: { ...this.config.defaultConfig, ...config },
|
|
477223
478073
|
coordinate,
|
|
477224
478074
|
feature: feature2,
|
|
477225
478075
|
visible: true,
|
|
@@ -477228,7 +478078,7 @@ class PopupManager {
|
|
|
477228
478078
|
break;
|
|
477229
478079
|
case "image":
|
|
477230
478080
|
app = createApp(ImagePopup, {
|
|
477231
|
-
config,
|
|
478081
|
+
config: { ...this.config.defaultConfig, ...config },
|
|
477232
478082
|
coordinate,
|
|
477233
478083
|
feature: feature2,
|
|
477234
478084
|
visible: true,
|
|
@@ -477237,7 +478087,7 @@ class PopupManager {
|
|
|
477237
478087
|
break;
|
|
477238
478088
|
case "array":
|
|
477239
478089
|
app = createApp(ArrayPopup, {
|
|
477240
|
-
config,
|
|
478090
|
+
config: { ...this.config.defaultConfig, ...config },
|
|
477241
478091
|
coordinate,
|
|
477242
478092
|
feature: feature2,
|
|
477243
478093
|
visible: true,
|
|
@@ -477764,9 +478614,113 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
477764
478614
|
emit("zoom-change", zoom, oldZoom);
|
|
477765
478615
|
};
|
|
477766
478616
|
const onFeatureInfo = (data) => {
|
|
477767
|
-
|
|
478617
|
+
if (data && data.length > 0) {
|
|
478618
|
+
const firstResult = data[0];
|
|
478619
|
+
const { layerId, layerName, features: features2, coordinate } = firstResult;
|
|
478620
|
+
if (features2 && features2.length > 0) {
|
|
478621
|
+
const feature2 = features2[0];
|
|
478622
|
+
const layerInfo = {
|
|
478623
|
+
layerId,
|
|
478624
|
+
layerName
|
|
478625
|
+
};
|
|
478626
|
+
emit("feature-click", feature2, layerInfo, coordinate);
|
|
478627
|
+
if (popupManager.value) {
|
|
478628
|
+
const allLayers = [...finalMapConfig.value.baseLayers || [], ...finalMapConfig.value.overlayLayers || [], ...finalMapConfig.value.vectorLayers || []];
|
|
478629
|
+
const targetLayer = allLayers.find((l2) => l2.id === layerId || l2.name === layerName);
|
|
478630
|
+
if (targetLayer && targetLayer.popup) {
|
|
478631
|
+
const popupConfig = targetLayer.popup;
|
|
478632
|
+
console.log("显示SuperMap图层popup:", { layerId, layerName, feature: feature2, coordinate });
|
|
478633
|
+
let properties = feature2.properties || feature2;
|
|
478634
|
+
let content2 = {};
|
|
478635
|
+
if (popupConfig.fields && Array.isArray(popupConfig.fields)) {
|
|
478636
|
+
popupConfig.fields.forEach((field) => {
|
|
478637
|
+
if (typeof field === "string") {
|
|
478638
|
+
content2[field] = properties[field] || "--";
|
|
478639
|
+
} else if (field.name) {
|
|
478640
|
+
const displayName = field.label || field.name;
|
|
478641
|
+
content2[displayName] = properties[field.name] || "--";
|
|
478642
|
+
}
|
|
478643
|
+
});
|
|
478644
|
+
} else {
|
|
478645
|
+
content2 = properties;
|
|
478646
|
+
}
|
|
478647
|
+
const getPopupType = (config) => {
|
|
478648
|
+
if (config.type) {
|
|
478649
|
+
return config.type;
|
|
478650
|
+
}
|
|
478651
|
+
if (config.fields && Array.isArray(config.fields)) {
|
|
478652
|
+
return "array";
|
|
478653
|
+
}
|
|
478654
|
+
if (config.htmlContent || config.content) {
|
|
478655
|
+
return "html";
|
|
478656
|
+
}
|
|
478657
|
+
if (config.images && Array.isArray(config.images)) {
|
|
478658
|
+
return "image";
|
|
478659
|
+
}
|
|
478660
|
+
return "array";
|
|
478661
|
+
};
|
|
478662
|
+
const popupType = getPopupType(popupConfig);
|
|
478663
|
+
let finalConfig = {
|
|
478664
|
+
title: popupConfig.title || layerName || "要素信息",
|
|
478665
|
+
showCloseButton: true,
|
|
478666
|
+
maxWidth: 300,
|
|
478667
|
+
maxHeight: 400,
|
|
478668
|
+
...popupConfig
|
|
478669
|
+
};
|
|
478670
|
+
switch (popupType) {
|
|
478671
|
+
case "array":
|
|
478672
|
+
finalConfig = {
|
|
478673
|
+
...finalConfig,
|
|
478674
|
+
type: "array",
|
|
478675
|
+
fields: popupConfig.fields || Object.keys(properties).map((key) => ({ name: key, label: key, type: "text" })),
|
|
478676
|
+
data: [properties],
|
|
478677
|
+
vertical: true
|
|
478678
|
+
};
|
|
478679
|
+
break;
|
|
478680
|
+
case "html":
|
|
478681
|
+
finalConfig = {
|
|
478682
|
+
...finalConfig,
|
|
478683
|
+
type: "html",
|
|
478684
|
+
content: popupConfig.htmlContent || popupConfig.content || content2
|
|
478685
|
+
};
|
|
478686
|
+
break;
|
|
478687
|
+
case "image":
|
|
478688
|
+
finalConfig = {
|
|
478689
|
+
...finalConfig,
|
|
478690
|
+
type: "image",
|
|
478691
|
+
images: popupConfig.images || []
|
|
478692
|
+
};
|
|
478693
|
+
break;
|
|
478694
|
+
default:
|
|
478695
|
+
finalConfig = {
|
|
478696
|
+
...finalConfig,
|
|
478697
|
+
htmlContent: content2
|
|
478698
|
+
};
|
|
478699
|
+
break;
|
|
478700
|
+
}
|
|
478701
|
+
showPopup(popupType, finalConfig, coordinate);
|
|
478702
|
+
}
|
|
478703
|
+
}
|
|
478704
|
+
}
|
|
478705
|
+
}
|
|
477768
478706
|
};
|
|
477769
478707
|
const onFeatureClick = (feature2, layer2, clickCoordinate, mapCoordinate) => {
|
|
478708
|
+
let popupConfig = null;
|
|
478709
|
+
const allLayers = [...finalMapConfig.value.baseLayers || [], ...finalMapConfig.value.overlayLayers || [], ...finalMapConfig.value.vectorLayers || []];
|
|
478710
|
+
console.log("点击事件调试信息:");
|
|
478711
|
+
console.log("layer对象:", layer2);
|
|
478712
|
+
console.log("所有图层配置:", allLayers.map((l2) => ({ id: l2.id, name: l2.name, hasPopup: !!l2.popup })));
|
|
478713
|
+
const targetLayer = allLayers.find((l2) => l2.id === layer2.values_.layerId || l2.name === layer2.layerName);
|
|
478714
|
+
console.log("匹配到的图层:", targetLayer);
|
|
478715
|
+
if (targetLayer && targetLayer.popup) {
|
|
478716
|
+
popupConfig = targetLayer.popup;
|
|
478717
|
+
console.log("找到popup配置:", popupConfig);
|
|
478718
|
+
}
|
|
478719
|
+
if (!popupConfig) {
|
|
478720
|
+
console.log("没有找到popup配置,跳过显示");
|
|
478721
|
+
emit("feature-click", feature2, layer2, clickCoordinate);
|
|
478722
|
+
return;
|
|
478723
|
+
}
|
|
477770
478724
|
if (feature2 && layer2 && popupManager.value && clickCoordinate) {
|
|
477771
478725
|
const coordinate = mapCoordinate || clickCoordinate;
|
|
477772
478726
|
if (coordinate) {
|
|
@@ -477778,22 +478732,20 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
477778
478732
|
} else {
|
|
477779
478733
|
properties = feature2;
|
|
477780
478734
|
}
|
|
477781
|
-
|
|
477782
|
-
const allLayers = [...finalMapConfig.value.baseLayers || [], ...finalMapConfig.value.overlayLayers || [], ...finalMapConfig.value.vectorLayers || []];
|
|
477783
|
-
const targetLayer = allLayers.find((l2) => l2.id === layer2.layerId || l2.name === layer2.layerName);
|
|
477784
|
-
if (targetLayer && targetLayer.popup) {
|
|
477785
|
-
popupConfig = targetLayer.popup;
|
|
477786
|
-
}
|
|
478735
|
+
const popupType = (popupConfig == null ? void 0 : popupConfig.type) || "array";
|
|
477787
478736
|
if (popupConfig && popupConfig.fields) {
|
|
477788
478737
|
popupManager.value.replacePopup(
|
|
477789
|
-
|
|
478738
|
+
popupType,
|
|
477790
478739
|
{
|
|
477791
|
-
type:
|
|
478740
|
+
type: popupType,
|
|
477792
478741
|
title: (targetLayer == null ? void 0 : targetLayer.name) || layer2.layerName || "要素信息",
|
|
477793
478742
|
fields: popupConfig.fields,
|
|
477794
478743
|
data: [properties],
|
|
477795
478744
|
showCloseButton: true,
|
|
477796
|
-
maxWidth:
|
|
478745
|
+
maxWidth: 300,
|
|
478746
|
+
maxHeight: 400,
|
|
478747
|
+
vertical: true,
|
|
478748
|
+
...popupConfig
|
|
477797
478749
|
},
|
|
477798
478750
|
coordinate,
|
|
477799
478751
|
feature2
|
|
@@ -477802,14 +478754,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
477802
478754
|
const fields = Object.keys(properties).filter((key) => key !== "geometry").map((key) => ({ name: key, label: key, type: "text" }));
|
|
477803
478755
|
if (fields.length > 0) {
|
|
477804
478756
|
popupManager.value.replacePopup(
|
|
477805
|
-
|
|
478757
|
+
popupType,
|
|
477806
478758
|
{
|
|
477807
|
-
type:
|
|
478759
|
+
type: popupType,
|
|
477808
478760
|
title: layer2.layerName || "要素信息",
|
|
477809
478761
|
fields,
|
|
477810
478762
|
data: [properties],
|
|
477811
478763
|
showCloseButton: true,
|
|
477812
|
-
maxWidth:
|
|
478764
|
+
maxWidth: 300,
|
|
478765
|
+
maxHeight: 400,
|
|
478766
|
+
vertical: true,
|
|
478767
|
+
...popupConfig
|
|
477813
478768
|
},
|
|
477814
478769
|
coordinate,
|
|
477815
478770
|
feature2
|
|
@@ -478563,7 +479518,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
478563
479518
|
};
|
|
478564
479519
|
}
|
|
478565
479520
|
});
|
|
478566
|
-
const CustomOpenlayer = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
479521
|
+
const CustomOpenlayer = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-78070f98"]]);
|
|
478567
479522
|
var u8 = Uint8Array;
|
|
478568
479523
|
var u16 = Uint16Array;
|
|
478569
479524
|
var i32 = Int32Array;
|
|
@@ -486835,7 +487790,7 @@ function(t3) {
|
|
|
486835
487790
|
*/
|
|
486836
487791
|
function(t3) {
|
|
486837
487792
|
function e8() {
|
|
486838
|
-
return (n.canvg ? Promise.resolve(n.canvg) : import("./index.es-
|
|
487793
|
+
return (n.canvg ? Promise.resolve(n.canvg) : import("./index.es-3480a166.mjs")).catch(function(t4) {
|
|
486839
487794
|
return Promise.reject(new Error("Could not load canvg: " + t4));
|
|
486840
487795
|
}).then(function(t4) {
|
|
486841
487796
|
return t4.default ? t4.default : t4;
|