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
package/lib/index.umd.js
CHANGED
|
@@ -41707,7 +41707,7 @@ var __publicField = (obj, key, value) => {
|
|
|
41707
41707
|
item
|
|
41708
41708
|
);
|
|
41709
41709
|
}
|
|
41710
|
-
function proj4$
|
|
41710
|
+
function proj4$3(fromProjOrToProj, toProjOrCoord, coord) {
|
|
41711
41711
|
var fromProj;
|
|
41712
41712
|
var toProj;
|
|
41713
41713
|
var single = false;
|
|
@@ -45707,7 +45707,7 @@ var __publicField = (obj, key, value) => {
|
|
|
45707
45707
|
proj42.Proj.projections.add(eqearth$1);
|
|
45708
45708
|
proj42.Proj.projections.add(bonne$1);
|
|
45709
45709
|
}
|
|
45710
|
-
const proj4$1 = Object.assign(proj4$
|
|
45710
|
+
const proj4$1 = Object.assign(proj4$3, {
|
|
45711
45711
|
defaultDatum: "WGS84",
|
|
45712
45712
|
Proj: Projection$3,
|
|
45713
45713
|
WGS84: new Projection$3("WGS84"),
|
|
@@ -45720,6 +45720,10 @@ var __publicField = (obj, key, value) => {
|
|
|
45720
45720
|
version: "__VERSION__"
|
|
45721
45721
|
});
|
|
45722
45722
|
includedProjections$1(proj4$1);
|
|
45723
|
+
const proj4$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
45724
|
+
__proto__: null,
|
|
45725
|
+
default: proj4$1
|
|
45726
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
45723
45727
|
let registered$1 = null;
|
|
45724
45728
|
function register$3(proj42) {
|
|
45725
45729
|
registered$1 = proj42;
|
|
@@ -45806,11 +45810,9 @@ var __publicField = (obj, key, value) => {
|
|
|
45806
45810
|
"map:contextmenu",
|
|
45807
45811
|
"map:pointermove",
|
|
45808
45812
|
"map:moveend",
|
|
45809
|
-
"map:zoomchange"
|
|
45810
|
-
"map:featureinfo"
|
|
45813
|
+
"map:zoomchange"
|
|
45811
45814
|
],
|
|
45812
|
-
debounceDelay: config.debounceDelay ?? 100
|
|
45813
|
-
enableFeatureInfo: config.enableFeatureInfo ?? true
|
|
45815
|
+
debounceDelay: config.debounceDelay ?? 100
|
|
45814
45816
|
};
|
|
45815
45817
|
this.mittEmitter = this.config.mittInstance || mitt();
|
|
45816
45818
|
this.lastZoom = this.map.getView().getZoom() || 0;
|
|
@@ -45832,9 +45834,6 @@ var __publicField = (obj, key, value) => {
|
|
|
45832
45834
|
pixel,
|
|
45833
45835
|
originalEvent: event.originalEvent
|
|
45834
45836
|
});
|
|
45835
|
-
if (this.config.enableFeatureInfo) {
|
|
45836
|
-
this.handleFeatureInfoQuery(coordinate, pixel);
|
|
45837
|
-
}
|
|
45838
45837
|
});
|
|
45839
45838
|
}
|
|
45840
45839
|
if (enabledEvents.includes("map:dblclick")) {
|
|
@@ -45911,23 +45910,6 @@ var __publicField = (obj, key, value) => {
|
|
|
45911
45910
|
this.map.on(eventType, handler);
|
|
45912
45911
|
this.listeners.set(key2, () => this.map.un(eventType, handler));
|
|
45913
45912
|
}
|
|
45914
|
-
/**
|
|
45915
|
-
* 处理要素信息查询
|
|
45916
|
-
*/
|
|
45917
|
-
async handleFeatureInfoQuery(coordinate, pixel) {
|
|
45918
|
-
try {
|
|
45919
|
-
const layerData = await this.layerManager.getFeatureInfoAtCoordinate(coordinate, {});
|
|
45920
|
-
if (layerData.length > 0) {
|
|
45921
|
-
this.emit("map:featureinfo", {
|
|
45922
|
-
coordinate,
|
|
45923
|
-
pixel,
|
|
45924
|
-
layerData
|
|
45925
|
-
});
|
|
45926
|
-
}
|
|
45927
|
-
} catch (error2) {
|
|
45928
|
-
console.warn("获取要素信息失败:", error2);
|
|
45929
|
-
}
|
|
45930
|
-
}
|
|
45931
45913
|
/**
|
|
45932
45914
|
* 防抖处理
|
|
45933
45915
|
*/
|
|
@@ -45982,12 +45964,6 @@ var __publicField = (obj, key, value) => {
|
|
|
45982
45964
|
getMittEmitter() {
|
|
45983
45965
|
return this.mittEmitter;
|
|
45984
45966
|
}
|
|
45985
|
-
/**
|
|
45986
|
-
* 手动触发要素信息查询
|
|
45987
|
-
*/
|
|
45988
|
-
async queryFeatureInfo(coordinate, pixel) {
|
|
45989
|
-
return await this.layerManager.getFeatureInfoAtCoordinate(coordinate, {});
|
|
45990
|
-
}
|
|
45991
45967
|
/**
|
|
45992
45968
|
* 更新配置
|
|
45993
45969
|
*/
|
|
@@ -69574,23 +69550,218 @@ ${this.attributes_.map(
|
|
|
69574
69550
|
return [{ value: "auto", label: "自动" }];
|
|
69575
69551
|
}
|
|
69576
69552
|
}
|
|
69553
|
+
const STORAGE_CONFIG = {
|
|
69554
|
+
MAX_MEASUREMENTS: 200,
|
|
69555
|
+
// 最大测量结果数量(降低到200)
|
|
69556
|
+
MAX_LAYER_CONFIGS: 50,
|
|
69557
|
+
// 最大图层配置数量(降低到50)
|
|
69558
|
+
QUOTA_WARNING_THRESHOLD: 0.6,
|
|
69559
|
+
// 配额警告阈值(60%)
|
|
69560
|
+
AUTO_CLEANUP_THRESHOLD: 0.7,
|
|
69561
|
+
// 自动清理阈值(70%)
|
|
69562
|
+
COMPRESSION_ENABLED: true,
|
|
69563
|
+
// 是否启用压缩
|
|
69564
|
+
BATCH_CLEANUP_SIZE: 20
|
|
69565
|
+
// 批量清理数量(降低到20)
|
|
69566
|
+
};
|
|
69567
|
+
class DataCompressor {
|
|
69568
|
+
static compress(data2) {
|
|
69569
|
+
try {
|
|
69570
|
+
return btoa(encodeURIComponent(data2));
|
|
69571
|
+
} catch {
|
|
69572
|
+
return data2;
|
|
69573
|
+
}
|
|
69574
|
+
}
|
|
69575
|
+
static decompress(compressedData) {
|
|
69576
|
+
try {
|
|
69577
|
+
return decodeURIComponent(atob(compressedData));
|
|
69578
|
+
} catch {
|
|
69579
|
+
return compressedData;
|
|
69580
|
+
}
|
|
69581
|
+
}
|
|
69582
|
+
}
|
|
69577
69583
|
class MapStorage {
|
|
69584
|
+
// 防止递归清理
|
|
69578
69585
|
constructor(instanceId) {
|
|
69579
69586
|
__publicField(this, "storageKeys");
|
|
69580
69587
|
__publicField(this, "instanceId");
|
|
69588
|
+
__publicField(this, "isCleaningUp", false);
|
|
69581
69589
|
this.instanceId = instanceId || "default";
|
|
69582
69590
|
this.storageKeys = {
|
|
69583
69591
|
MEASUREMENTS: `${this.instanceId}_openlayer_measurements`,
|
|
69584
69592
|
LAYER_CONFIGS: `${this.instanceId}_openlayer_layer_configs`,
|
|
69585
69593
|
MAP_STATE: `${this.instanceId}_openlayer_map_state`
|
|
69586
69594
|
};
|
|
69595
|
+
this.initCleanup();
|
|
69596
|
+
}
|
|
69597
|
+
/**
|
|
69598
|
+
* 初始化清理过量数据
|
|
69599
|
+
*/
|
|
69600
|
+
initCleanup() {
|
|
69601
|
+
try {
|
|
69602
|
+
const measurementsData = localStorage.getItem(this.storageKeys.MEASUREMENTS);
|
|
69603
|
+
if (measurementsData) {
|
|
69604
|
+
const decompressed = DataCompressor.decompress(measurementsData);
|
|
69605
|
+
const measurements = JSON.parse(decompressed);
|
|
69606
|
+
if (measurements.length > STORAGE_CONFIG.MAX_MEASUREMENTS) {
|
|
69607
|
+
const cleanedMeasurements = measurements.sort((a3, b10) => (b10.timestamp || 0) - (a3.timestamp || 0)).slice(0, STORAGE_CONFIG.MAX_MEASUREMENTS);
|
|
69608
|
+
const compressed = DataCompressor.compress(JSON.stringify(cleanedMeasurements));
|
|
69609
|
+
localStorage.setItem(this.storageKeys.MEASUREMENTS, compressed);
|
|
69610
|
+
console.log(`初始化清理测量结果:${measurements.length} -> ${cleanedMeasurements.length}`);
|
|
69611
|
+
}
|
|
69612
|
+
}
|
|
69613
|
+
const layerConfigsData = localStorage.getItem(this.storageKeys.LAYER_CONFIGS);
|
|
69614
|
+
if (layerConfigsData) {
|
|
69615
|
+
const decompressed = DataCompressor.decompress(layerConfigsData);
|
|
69616
|
+
const layerConfigs = JSON.parse(decompressed);
|
|
69617
|
+
if (layerConfigs.length > STORAGE_CONFIG.MAX_LAYER_CONFIGS) {
|
|
69618
|
+
const cleanedConfigs = layerConfigs.slice(0, STORAGE_CONFIG.MAX_LAYER_CONFIGS);
|
|
69619
|
+
const compressed = DataCompressor.compress(JSON.stringify(cleanedConfigs));
|
|
69620
|
+
localStorage.setItem(this.storageKeys.LAYER_CONFIGS, compressed);
|
|
69621
|
+
console.log(`初始化清理图层配置:${layerConfigs.length} -> ${cleanedConfigs.length}`);
|
|
69622
|
+
}
|
|
69623
|
+
}
|
|
69624
|
+
} catch (error2) {
|
|
69625
|
+
console.error("初始化清理失败:", error2);
|
|
69626
|
+
}
|
|
69627
|
+
}
|
|
69628
|
+
/**
|
|
69629
|
+
* 检查localStorage配额使用情况
|
|
69630
|
+
*/
|
|
69631
|
+
checkStorageQuota() {
|
|
69632
|
+
let used = 0;
|
|
69633
|
+
const available = 5 * 1024 * 1024;
|
|
69634
|
+
try {
|
|
69635
|
+
for (let key2 in localStorage) {
|
|
69636
|
+
if (localStorage.hasOwnProperty(key2)) {
|
|
69637
|
+
used += localStorage[key2].length + key2.length;
|
|
69638
|
+
}
|
|
69639
|
+
}
|
|
69640
|
+
} catch {
|
|
69641
|
+
used = 0;
|
|
69642
|
+
}
|
|
69643
|
+
return {
|
|
69644
|
+
used,
|
|
69645
|
+
available,
|
|
69646
|
+
percentage: available > 0 ? used / available : 0
|
|
69647
|
+
};
|
|
69648
|
+
}
|
|
69649
|
+
/**
|
|
69650
|
+
* 自动清理旧数据
|
|
69651
|
+
*/
|
|
69652
|
+
autoCleanup() {
|
|
69653
|
+
if (this.isCleaningUp) {
|
|
69654
|
+
console.warn("清理操作正在进行中,跳过重复调用");
|
|
69655
|
+
return;
|
|
69656
|
+
}
|
|
69657
|
+
this.isCleaningUp = true;
|
|
69658
|
+
try {
|
|
69659
|
+
const quota = this.checkStorageQuota();
|
|
69660
|
+
if (quota.percentage >= STORAGE_CONFIG.AUTO_CLEANUP_THRESHOLD) {
|
|
69661
|
+
console.warn("存储空间不足,开始自动清理旧数据");
|
|
69662
|
+
try {
|
|
69663
|
+
const measurementsData = localStorage.getItem(this.storageKeys.MEASUREMENTS);
|
|
69664
|
+
if (measurementsData) {
|
|
69665
|
+
const decompressed = DataCompressor.decompress(measurementsData);
|
|
69666
|
+
const measurements = JSON.parse(decompressed);
|
|
69667
|
+
if (measurements.length > STORAGE_CONFIG.BATCH_CLEANUP_SIZE) {
|
|
69668
|
+
const cleanedMeasurements = measurements.sort((a3, b10) => (b10.timestamp || 0) - (a3.timestamp || 0)).slice(0, STORAGE_CONFIG.MAX_MEASUREMENTS - STORAGE_CONFIG.BATCH_CLEANUP_SIZE);
|
|
69669
|
+
const compressed = DataCompressor.compress(JSON.stringify(cleanedMeasurements));
|
|
69670
|
+
localStorage.setItem(this.storageKeys.MEASUREMENTS, compressed);
|
|
69671
|
+
console.log(`清理测量结果:${measurements.length} -> ${cleanedMeasurements.length}`);
|
|
69672
|
+
}
|
|
69673
|
+
}
|
|
69674
|
+
} catch (error2) {
|
|
69675
|
+
console.error("清理测量结果失败:", error2);
|
|
69676
|
+
}
|
|
69677
|
+
try {
|
|
69678
|
+
const layerConfigsData = localStorage.getItem(this.storageKeys.LAYER_CONFIGS);
|
|
69679
|
+
if (layerConfigsData) {
|
|
69680
|
+
const decompressed = DataCompressor.decompress(layerConfigsData);
|
|
69681
|
+
const layerConfigs = JSON.parse(decompressed);
|
|
69682
|
+
if (layerConfigs.length > STORAGE_CONFIG.BATCH_CLEANUP_SIZE) {
|
|
69683
|
+
const cleanedConfigs = layerConfigs.slice(0, STORAGE_CONFIG.MAX_LAYER_CONFIGS - STORAGE_CONFIG.BATCH_CLEANUP_SIZE);
|
|
69684
|
+
const compressed = DataCompressor.compress(JSON.stringify(cleanedConfigs));
|
|
69685
|
+
localStorage.setItem(this.storageKeys.LAYER_CONFIGS, compressed);
|
|
69686
|
+
console.log(`清理图层配置:${layerConfigs.length} -> ${cleanedConfigs.length}`);
|
|
69687
|
+
}
|
|
69688
|
+
}
|
|
69689
|
+
} catch (error2) {
|
|
69690
|
+
console.error("清理图层配置失败:", error2);
|
|
69691
|
+
}
|
|
69692
|
+
}
|
|
69693
|
+
} finally {
|
|
69694
|
+
this.isCleaningUp = false;
|
|
69695
|
+
}
|
|
69696
|
+
}
|
|
69697
|
+
/**
|
|
69698
|
+
* 安全存储数据(带配额检查)
|
|
69699
|
+
*/
|
|
69700
|
+
safeSetItem(key2, value) {
|
|
69701
|
+
try {
|
|
69702
|
+
if (!this.isCleaningUp) {
|
|
69703
|
+
const quota = this.checkStorageQuota();
|
|
69704
|
+
if (quota.percentage >= STORAGE_CONFIG.QUOTA_WARNING_THRESHOLD) {
|
|
69705
|
+
console.warn(`存储空间使用率已达${Math.round(quota.percentage * 100)}%`);
|
|
69706
|
+
if (quota.percentage >= STORAGE_CONFIG.AUTO_CLEANUP_THRESHOLD) {
|
|
69707
|
+
this.autoCleanup();
|
|
69708
|
+
}
|
|
69709
|
+
}
|
|
69710
|
+
}
|
|
69711
|
+
const compressedValue = DataCompressor.compress(value);
|
|
69712
|
+
localStorage.setItem(key2, compressedValue);
|
|
69713
|
+
return true;
|
|
69714
|
+
} catch (error2) {
|
|
69715
|
+
if (error2 instanceof DOMException && error2.code === 22) {
|
|
69716
|
+
console.error("存储配额已满,尝试清理后重试");
|
|
69717
|
+
if (!this.isCleaningUp) {
|
|
69718
|
+
this.autoCleanup();
|
|
69719
|
+
try {
|
|
69720
|
+
const compressedValue = DataCompressor.compress(value);
|
|
69721
|
+
localStorage.setItem(key2, compressedValue);
|
|
69722
|
+
return true;
|
|
69723
|
+
} catch {
|
|
69724
|
+
console.error("清理后仍无法存储,数据过大或配额不足");
|
|
69725
|
+
return false;
|
|
69726
|
+
}
|
|
69727
|
+
} else {
|
|
69728
|
+
console.error("清理过程中存储失败,跳过重试");
|
|
69729
|
+
return false;
|
|
69730
|
+
}
|
|
69731
|
+
}
|
|
69732
|
+
console.error("存储失败:", error2);
|
|
69733
|
+
return false;
|
|
69734
|
+
}
|
|
69735
|
+
}
|
|
69736
|
+
/**
|
|
69737
|
+
* 安全获取数据(带解压缩)
|
|
69738
|
+
*/
|
|
69739
|
+
safeGetItem(key2) {
|
|
69740
|
+
try {
|
|
69741
|
+
const item = localStorage.getItem(key2);
|
|
69742
|
+
if (item) {
|
|
69743
|
+
return DataCompressor.decompress(item);
|
|
69744
|
+
}
|
|
69745
|
+
return null;
|
|
69746
|
+
} catch (error2) {
|
|
69747
|
+
console.error("获取数据失败:", error2);
|
|
69748
|
+
return null;
|
|
69749
|
+
}
|
|
69587
69750
|
}
|
|
69588
69751
|
/**
|
|
69589
69752
|
* 保存测量结果
|
|
69590
69753
|
*/
|
|
69591
69754
|
saveMeasurements(measurements) {
|
|
69592
69755
|
try {
|
|
69593
|
-
|
|
69756
|
+
let limitedMeasurements = measurements.sort((a3, b10) => (b10.timestamp || 0) - (a3.timestamp || 0)).slice(0, STORAGE_CONFIG.MAX_MEASUREMENTS);
|
|
69757
|
+
limitedMeasurements = limitedMeasurements.map((m2) => ({
|
|
69758
|
+
...m2,
|
|
69759
|
+
timestamp: m2.timestamp || Date.now()
|
|
69760
|
+
}));
|
|
69761
|
+
const success = this.safeSetItem(this.storageKeys.MEASUREMENTS, JSON.stringify(limitedMeasurements));
|
|
69762
|
+
if (!success) {
|
|
69763
|
+
console.error("保存测量结果失败: 存储空间不足");
|
|
69764
|
+
}
|
|
69594
69765
|
} catch (error2) {
|
|
69595
69766
|
console.error("保存测量结果失败:", error2);
|
|
69596
69767
|
}
|
|
@@ -69600,7 +69771,7 @@ ${this.attributes_.map(
|
|
|
69600
69771
|
*/
|
|
69601
69772
|
getMeasurements() {
|
|
69602
69773
|
try {
|
|
69603
|
-
const data2 =
|
|
69774
|
+
const data2 = this.safeGetItem(this.storageKeys.MEASUREMENTS);
|
|
69604
69775
|
return data2 ? JSON.parse(data2) : [];
|
|
69605
69776
|
} catch (error2) {
|
|
69606
69777
|
console.error("获取测量结果失败:", error2);
|
|
@@ -69633,18 +69804,31 @@ ${this.attributes_.map(
|
|
|
69633
69804
|
*/
|
|
69634
69805
|
saveLayerConfigs(configs) {
|
|
69635
69806
|
try {
|
|
69636
|
-
const
|
|
69637
|
-
|
|
69638
|
-
|
|
69639
|
-
|
|
69640
|
-
|
|
69641
|
-
|
|
69642
|
-
|
|
69643
|
-
|
|
69644
|
-
|
|
69645
|
-
|
|
69646
|
-
|
|
69647
|
-
|
|
69807
|
+
const limitedConfigs = configs.slice(0, STORAGE_CONFIG.MAX_LAYER_CONFIGS);
|
|
69808
|
+
const configsToSave = limitedConfigs.map((config) => {
|
|
69809
|
+
const optimizedConfig = {
|
|
69810
|
+
id: config.id,
|
|
69811
|
+
name: config.name,
|
|
69812
|
+
type: config.type,
|
|
69813
|
+
visible: config.visible
|
|
69814
|
+
};
|
|
69815
|
+
if (config.url)
|
|
69816
|
+
optimizedConfig.url = config.url;
|
|
69817
|
+
if (config.opacity !== void 0 && config.opacity !== 1)
|
|
69818
|
+
optimizedConfig.opacity = config.opacity;
|
|
69819
|
+
if (config.zIndex !== void 0 && config.zIndex !== 0)
|
|
69820
|
+
optimizedConfig.zIndex = config.zIndex;
|
|
69821
|
+
if (config.legend)
|
|
69822
|
+
optimizedConfig.legend = config.legend;
|
|
69823
|
+
if (config.metadata && Object.keys(config.metadata).length > 0) {
|
|
69824
|
+
optimizedConfig.metadata = config.metadata;
|
|
69825
|
+
}
|
|
69826
|
+
return optimizedConfig;
|
|
69827
|
+
});
|
|
69828
|
+
const success = this.safeSetItem(this.storageKeys.LAYER_CONFIGS, JSON.stringify(configsToSave));
|
|
69829
|
+
if (!success) {
|
|
69830
|
+
console.error("保存图层配置失败: 存储空间不足");
|
|
69831
|
+
}
|
|
69648
69832
|
} catch (error2) {
|
|
69649
69833
|
console.error("保存图层配置失败:", error2);
|
|
69650
69834
|
}
|
|
@@ -69654,7 +69838,7 @@ ${this.attributes_.map(
|
|
|
69654
69838
|
*/
|
|
69655
69839
|
getLayerConfigs() {
|
|
69656
69840
|
try {
|
|
69657
|
-
const data2 =
|
|
69841
|
+
const data2 = this.safeGetItem(this.storageKeys.LAYER_CONFIGS);
|
|
69658
69842
|
return data2 ? JSON.parse(data2) : [];
|
|
69659
69843
|
} catch (error2) {
|
|
69660
69844
|
console.error("获取图层配置失败:", error2);
|
|
@@ -69667,7 +69851,10 @@ ${this.attributes_.map(
|
|
|
69667
69851
|
saveMapState(center2, zoom, rotation = 0) {
|
|
69668
69852
|
try {
|
|
69669
69853
|
const state = { center: center2, zoom, rotation, timestamp: Date.now() };
|
|
69670
|
-
|
|
69854
|
+
const success = this.safeSetItem(this.storageKeys.MAP_STATE, JSON.stringify(state));
|
|
69855
|
+
if (!success) {
|
|
69856
|
+
console.error("保存地图状态失败: 存储空间不足");
|
|
69857
|
+
}
|
|
69671
69858
|
} catch (error2) {
|
|
69672
69859
|
console.error("保存地图状态失败:", error2);
|
|
69673
69860
|
}
|
|
@@ -69677,7 +69864,7 @@ ${this.attributes_.map(
|
|
|
69677
69864
|
*/
|
|
69678
69865
|
getMapState() {
|
|
69679
69866
|
try {
|
|
69680
|
-
const data2 =
|
|
69867
|
+
const data2 = this.safeGetItem(this.storageKeys.MAP_STATE);
|
|
69681
69868
|
return data2 ? JSON.parse(data2) : null;
|
|
69682
69869
|
} catch (error2) {
|
|
69683
69870
|
console.error("获取地图状态失败:", error2);
|
|
@@ -69705,10 +69892,101 @@ ${this.attributes_.map(
|
|
|
69705
69892
|
});
|
|
69706
69893
|
return Math.round(total / 1024 * 100) / 100;
|
|
69707
69894
|
}
|
|
69895
|
+
/**
|
|
69896
|
+
* 获取详细的存储状态信息
|
|
69897
|
+
*/
|
|
69898
|
+
getStorageStatus() {
|
|
69899
|
+
const quota = this.checkStorageQuota();
|
|
69900
|
+
const measurements = this.getMeasurements();
|
|
69901
|
+
const layerConfigs = this.getLayerConfigs();
|
|
69902
|
+
const warnings = [];
|
|
69903
|
+
if (quota.percentage >= STORAGE_CONFIG.QUOTA_WARNING_THRESHOLD) {
|
|
69904
|
+
warnings.push(`存储空间使用率已达${Math.round(quota.percentage * 100)}%`);
|
|
69905
|
+
}
|
|
69906
|
+
if (measurements.length >= STORAGE_CONFIG.MAX_MEASUREMENTS * 0.8) {
|
|
69907
|
+
warnings.push(`测量结果数量接近上限 (${measurements.length}/${STORAGE_CONFIG.MAX_MEASUREMENTS})`);
|
|
69908
|
+
}
|
|
69909
|
+
if (layerConfigs.length >= STORAGE_CONFIG.MAX_LAYER_CONFIGS * 0.8) {
|
|
69910
|
+
warnings.push(`图层配置数量接近上限 (${layerConfigs.length}/${STORAGE_CONFIG.MAX_LAYER_CONFIGS})`);
|
|
69911
|
+
}
|
|
69912
|
+
return {
|
|
69913
|
+
quota,
|
|
69914
|
+
instanceSize: this.getStorageSize(),
|
|
69915
|
+
measurementCount: measurements.length,
|
|
69916
|
+
layerConfigCount: layerConfigs.length,
|
|
69917
|
+
compressionEnabled: STORAGE_CONFIG.COMPRESSION_ENABLED,
|
|
69918
|
+
warnings
|
|
69919
|
+
};
|
|
69920
|
+
}
|
|
69921
|
+
/**
|
|
69922
|
+
* 手动清理存储
|
|
69923
|
+
*/
|
|
69924
|
+
manualCleanup(options = {}) {
|
|
69925
|
+
const {
|
|
69926
|
+
clearMeasurements = false,
|
|
69927
|
+
clearLayerConfigs = false,
|
|
69928
|
+
clearMapState = false,
|
|
69929
|
+
keepRecentCount = 50
|
|
69930
|
+
} = options;
|
|
69931
|
+
if (clearMeasurements) {
|
|
69932
|
+
if (keepRecentCount > 0) {
|
|
69933
|
+
const measurements = this.getMeasurements();
|
|
69934
|
+
const recentMeasurements = measurements.sort((a3, b10) => (b10.timestamp || 0) - (a3.timestamp || 0)).slice(0, keepRecentCount);
|
|
69935
|
+
this.saveMeasurements(recentMeasurements);
|
|
69936
|
+
} else {
|
|
69937
|
+
this.clearMeasurements();
|
|
69938
|
+
}
|
|
69939
|
+
}
|
|
69940
|
+
if (clearLayerConfigs) {
|
|
69941
|
+
if (keepRecentCount > 0) {
|
|
69942
|
+
const layerConfigs = this.getLayerConfigs();
|
|
69943
|
+
const recentConfigs = layerConfigs.slice(0, keepRecentCount);
|
|
69944
|
+
this.saveLayerConfigs(recentConfigs);
|
|
69945
|
+
} else {
|
|
69946
|
+
localStorage.removeItem(this.storageKeys.LAYER_CONFIGS);
|
|
69947
|
+
}
|
|
69948
|
+
}
|
|
69949
|
+
if (clearMapState) {
|
|
69950
|
+
localStorage.removeItem(this.storageKeys.MAP_STATE);
|
|
69951
|
+
}
|
|
69952
|
+
}
|
|
69953
|
+
/**
|
|
69954
|
+
* 导出存储数据(用于备份)
|
|
69955
|
+
*/
|
|
69956
|
+
exportData() {
|
|
69957
|
+
return {
|
|
69958
|
+
measurements: this.getMeasurements(),
|
|
69959
|
+
layerConfigs: this.getLayerConfigs(),
|
|
69960
|
+
mapState: this.getMapState(),
|
|
69961
|
+
exportTime: Date.now()
|
|
69962
|
+
};
|
|
69963
|
+
}
|
|
69964
|
+
/**
|
|
69965
|
+
* 导入存储数据(用于恢复)
|
|
69966
|
+
*/
|
|
69967
|
+
importData(data2) {
|
|
69968
|
+
try {
|
|
69969
|
+
if (data2.measurements) {
|
|
69970
|
+
this.saveMeasurements(data2.measurements);
|
|
69971
|
+
}
|
|
69972
|
+
if (data2.layerConfigs) {
|
|
69973
|
+
this.saveLayerConfigs(data2.layerConfigs);
|
|
69974
|
+
}
|
|
69975
|
+
if (data2.mapState) {
|
|
69976
|
+
const { center: center2, zoom, rotation } = data2.mapState;
|
|
69977
|
+
this.saveMapState(center2, zoom, rotation);
|
|
69978
|
+
}
|
|
69979
|
+
return true;
|
|
69980
|
+
} catch (error2) {
|
|
69981
|
+
console.error("导入数据失败:", error2);
|
|
69982
|
+
return false;
|
|
69983
|
+
}
|
|
69984
|
+
}
|
|
69708
69985
|
}
|
|
69709
69986
|
function createMapStorage(instanceId) {
|
|
69710
69987
|
return new MapStorage(instanceId);
|
|
69711
69988
|
}
|
|
69989
|
+
new MapStorage("global");
|
|
69712
69990
|
class MeasurementTool {
|
|
69713
69991
|
constructor(map2, storage2, options = {}) {
|
|
69714
69992
|
__publicField(this, "map");
|
|
@@ -69808,7 +70086,7 @@ ${this.attributes_.map(
|
|
|
69808
70086
|
}
|
|
69809
70087
|
// 清除特定要素的测量结果标注
|
|
69810
70088
|
clearFeatureTooltips(feature2) {
|
|
69811
|
-
const featureId2 = feature2.getId() || feature2.ol_uid;
|
|
70089
|
+
const featureId2 = feature2.getId && feature2.getId() || feature2.ol_uid || feature2.get("id");
|
|
69812
70090
|
const nodesToRemove = this.nodeMarkers.filter((node2) => {
|
|
69813
70091
|
const nodeFeatureId = node2.get("parentFeatureId");
|
|
69814
70092
|
return nodeFeatureId === featureId2;
|
|
@@ -69935,7 +70213,7 @@ ${this.attributes_.map(
|
|
|
69935
70213
|
const tooltip = this.createSegmentTooltipOverlay(center2, areaText);
|
|
69936
70214
|
tooltips.push(tooltip);
|
|
69937
70215
|
this.map.addOverlay(tooltip);
|
|
69938
|
-
const featureId2 = feature2.getId() || feature2.ol_uid;
|
|
70216
|
+
const featureId2 = feature2.getId && feature2.getId() || feature2.ol_uid || feature2.get("id");
|
|
69939
70217
|
const tooltipElement = tooltip.getElement();
|
|
69940
70218
|
this.areaTooltips.push({
|
|
69941
70219
|
element: tooltipElement,
|
|
@@ -69952,7 +70230,7 @@ ${this.attributes_.map(
|
|
|
69952
70230
|
const tooltip = this.createSegmentTooltipOverlay(vertex, angleText);
|
|
69953
70231
|
tooltips.push(tooltip);
|
|
69954
70232
|
this.map.addOverlay(tooltip);
|
|
69955
|
-
const featureId2 = feature2.getId() || feature2.ol_uid;
|
|
70233
|
+
const featureId2 = feature2.getId && feature2.getId() || feature2.ol_uid || feature2.get("id");
|
|
69956
70234
|
const tooltipElement = tooltip.getElement();
|
|
69957
70235
|
this.angleTooltips.push({
|
|
69958
70236
|
element: tooltipElement,
|
|
@@ -81658,7 +81936,7 @@ ${this.attributes_.map(
|
|
|
81658
81936
|
const styles = customCss.split(";").filter((style) => style.trim());
|
|
81659
81937
|
styles.forEach((style) => {
|
|
81660
81938
|
const [property, value] = style.split(":").map((s2) => s2.trim());
|
|
81661
|
-
if (property && value) {
|
|
81939
|
+
if (property && value && canvas) {
|
|
81662
81940
|
canvas.style[property] = value;
|
|
81663
81941
|
}
|
|
81664
81942
|
});
|
|
@@ -81688,17 +81966,20 @@ ${this.attributes_.map(
|
|
|
81688
81966
|
* 清除图层样式
|
|
81689
81967
|
*/
|
|
81690
81968
|
clearLayerStyles() {
|
|
81691
|
-
var _a3, _b3;
|
|
81692
81969
|
if (!this.layer)
|
|
81693
81970
|
return;
|
|
81694
|
-
const
|
|
81971
|
+
const renderer = this.layer.getRenderer();
|
|
81972
|
+
let canvas = null;
|
|
81973
|
+
if (renderer && typeof renderer.getCanvas === "function") {
|
|
81974
|
+
canvas = renderer.getCanvas();
|
|
81975
|
+
}
|
|
81695
81976
|
if (canvas) {
|
|
81696
81977
|
if (this.config.customCss) {
|
|
81697
81978
|
const customCss = this.config.customCss;
|
|
81698
81979
|
const styles = customCss.split(";").filter((style) => style.trim());
|
|
81699
81980
|
styles.forEach((style) => {
|
|
81700
81981
|
const [property] = style.split(":").map((s2) => s2.trim());
|
|
81701
|
-
if (property) {
|
|
81982
|
+
if (property && canvas) {
|
|
81702
81983
|
canvas.style[property] = "";
|
|
81703
81984
|
}
|
|
81704
81985
|
});
|
|
@@ -81967,18 +82248,121 @@ ${this.attributes_.map(
|
|
|
81967
82248
|
getFeatureInfoUrl(coordinate, resolution, projection2, params2) {
|
|
81968
82249
|
const layer2 = this.getLayer();
|
|
81969
82250
|
const source = layer2.getSource();
|
|
81970
|
-
if (source
|
|
81971
|
-
return
|
|
82251
|
+
if (!source)
|
|
82252
|
+
return void 0;
|
|
82253
|
+
return source.getFeatureInfoUrl(
|
|
82254
|
+
coordinate,
|
|
82255
|
+
resolution,
|
|
82256
|
+
projection2,
|
|
82257
|
+
{
|
|
82258
|
+
"INFO_FORMAT": "application/json",
|
|
82259
|
+
"FEATURE_COUNT": 10,
|
|
82260
|
+
...params2
|
|
82261
|
+
}
|
|
82262
|
+
);
|
|
82263
|
+
}
|
|
82264
|
+
/**
|
|
82265
|
+
* 通过坐标获取要素信息
|
|
82266
|
+
*/
|
|
82267
|
+
async getFeatureInfoAtCoordinate(coordinate, options = {}) {
|
|
82268
|
+
const {
|
|
82269
|
+
infoFormat = "application/json",
|
|
82270
|
+
featureCount = 10,
|
|
82271
|
+
resolution,
|
|
82272
|
+
projection: projection2 = "EPSG:3857"
|
|
82273
|
+
} = options;
|
|
82274
|
+
try {
|
|
82275
|
+
const map2 = this.map;
|
|
82276
|
+
if (!map2) {
|
|
82277
|
+
console.warn("地图实例未初始化");
|
|
82278
|
+
return [];
|
|
82279
|
+
}
|
|
82280
|
+
const view = map2.getView();
|
|
82281
|
+
const currentResolution = resolution || view.getResolution();
|
|
82282
|
+
const currentProjection = view.getProjection().getCode();
|
|
82283
|
+
if (!currentResolution) {
|
|
82284
|
+
console.warn("无法获取地图分辨率");
|
|
82285
|
+
return [];
|
|
82286
|
+
}
|
|
82287
|
+
const url = this.getFeatureInfoUrl(
|
|
81972
82288
|
coordinate,
|
|
81973
|
-
|
|
81974
|
-
|
|
82289
|
+
currentResolution,
|
|
82290
|
+
currentProjection,
|
|
81975
82291
|
{
|
|
81976
|
-
"INFO_FORMAT":
|
|
81977
|
-
|
|
82292
|
+
"INFO_FORMAT": infoFormat,
|
|
82293
|
+
"FEATURE_COUNT": featureCount
|
|
81978
82294
|
}
|
|
81979
|
-
)
|
|
82295
|
+
);
|
|
82296
|
+
if (!url) {
|
|
82297
|
+
console.warn("无法构建GetFeatureInfo请求URL");
|
|
82298
|
+
return [];
|
|
82299
|
+
}
|
|
82300
|
+
console.log("WMS GetFeatureInfo请求URL:", url);
|
|
82301
|
+
const response = await fetch(url);
|
|
82302
|
+
if (!response.ok) {
|
|
82303
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
82304
|
+
}
|
|
82305
|
+
const data2 = await response.json();
|
|
82306
|
+
const features2 = this.parseFeatureInfoResponse(data2);
|
|
82307
|
+
return features2.map((feature2) => {
|
|
82308
|
+
const properties = feature2.properties || {};
|
|
82309
|
+
return {
|
|
82310
|
+
...feature2,
|
|
82311
|
+
properties: {
|
|
82312
|
+
...properties,
|
|
82313
|
+
layerId: this.config.id,
|
|
82314
|
+
layerName: this.config.name,
|
|
82315
|
+
layerType: "wms"
|
|
82316
|
+
},
|
|
82317
|
+
// 添加OpenLayers Feature兼容方法
|
|
82318
|
+
getProperties: () => ({
|
|
82319
|
+
...properties,
|
|
82320
|
+
layerId: this.config.id,
|
|
82321
|
+
layerName: this.config.name,
|
|
82322
|
+
layerType: "wms"
|
|
82323
|
+
}),
|
|
82324
|
+
get: (key2) => properties[key2],
|
|
82325
|
+
setProperties: (props) => {
|
|
82326
|
+
Object.assign(properties, props);
|
|
82327
|
+
}
|
|
82328
|
+
};
|
|
82329
|
+
});
|
|
82330
|
+
} catch (error2) {
|
|
82331
|
+
console.error("WMS GetFeatureInfo查询失败:", error2);
|
|
82332
|
+
return [];
|
|
81980
82333
|
}
|
|
81981
|
-
|
|
82334
|
+
}
|
|
82335
|
+
/**
|
|
82336
|
+
* 解析GetFeatureInfo响应数据
|
|
82337
|
+
*/
|
|
82338
|
+
parseFeatureInfoResponse(data2) {
|
|
82339
|
+
const features2 = [];
|
|
82340
|
+
try {
|
|
82341
|
+
if (data2.type === "FeatureCollection" && data2.features) {
|
|
82342
|
+
return data2.features;
|
|
82343
|
+
}
|
|
82344
|
+
if (data2.type === "Feature") {
|
|
82345
|
+
return [data2];
|
|
82346
|
+
}
|
|
82347
|
+
if (Array.isArray(data2)) {
|
|
82348
|
+
return data2;
|
|
82349
|
+
}
|
|
82350
|
+
if (typeof data2 === "object" && data2 !== null) {
|
|
82351
|
+
for (const key2 in data2) {
|
|
82352
|
+
if (Array.isArray(data2[key2])) {
|
|
82353
|
+
return data2[key2];
|
|
82354
|
+
}
|
|
82355
|
+
}
|
|
82356
|
+
return [{
|
|
82357
|
+
type: "Feature",
|
|
82358
|
+
properties: data2,
|
|
82359
|
+
geometry: null
|
|
82360
|
+
}];
|
|
82361
|
+
}
|
|
82362
|
+
} catch (error2) {
|
|
82363
|
+
console.error("解析WMS响应数据失败:", error2);
|
|
82364
|
+
}
|
|
82365
|
+
return features2;
|
|
81982
82366
|
}
|
|
81983
82367
|
}
|
|
81984
82368
|
class WMTSLayerHandler extends BaseLayer$2 {
|
|
@@ -82990,8 +83374,7 @@ ${this.attributes_.map(
|
|
|
82990
83374
|
view.fit(extent3, {
|
|
82991
83375
|
padding: fitOptions.padding,
|
|
82992
83376
|
maxZoom: fitOptions.maxZoom,
|
|
82993
|
-
duration: fitOptions.duration
|
|
82994
|
-
minZoom: fitOptions.minZoom
|
|
83377
|
+
duration: fitOptions.duration
|
|
82995
83378
|
});
|
|
82996
83379
|
console.log(`已定位到 ${features2.length} 个 GeoJSON 要素`);
|
|
82997
83380
|
}
|
|
@@ -83319,7 +83702,7 @@ ${this.attributes_.map(
|
|
|
83319
83702
|
}
|
|
83320
83703
|
class GMLLayerHandler extends BaseLayer$2 {
|
|
83321
83704
|
constructor(config, map2) {
|
|
83322
|
-
super(config
|
|
83705
|
+
super(config);
|
|
83323
83706
|
__publicField(this, "vectorSource", null);
|
|
83324
83707
|
__publicField(this, "gmlFormat", null);
|
|
83325
83708
|
this.initializeGMLFormat();
|
|
@@ -83334,21 +83717,18 @@ ${this.attributes_.map(
|
|
|
83334
83717
|
case "2":
|
|
83335
83718
|
case "2.0":
|
|
83336
83719
|
this.gmlFormat = new GML$1({
|
|
83337
|
-
className: gmlConfig.className,
|
|
83338
83720
|
srsName: gmlConfig.srsName || "EPSG:4326"
|
|
83339
83721
|
});
|
|
83340
83722
|
break;
|
|
83341
83723
|
case "3":
|
|
83342
83724
|
case "3.0":
|
|
83343
83725
|
this.gmlFormat = new GML3$1({
|
|
83344
|
-
className: gmlConfig.className,
|
|
83345
83726
|
srsName: gmlConfig.srsName || "EPSG:4326"
|
|
83346
83727
|
});
|
|
83347
83728
|
break;
|
|
83348
83729
|
case "3.2":
|
|
83349
83730
|
default:
|
|
83350
83731
|
this.gmlFormat = new GML32$1({
|
|
83351
|
-
className: gmlConfig.className,
|
|
83352
83732
|
srsName: gmlConfig.srsName || "EPSG:4326"
|
|
83353
83733
|
});
|
|
83354
83734
|
break;
|
|
@@ -84203,7 +84583,7 @@ ${this.attributes_.map(
|
|
|
84203
84583
|
* 更新图层配置
|
|
84204
84584
|
*/
|
|
84205
84585
|
updateLayerConfig(config) {
|
|
84206
|
-
super.
|
|
84586
|
+
super.updateConfig(config);
|
|
84207
84587
|
if (config.clusterDistance !== void 0) {
|
|
84208
84588
|
this.setDistance(config.clusterDistance);
|
|
84209
84589
|
}
|
|
@@ -463483,8 +463863,8 @@ ${this.attributes_.map(
|
|
|
463483
463863
|
__publicField(this, "maxStyleApplyAttempts", 5);
|
|
463484
463864
|
}
|
|
463485
463865
|
setupEPSG4490() {
|
|
463486
|
-
|
|
463487
|
-
register$3(proj4$
|
|
463866
|
+
(void 0)("EPSG:4490", "+proj=longlat +ellps=GRS80 +no_defs +type=crs");
|
|
463867
|
+
register$3(proj4$2);
|
|
463488
463868
|
console.log("EPSG:4490投影已注册");
|
|
463489
463869
|
}
|
|
463490
463870
|
async createLayer() {
|
|
@@ -463627,8 +464007,11 @@ ${this.attributes_.map(
|
|
|
463627
464007
|
let mapJsonUrl = config.url;
|
|
463628
464008
|
if (mapJsonUrl.includes("/rest/maps/")) {
|
|
463629
464009
|
const match2 = mapJsonUrl.match(/(.*\/rest\/maps\/[^/]+)/);
|
|
463630
|
-
if (match2) {
|
|
464010
|
+
if (match2 && match2.length > 1) {
|
|
463631
464011
|
mapJsonUrl = match2[1] + ".json";
|
|
464012
|
+
} else {
|
|
464013
|
+
console.warn("无法从URL中提取map.json路径,跳过元数据获取");
|
|
464014
|
+
return sourceOptions;
|
|
463632
464015
|
}
|
|
463633
464016
|
}
|
|
463634
464017
|
console.log(`正在获取SuperMap服务元数据: ${mapJsonUrl}`);
|
|
@@ -463790,7 +464173,12 @@ ${this.attributes_.map(
|
|
|
463790
464173
|
const source = (_a3 = this.layer) == null ? void 0 : _a3.getSource();
|
|
463791
464174
|
if (source) {
|
|
463792
464175
|
let needsRecreate = false;
|
|
463793
|
-
const recreateConfigs = [
|
|
464176
|
+
const recreateConfigs = [
|
|
464177
|
+
"format",
|
|
464178
|
+
"transparent",
|
|
464179
|
+
"cacheEnabled",
|
|
464180
|
+
"autoFetchMetadata"
|
|
464181
|
+
];
|
|
463794
464182
|
for (const key2 of recreateConfigs) {
|
|
463795
464183
|
if (newConfig[key2] !== void 0 && newConfig[key2] !== this.config[key2]) {
|
|
463796
464184
|
needsRecreate = true;
|
|
@@ -463826,6 +464214,539 @@ ${this.attributes_.map(
|
|
|
463826
464214
|
console.error("重新创建SuperMap图层失败:", error2);
|
|
463827
464215
|
}
|
|
463828
464216
|
}
|
|
464217
|
+
/**
|
|
464218
|
+
* 根据地图当前分辨率动态计算点选容差
|
|
464219
|
+
* @param map OpenLayers Map 对象
|
|
464220
|
+
* @param baseTolerance 基础容差(地图坐标系单位,默认为 5)
|
|
464221
|
+
* @returns number 动态计算后的 tolerance
|
|
464222
|
+
*/
|
|
464223
|
+
getDynamicTolerance(baseTolerance = 500) {
|
|
464224
|
+
if (!this.map || !this.map.getView)
|
|
464225
|
+
return baseTolerance;
|
|
464226
|
+
const resolution = this.map.getView().getResolution();
|
|
464227
|
+
if (!resolution)
|
|
464228
|
+
return baseTolerance;
|
|
464229
|
+
const dynamicTolerance = baseTolerance * resolution;
|
|
464230
|
+
return dynamicTolerance;
|
|
464231
|
+
}
|
|
464232
|
+
/**
|
|
464233
|
+
* 点选查询要素(类似 WMS GetFeatureInfo)
|
|
464234
|
+
* @param lon 经度
|
|
464235
|
+
* @param lat 纬度
|
|
464236
|
+
* @param options 查询选项
|
|
464237
|
+
* @returns Promise<any[]> 查询到的要素数组
|
|
464238
|
+
*/
|
|
464239
|
+
async queryFeatureByPointOL(lon2, lat2, options = {}) {
|
|
464240
|
+
const {
|
|
464241
|
+
datasetNames = ["hms:Football_field"],
|
|
464242
|
+
serviceUrl = "http://172.16.201.151/iserver/services/data-hms-public/rest/data",
|
|
464243
|
+
tolerance: tolerance2 = 0.027,
|
|
464244
|
+
vectorLayer = null
|
|
464245
|
+
} = options;
|
|
464246
|
+
const point2 = new Point$c([lon2, lat2]);
|
|
464247
|
+
let smGeom = Util.toSuperMapGeometry(point2);
|
|
464248
|
+
if (!smGeom) {
|
|
464249
|
+
const SuperMap2 = window.SuperMap || globalThis.SuperMap;
|
|
464250
|
+
if (SuperMap2 && SuperMap2.Geometry && typeof SuperMap2.Geometry.Point === "function") {
|
|
464251
|
+
smGeom = new SuperMap2.Geometry.Point(lon2, lat2);
|
|
464252
|
+
} else {
|
|
464253
|
+
console.warn("无法构造 SuperMap.Geometry.Point");
|
|
464254
|
+
return [];
|
|
464255
|
+
}
|
|
464256
|
+
}
|
|
464257
|
+
const queryParams = new GetFeaturesByGeometryParameters({
|
|
464258
|
+
datasetNames,
|
|
464259
|
+
geometry: smGeom,
|
|
464260
|
+
spatialQueryMode: "INTERSECT"
|
|
464261
|
+
// WMS 点选风格就是 INTERSECT
|
|
464262
|
+
// tolerance 参数在此版本中不支持,已移除
|
|
464263
|
+
});
|
|
464264
|
+
return new Promise((resolve, reject2) => {
|
|
464265
|
+
new FeatureService(serviceUrl).getFeaturesByGeometry(
|
|
464266
|
+
queryParams,
|
|
464267
|
+
(result) => {
|
|
464268
|
+
var _a3, _b3, _c2;
|
|
464269
|
+
if (result.error) {
|
|
464270
|
+
console.error("iServer 错误:", result.error);
|
|
464271
|
+
reject2(result.error);
|
|
464272
|
+
return;
|
|
464273
|
+
}
|
|
464274
|
+
const features2 = ((_b3 = (_a3 = result.result) == null ? void 0 : _a3.features) == null ? void 0 : _b3.features) || [];
|
|
464275
|
+
if (vectorLayer) {
|
|
464276
|
+
(_c2 = vectorLayer.getSource()) == null ? void 0 : _c2.clear();
|
|
464277
|
+
features2.forEach((f2) => {
|
|
464278
|
+
var _a4;
|
|
464279
|
+
const olFeat = new ol$1.Feature(Util.toSuperMapGeometry(f2.geometry));
|
|
464280
|
+
olFeat.setProperties(f2.properties || {});
|
|
464281
|
+
(_a4 = vectorLayer.getSource()) == null ? void 0 : _a4.addFeature(olFeat);
|
|
464282
|
+
});
|
|
464283
|
+
}
|
|
464284
|
+
resolve(features2);
|
|
464285
|
+
}
|
|
464286
|
+
);
|
|
464287
|
+
});
|
|
464288
|
+
}
|
|
464289
|
+
/**
|
|
464290
|
+
* 通过缓冲区查询要素的公共方法
|
|
464291
|
+
* @param lon 经度
|
|
464292
|
+
* @param lat 纬度
|
|
464293
|
+
* @param options 查询选项
|
|
464294
|
+
* @returns Promise<Feature[]> 查询到的要素数组
|
|
464295
|
+
*/
|
|
464296
|
+
async getFeaturesByBuffer(lon2 = 93.53179023100006, lat2 = 42.81598224900006, options = {}) {
|
|
464297
|
+
try {
|
|
464298
|
+
const {
|
|
464299
|
+
bufferDistance = 0.027,
|
|
464300
|
+
datasetNames = ["hms:Football_field"],
|
|
464301
|
+
serviceUrl = "http://172.16.201.151/iserver/services/data-hms-public/rest/data",
|
|
464302
|
+
vectorLayer = null
|
|
464303
|
+
} = options;
|
|
464304
|
+
const olPoint = new Point$c([lon2, lat2]);
|
|
464305
|
+
let smGeom = Util.toSuperMapGeometry(olPoint);
|
|
464306
|
+
console.log("Util.toSuperMapGeometry ->", smGeom);
|
|
464307
|
+
if (!smGeom) {
|
|
464308
|
+
const SuperMap2 = window.SuperMap || globalThis.SuperMap;
|
|
464309
|
+
if (SuperMap2 && SuperMap2.Geometry && typeof SuperMap2.Geometry.Point === "function") {
|
|
464310
|
+
smGeom = new SuperMap2.Geometry.Point(lon2, lat2);
|
|
464311
|
+
console.log("使用全局 SuperMap.Geometry.Point 构建 smGeom:", smGeom);
|
|
464312
|
+
} else {
|
|
464313
|
+
console.warn(
|
|
464314
|
+
"无法取得全局 SuperMap,无法构造 SuperMap.Geometry.Point。建议使用方案A的 REST 调用绕开。"
|
|
464315
|
+
);
|
|
464316
|
+
}
|
|
464317
|
+
}
|
|
464318
|
+
if (!smGeom) {
|
|
464319
|
+
console.error(
|
|
464320
|
+
"无法构建 SuperMap Geometry(smGeom 为 null)。请使用方案A 或检查 iClient 的引入方式。"
|
|
464321
|
+
);
|
|
464322
|
+
return [];
|
|
464323
|
+
}
|
|
464324
|
+
const bufferParams = new GetFeaturesByBufferParameters({
|
|
464325
|
+
datasetNames,
|
|
464326
|
+
bufferDistance,
|
|
464327
|
+
// 举例(300m ≈ 0.0027°),注意单位和坐标系一致
|
|
464328
|
+
geometry: smGeom,
|
|
464329
|
+
spatialQueryMode: "INTERSECT"
|
|
464330
|
+
});
|
|
464331
|
+
return new Promise((resolve, reject2) => {
|
|
464332
|
+
new FeatureService(serviceUrl).getFeaturesByBuffer(
|
|
464333
|
+
bufferParams,
|
|
464334
|
+
(serviceResult) => {
|
|
464335
|
+
var _a3, _b3, _c2, _d, _e2;
|
|
464336
|
+
console.log("serviceResult:", serviceResult);
|
|
464337
|
+
if (serviceResult.error) {
|
|
464338
|
+
console.error("iServer error:", serviceResult.error);
|
|
464339
|
+
reject2(new Error("iServer 返回错误,详见控制台"));
|
|
464340
|
+
return;
|
|
464341
|
+
}
|
|
464342
|
+
const feats = ((_c2 = (_b3 = (_a3 = serviceResult.result) == null ? void 0 : _a3.features) == null ? void 0 : _b3.features) == null ? void 0 : _c2.map(
|
|
464343
|
+
(f2) => new ol$1.Feature(Util.toSuperMapGeometry(f2.geometry))
|
|
464344
|
+
)) ?? [];
|
|
464345
|
+
if (vectorLayer) {
|
|
464346
|
+
(_d = vectorLayer.getSource()) == null ? void 0 : _d.clear();
|
|
464347
|
+
if (feats.length) {
|
|
464348
|
+
(_e2 = vectorLayer.getSource()) == null ? void 0 : _e2.addFeatures(feats);
|
|
464349
|
+
}
|
|
464350
|
+
}
|
|
464351
|
+
console.log("查询并绘制完成,count:", feats.length);
|
|
464352
|
+
resolve(feats);
|
|
464353
|
+
}
|
|
464354
|
+
);
|
|
464355
|
+
});
|
|
464356
|
+
} catch (err2) {
|
|
464357
|
+
console.error("queryBuffer 捕获异常:", err2);
|
|
464358
|
+
throw new Error("查询异常,详见控制台");
|
|
464359
|
+
}
|
|
464360
|
+
}
|
|
464361
|
+
// ✅ 构建数据服务 URL(适配 map-hmsmap 服务)
|
|
464362
|
+
buildDataServerUrl(baseUrl) {
|
|
464363
|
+
const mapServiceMatch = baseUrl.match(/services\/map-(.+?)\/rest/);
|
|
464364
|
+
if (!mapServiceMatch) {
|
|
464365
|
+
throw new Error("无法从地图服务 URL 推导数据服务地址");
|
|
464366
|
+
}
|
|
464367
|
+
const workspaceName = mapServiceMatch[1];
|
|
464368
|
+
return `${baseUrl.split("/services")[0]}/services/data-${workspaceName}/rest`;
|
|
464369
|
+
}
|
|
464370
|
+
// ✅ 获取默认数据集(示例)
|
|
464371
|
+
getDefaultDatasets() {
|
|
464372
|
+
return ["football_field@hmsmap"];
|
|
464373
|
+
}
|
|
464374
|
+
/**
|
|
464375
|
+
* 通过边界范围查询要素
|
|
464376
|
+
* @param bounds 边界范围 [minX, minY, maxX, maxY]
|
|
464377
|
+
* @param options 查询选项
|
|
464378
|
+
* @returns Promise<any[]> 查询结果
|
|
464379
|
+
*/
|
|
464380
|
+
async getFeaturesByBounds(bounds2, options = {}) {
|
|
464381
|
+
var _a3;
|
|
464382
|
+
const config = this.config;
|
|
464383
|
+
if (!config.url) {
|
|
464384
|
+
console.warn("SuperMap图层缺少服务URL,无法进行要素查询");
|
|
464385
|
+
return [];
|
|
464386
|
+
}
|
|
464387
|
+
const {
|
|
464388
|
+
maxFeatures = 100,
|
|
464389
|
+
datasetNames,
|
|
464390
|
+
returnContent = true,
|
|
464391
|
+
targetProjection
|
|
464392
|
+
} = options;
|
|
464393
|
+
try {
|
|
464394
|
+
const mapProjection = (_a3 = this.map) == null ? void 0 : _a3.getView().getProjection();
|
|
464395
|
+
const projectionCode = targetProjection || (mapProjection == null ? void 0 : mapProjection.getCode()) || "EPSG:4326";
|
|
464396
|
+
let transformedBounds = bounds2;
|
|
464397
|
+
if (mapProjection && targetProjection && mapProjection.getCode() !== targetProjection) {
|
|
464398
|
+
const bottomLeft = transform$l(
|
|
464399
|
+
[bounds2[0], bounds2[1]],
|
|
464400
|
+
mapProjection.getCode(),
|
|
464401
|
+
targetProjection
|
|
464402
|
+
);
|
|
464403
|
+
const topRight = transform$l(
|
|
464404
|
+
[bounds2[2], bounds2[3]],
|
|
464405
|
+
mapProjection.getCode(),
|
|
464406
|
+
targetProjection
|
|
464407
|
+
);
|
|
464408
|
+
transformedBounds = [
|
|
464409
|
+
bottomLeft[0],
|
|
464410
|
+
bottomLeft[1],
|
|
464411
|
+
topRight[0],
|
|
464412
|
+
topRight[1]
|
|
464413
|
+
];
|
|
464414
|
+
}
|
|
464415
|
+
const serviceUrl = this.buildDataServiceUrl(config.url);
|
|
464416
|
+
console.log(`开始SuperMap边界查询:`, {
|
|
464417
|
+
bounds: transformedBounds,
|
|
464418
|
+
serviceUrl,
|
|
464419
|
+
projection: projectionCode
|
|
464420
|
+
});
|
|
464421
|
+
const boundsParams = new GetFeaturesByBoundsParameters({
|
|
464422
|
+
datasetNames: datasetNames || this.extractDatasetNames(config.url),
|
|
464423
|
+
bounds: transformedBounds,
|
|
464424
|
+
maxFeatures,
|
|
464425
|
+
returnContent
|
|
464426
|
+
});
|
|
464427
|
+
const boundsService = new GetFeaturesByBoundsService(serviceUrl);
|
|
464428
|
+
return new Promise((resolve, reject2) => {
|
|
464429
|
+
boundsService.getFeaturesByBounds(
|
|
464430
|
+
boundsParams,
|
|
464431
|
+
(serviceResult) => {
|
|
464432
|
+
var _a4;
|
|
464433
|
+
if (serviceResult.type === "processCompleted") {
|
|
464434
|
+
const result = serviceResult.result;
|
|
464435
|
+
if (result && result.features) {
|
|
464436
|
+
console.log(
|
|
464437
|
+
`SuperMap边界查询成功,找到 ${result.features.length} 个要素`
|
|
464438
|
+
);
|
|
464439
|
+
resolve(result.features);
|
|
464440
|
+
} else {
|
|
464441
|
+
console.log("SuperMap边界查询完成,但未找到要素");
|
|
464442
|
+
resolve([]);
|
|
464443
|
+
}
|
|
464444
|
+
} else {
|
|
464445
|
+
console.error("SuperMap边界查询失败:", serviceResult.error);
|
|
464446
|
+
reject2(
|
|
464447
|
+
new Error(((_a4 = serviceResult.error) == null ? void 0 : _a4.errorMsg) || "边界查询失败")
|
|
464448
|
+
);
|
|
464449
|
+
}
|
|
464450
|
+
}
|
|
464451
|
+
);
|
|
464452
|
+
});
|
|
464453
|
+
} catch (error2) {
|
|
464454
|
+
console.error("SuperMap边界查询异常:", error2);
|
|
464455
|
+
return [];
|
|
464456
|
+
}
|
|
464457
|
+
}
|
|
464458
|
+
/**
|
|
464459
|
+
* 通过几何对象查询要素
|
|
464460
|
+
* @param geometry OpenLayers几何对象
|
|
464461
|
+
* @param options 查询选项
|
|
464462
|
+
* @returns Promise<any[]> 查询结果
|
|
464463
|
+
*/
|
|
464464
|
+
async getFeaturesByGeometry(geometry2, options = {}) {
|
|
464465
|
+
const config = this.config;
|
|
464466
|
+
if (!config.url) {
|
|
464467
|
+
console.warn("SuperMap图层缺少服务URL,无法进行要素查询");
|
|
464468
|
+
return [];
|
|
464469
|
+
}
|
|
464470
|
+
const {
|
|
464471
|
+
maxFeatures = 100,
|
|
464472
|
+
datasetNames,
|
|
464473
|
+
returnContent = true,
|
|
464474
|
+
spatialQueryMode = "INTERSECT",
|
|
464475
|
+
targetProjection
|
|
464476
|
+
} = options;
|
|
464477
|
+
try {
|
|
464478
|
+
const serviceUrl = this.buildDataServiceUrl(config.url);
|
|
464479
|
+
console.log(`开始SuperMap几何查询:`, {
|
|
464480
|
+
geometryType: geometry2.getType(),
|
|
464481
|
+
spatialQueryMode,
|
|
464482
|
+
serviceUrl
|
|
464483
|
+
});
|
|
464484
|
+
const geometryParams = new GetFeaturesByGeometryParameters({
|
|
464485
|
+
datasetNames: datasetNames || this.extractDatasetNames(config.url),
|
|
464486
|
+
geometry: geometry2,
|
|
464487
|
+
maxFeatures,
|
|
464488
|
+
returnContent,
|
|
464489
|
+
spatialQueryMode
|
|
464490
|
+
});
|
|
464491
|
+
const geometryService = new GetFeaturesByGeometryService(serviceUrl);
|
|
464492
|
+
return new Promise((resolve, reject2) => {
|
|
464493
|
+
geometryService.getFeaturesByGeometry(
|
|
464494
|
+
geometryParams,
|
|
464495
|
+
(serviceResult) => {
|
|
464496
|
+
var _a3;
|
|
464497
|
+
if (serviceResult.type === "processCompleted") {
|
|
464498
|
+
const result = serviceResult.result;
|
|
464499
|
+
if (result && result.features) {
|
|
464500
|
+
console.log(
|
|
464501
|
+
`SuperMap几何查询成功,找到 ${result.features.length} 个要素`
|
|
464502
|
+
);
|
|
464503
|
+
resolve(result.features);
|
|
464504
|
+
} else {
|
|
464505
|
+
console.log("SuperMap几何查询完成,但未找到要素");
|
|
464506
|
+
resolve([]);
|
|
464507
|
+
}
|
|
464508
|
+
} else {
|
|
464509
|
+
console.error("SuperMap几何查询失败:", serviceResult.error);
|
|
464510
|
+
reject2(
|
|
464511
|
+
new Error(((_a3 = serviceResult.error) == null ? void 0 : _a3.errorMsg) || "几何查询失败")
|
|
464512
|
+
);
|
|
464513
|
+
}
|
|
464514
|
+
}
|
|
464515
|
+
);
|
|
464516
|
+
});
|
|
464517
|
+
} catch (error2) {
|
|
464518
|
+
console.error("SuperMap几何查询异常:", error2);
|
|
464519
|
+
return [];
|
|
464520
|
+
}
|
|
464521
|
+
}
|
|
464522
|
+
/**
|
|
464523
|
+
* 通过SQL条件查询要素
|
|
464524
|
+
* @param sqlCondition SQL查询条件
|
|
464525
|
+
* @param options 查询选项
|
|
464526
|
+
* @returns Promise<any[]> 查询结果
|
|
464527
|
+
*/
|
|
464528
|
+
async getFeaturesBySQL(sqlCondition, options = {}) {
|
|
464529
|
+
const config = this.config;
|
|
464530
|
+
if (!config.url) {
|
|
464531
|
+
console.warn("SuperMap图层缺少服务URL,无法进行要素查询");
|
|
464532
|
+
return [];
|
|
464533
|
+
}
|
|
464534
|
+
const {
|
|
464535
|
+
maxFeatures = 100,
|
|
464536
|
+
datasetNames,
|
|
464537
|
+
returnContent = true,
|
|
464538
|
+
targetProjection
|
|
464539
|
+
} = options;
|
|
464540
|
+
try {
|
|
464541
|
+
const serviceUrl = this.buildDataServiceUrl(config.url);
|
|
464542
|
+
console.log(`开始SuperMap SQL查询:`, {
|
|
464543
|
+
sqlCondition,
|
|
464544
|
+
serviceUrl
|
|
464545
|
+
});
|
|
464546
|
+
const sqlParams = new GetFeaturesBySQLParameters({
|
|
464547
|
+
datasetNames: datasetNames || this.extractDatasetNames(config.url),
|
|
464548
|
+
queryParameter: {
|
|
464549
|
+
name: "sqlQuery",
|
|
464550
|
+
attributeFilter: sqlCondition
|
|
464551
|
+
},
|
|
464552
|
+
maxFeatures,
|
|
464553
|
+
returnContent
|
|
464554
|
+
});
|
|
464555
|
+
const sqlService = new GetFeaturesBySQLService(serviceUrl);
|
|
464556
|
+
return new Promise((resolve, reject2) => {
|
|
464557
|
+
sqlService.getFeaturesBySQL(sqlParams, (serviceResult) => {
|
|
464558
|
+
var _a3;
|
|
464559
|
+
if (serviceResult.type === "processCompleted") {
|
|
464560
|
+
const result = serviceResult.result;
|
|
464561
|
+
if (result && result.features) {
|
|
464562
|
+
console.log(
|
|
464563
|
+
`SuperMap SQL查询成功,找到 ${result.features.length} 个要素`
|
|
464564
|
+
);
|
|
464565
|
+
resolve(result.features);
|
|
464566
|
+
} else {
|
|
464567
|
+
console.log("SuperMap SQL查询完成,但未找到要素");
|
|
464568
|
+
resolve([]);
|
|
464569
|
+
}
|
|
464570
|
+
} else {
|
|
464571
|
+
console.error("SuperMap SQL查询失败:", serviceResult.error);
|
|
464572
|
+
reject2(new Error(((_a3 = serviceResult.error) == null ? void 0 : _a3.errorMsg) || "SQL查询失败"));
|
|
464573
|
+
}
|
|
464574
|
+
});
|
|
464575
|
+
});
|
|
464576
|
+
} catch (error2) {
|
|
464577
|
+
console.error("SuperMap SQL查询异常:", error2);
|
|
464578
|
+
return [];
|
|
464579
|
+
}
|
|
464580
|
+
}
|
|
464581
|
+
/**
|
|
464582
|
+
* 通过要素ID查询要素
|
|
464583
|
+
* @param featureIds 要素ID数组
|
|
464584
|
+
* @param options 查询选项
|
|
464585
|
+
* @returns Promise<any[]> 查询结果
|
|
464586
|
+
*/
|
|
464587
|
+
async getFeaturesByIDs(featureIds, options = {}) {
|
|
464588
|
+
const config = this.config;
|
|
464589
|
+
if (!config.url) {
|
|
464590
|
+
console.warn("SuperMap图层缺少服务URL,无法进行要素查询");
|
|
464591
|
+
return [];
|
|
464592
|
+
}
|
|
464593
|
+
const { datasetNames, returnContent = true, targetProjection } = options;
|
|
464594
|
+
try {
|
|
464595
|
+
const serviceUrl = this.buildDataServiceUrl(config.url);
|
|
464596
|
+
console.log(`开始SuperMap ID查询:`, {
|
|
464597
|
+
featureIds,
|
|
464598
|
+
serviceUrl
|
|
464599
|
+
});
|
|
464600
|
+
const idsParams = new GetFeaturesByIDsParameters({
|
|
464601
|
+
datasetNames: datasetNames || this.extractDatasetNames(config.url),
|
|
464602
|
+
IDs: featureIds,
|
|
464603
|
+
returnContent
|
|
464604
|
+
});
|
|
464605
|
+
const idsService = new GetFeaturesByIDsService(serviceUrl);
|
|
464606
|
+
return new Promise((resolve, reject2) => {
|
|
464607
|
+
idsService.getFeaturesByIDs(idsParams, (serviceResult) => {
|
|
464608
|
+
var _a3;
|
|
464609
|
+
if (serviceResult.type === "processCompleted") {
|
|
464610
|
+
const result = serviceResult.result;
|
|
464611
|
+
if (result && result.features) {
|
|
464612
|
+
console.log(
|
|
464613
|
+
`SuperMap ID查询成功,找到 ${result.features.length} 个要素`
|
|
464614
|
+
);
|
|
464615
|
+
resolve(result.features);
|
|
464616
|
+
} else {
|
|
464617
|
+
console.log("SuperMap ID查询完成,但未找到要素");
|
|
464618
|
+
resolve([]);
|
|
464619
|
+
}
|
|
464620
|
+
} else {
|
|
464621
|
+
console.error("SuperMap ID查询失败:", serviceResult.error);
|
|
464622
|
+
reject2(new Error(((_a3 = serviceResult.error) == null ? void 0 : _a3.errorMsg) || "ID查询失败"));
|
|
464623
|
+
}
|
|
464624
|
+
});
|
|
464625
|
+
});
|
|
464626
|
+
} catch (error2) {
|
|
464627
|
+
console.error("SuperMap ID查询异常:", error2);
|
|
464628
|
+
return [];
|
|
464629
|
+
}
|
|
464630
|
+
}
|
|
464631
|
+
/**
|
|
464632
|
+
* 构建数据服务URL
|
|
464633
|
+
* @param mapUrl 地图服务URL
|
|
464634
|
+
* @returns 数据服务URL
|
|
464635
|
+
*/
|
|
464636
|
+
buildDataServiceUrl(mapUrl) {
|
|
464637
|
+
try {
|
|
464638
|
+
const url = new URL(mapUrl);
|
|
464639
|
+
if (url.pathname.includes("/rest/data")) {
|
|
464640
|
+
console.log(`已经是数据服务URL: ${mapUrl}`);
|
|
464641
|
+
return mapUrl;
|
|
464642
|
+
}
|
|
464643
|
+
if (url.pathname.includes("/rest/maps/")) {
|
|
464644
|
+
const dataServiceUrl = mapUrl.replace(
|
|
464645
|
+
/\/rest\/maps\/.*$/,
|
|
464646
|
+
"/rest/data"
|
|
464647
|
+
);
|
|
464648
|
+
console.log(`构建数据服务URL: ${mapUrl} -> ${dataServiceUrl}`);
|
|
464649
|
+
return dataServiceUrl;
|
|
464650
|
+
}
|
|
464651
|
+
const pathParts = url.pathname.split("/").filter((part) => part);
|
|
464652
|
+
const servicesIndex = pathParts.findIndex((part) => part === "services");
|
|
464653
|
+
if (servicesIndex !== -1 && servicesIndex + 1 < pathParts.length) {
|
|
464654
|
+
const serviceName = pathParts[servicesIndex + 1];
|
|
464655
|
+
const basePath = pathParts.slice(0, servicesIndex + 2).join("/");
|
|
464656
|
+
const dataServiceUrl = `${url.protocol}//${url.host}/${basePath}/rest/data`;
|
|
464657
|
+
console.log(
|
|
464658
|
+
`从服务名称构建数据服务URL: ${mapUrl} -> ${dataServiceUrl}`
|
|
464659
|
+
);
|
|
464660
|
+
return dataServiceUrl;
|
|
464661
|
+
}
|
|
464662
|
+
throw new Error(`无法解析SuperMap服务URL格式: ${mapUrl}`);
|
|
464663
|
+
} catch (error2) {
|
|
464664
|
+
console.error("构建数据服务URL失败:", error2);
|
|
464665
|
+
return mapUrl;
|
|
464666
|
+
}
|
|
464667
|
+
}
|
|
464668
|
+
/**
|
|
464669
|
+
* 从地图服务URL中提取数据集名称
|
|
464670
|
+
* @param mapUrl 地图服务URL
|
|
464671
|
+
* @returns 数据集名称数组
|
|
464672
|
+
*/
|
|
464673
|
+
extractDatasetNames(mapUrl) {
|
|
464674
|
+
try {
|
|
464675
|
+
const url = new URL(mapUrl);
|
|
464676
|
+
const pathParts = url.pathname.split("/").filter((part) => part);
|
|
464677
|
+
const mapsIndex = pathParts.findIndex((part) => part === "maps");
|
|
464678
|
+
if (mapsIndex !== -1 && mapsIndex + 1 < pathParts.length) {
|
|
464679
|
+
const mapName = pathParts[mapsIndex + 1];
|
|
464680
|
+
console.log(`从URL提取到地图名称: ${mapName}`);
|
|
464681
|
+
return [mapName];
|
|
464682
|
+
}
|
|
464683
|
+
const config = this.config;
|
|
464684
|
+
if (config.datasetNames && Array.isArray(config.datasetNames)) {
|
|
464685
|
+
console.log(`使用配置中的数据集名称: ${config.datasetNames}`);
|
|
464686
|
+
return config.datasetNames;
|
|
464687
|
+
}
|
|
464688
|
+
console.warn("无法确定数据集名称,将查询所有可用数据集");
|
|
464689
|
+
return [];
|
|
464690
|
+
} catch (error2) {
|
|
464691
|
+
console.error("提取数据集名称失败:", error2);
|
|
464692
|
+
return [];
|
|
464693
|
+
}
|
|
464694
|
+
}
|
|
464695
|
+
/**
|
|
464696
|
+
* 为popup等功能提供的便捷方法:通过点击坐标获取要素信息
|
|
464697
|
+
* @param coordinate 点击坐标
|
|
464698
|
+
* @param options 查询选项
|
|
464699
|
+
* @returns Promise<any[]> 要素信息数组
|
|
464700
|
+
*/
|
|
464701
|
+
async getFeatureInfoAtCoordinate(coordinate, options = {}) {
|
|
464702
|
+
var _a3, _b3, _c2, _d, _e2, _f;
|
|
464703
|
+
const {
|
|
464704
|
+
bufferDistance = 100,
|
|
464705
|
+
maxFeatures = options.featureCount || 10,
|
|
464706
|
+
queryMethod
|
|
464707
|
+
} = options;
|
|
464708
|
+
try {
|
|
464709
|
+
let features2 = [];
|
|
464710
|
+
const finalQueryMethod = queryMethod || ((_a3 = this.config.supermapConfig) == null ? void 0 : _a3.queryMethod) || "point";
|
|
464711
|
+
console.log(`使用查询方式: ${finalQueryMethod}`);
|
|
464712
|
+
if (finalQueryMethod === "buffer") {
|
|
464713
|
+
const configuredBufferDistance = ((_b3 = this.config.supermapConfig) == null ? void 0 : _b3.bufferDistance) || bufferDistance;
|
|
464714
|
+
features2 = await this.getFeaturesByBuffer(
|
|
464715
|
+
coordinate[0],
|
|
464716
|
+
coordinate[1],
|
|
464717
|
+
{
|
|
464718
|
+
bufferDistance: configuredBufferDistance / 1e3,
|
|
464719
|
+
// 转换为度数单位
|
|
464720
|
+
datasetNames: (_c2 = this.config.supermapConfig) == null ? void 0 : _c2.datasetNames,
|
|
464721
|
+
serviceUrl: (_d = this.config.supermapConfig) == null ? void 0 : _d.featureServiceUrl
|
|
464722
|
+
}
|
|
464723
|
+
);
|
|
464724
|
+
} else {
|
|
464725
|
+
features2 = await this.queryFeatureByPointOL(
|
|
464726
|
+
coordinate[0],
|
|
464727
|
+
coordinate[1],
|
|
464728
|
+
{
|
|
464729
|
+
datasetNames: (_e2 = this.config.supermapConfig) == null ? void 0 : _e2.datasetNames,
|
|
464730
|
+
serviceUrl: (_f = this.config.supermapConfig) == null ? void 0 : _f.featureServiceUrl
|
|
464731
|
+
// tolerance 参数已移除,使用默认值
|
|
464732
|
+
}
|
|
464733
|
+
);
|
|
464734
|
+
}
|
|
464735
|
+
return features2.slice(0, maxFeatures).map((feature2) => {
|
|
464736
|
+
const properties = feature2.getProperties() || {};
|
|
464737
|
+
feature2.setProperties({
|
|
464738
|
+
...properties,
|
|
464739
|
+
layerId: this.config.id,
|
|
464740
|
+
layerName: this.config.name,
|
|
464741
|
+
layerType: "supermap-rest"
|
|
464742
|
+
});
|
|
464743
|
+
return feature2;
|
|
464744
|
+
});
|
|
464745
|
+
} catch (error2) {
|
|
464746
|
+
console.error("获取要素信息失败:", error2);
|
|
464747
|
+
return [];
|
|
464748
|
+
}
|
|
464749
|
+
}
|
|
463829
464750
|
}
|
|
463830
464751
|
class CanvasLayerHandler extends BaseLayer$2 {
|
|
463831
464752
|
constructor() {
|
|
@@ -463978,7 +464899,7 @@ ${this.attributes_.map(
|
|
|
463978
464899
|
* 更新图层配置
|
|
463979
464900
|
*/
|
|
463980
464901
|
updateLayerConfig(config) {
|
|
463981
|
-
super.
|
|
464902
|
+
super.updateConfig(config);
|
|
463982
464903
|
if (config.canvasConfig) {
|
|
463983
464904
|
this.updateCanvasConfig(config.canvasConfig);
|
|
463984
464905
|
}
|
|
@@ -464697,176 +465618,6 @@ ${this.attributes_.map(
|
|
|
464697
465618
|
getLayerHandler(layerId) {
|
|
464698
465619
|
return this.layerHandlers.get(layerId);
|
|
464699
465620
|
}
|
|
464700
|
-
/**
|
|
464701
|
-
* 根据坐标获取图层要素信息(用于tooltip)
|
|
464702
|
-
*/
|
|
464703
|
-
async getFeatureInfoAtCoordinate(coordinate, options = {}) {
|
|
464704
|
-
const results = [];
|
|
464705
|
-
const { layers, infoFormat = "application/json", featureCount = 10 } = options;
|
|
464706
|
-
const view = this.map.getView();
|
|
464707
|
-
const resolution = view.getResolution();
|
|
464708
|
-
const projection2 = view.getProjection();
|
|
464709
|
-
for (const [layerId, config] of this.layerConfigs) {
|
|
464710
|
-
if (!config.visible)
|
|
464711
|
-
continue;
|
|
464712
|
-
if (layers && layers.length > 0 && !layers.includes(layerId)) {
|
|
464713
|
-
continue;
|
|
464714
|
-
}
|
|
464715
|
-
const handler = this.layerHandlers.get(layerId);
|
|
464716
|
-
if (!handler)
|
|
464717
|
-
continue;
|
|
464718
|
-
try {
|
|
464719
|
-
const featureInfoConfig = config.featureInfo;
|
|
464720
|
-
if (featureInfoConfig == null ? void 0 : featureInfoConfig.enabled) {
|
|
464721
|
-
if (featureInfoConfig.customApi) {
|
|
464722
|
-
try {
|
|
464723
|
-
const customApi = featureInfoConfig.customApi;
|
|
464724
|
-
const requestUrl = customApi.url;
|
|
464725
|
-
const method2 = customApi.method || "GET";
|
|
464726
|
-
const requestParams = {};
|
|
464727
|
-
if (customApi.params) {
|
|
464728
|
-
if (customApi.params.coordinate) {
|
|
464729
|
-
requestParams[customApi.params.coordinate] = coordinate;
|
|
464730
|
-
}
|
|
464731
|
-
if (customApi.params.layer) {
|
|
464732
|
-
requestParams[customApi.params.layer] = layerId;
|
|
464733
|
-
}
|
|
464734
|
-
Object.keys(customApi.params).forEach((key2) => {
|
|
464735
|
-
if (key2 !== "coordinate" && key2 !== "layer") {
|
|
464736
|
-
requestParams[key2] = customApi.params[key2];
|
|
464737
|
-
}
|
|
464738
|
-
});
|
|
464739
|
-
}
|
|
464740
|
-
const requestOptions = {
|
|
464741
|
-
method: method2,
|
|
464742
|
-
headers: {
|
|
464743
|
-
"Content-Type": "application/json"
|
|
464744
|
-
}
|
|
464745
|
-
};
|
|
464746
|
-
let finalUrl = requestUrl;
|
|
464747
|
-
if (method2.toUpperCase() === "POST") {
|
|
464748
|
-
requestOptions.body = JSON.stringify(requestParams);
|
|
464749
|
-
} else {
|
|
464750
|
-
const urlParams = new URLSearchParams();
|
|
464751
|
-
Object.keys(requestParams).forEach((key2) => {
|
|
464752
|
-
if (Array.isArray(requestParams[key2])) {
|
|
464753
|
-
urlParams.append(key2, requestParams[key2].join(","));
|
|
464754
|
-
} else {
|
|
464755
|
-
urlParams.append(key2, String(requestParams[key2]));
|
|
464756
|
-
}
|
|
464757
|
-
});
|
|
464758
|
-
finalUrl = `${requestUrl}?${urlParams.toString()}`;
|
|
464759
|
-
}
|
|
464760
|
-
const response = await fetch(finalUrl, requestOptions);
|
|
464761
|
-
if (response.ok) {
|
|
464762
|
-
let data2 = await response.json();
|
|
464763
|
-
if (customApi.responseHandler) {
|
|
464764
|
-
try {
|
|
464765
|
-
const handlerFunc = new Function("data", `return (${customApi.responseHandler})(data)`);
|
|
464766
|
-
data2 = handlerFunc(data2);
|
|
464767
|
-
} catch (error2) {
|
|
464768
|
-
console.warn("自定义响应处理函数执行失败:", error2);
|
|
464769
|
-
}
|
|
464770
|
-
}
|
|
464771
|
-
const features2 = Array.isArray(data2) ? data2 : data2.features || [];
|
|
464772
|
-
if (features2.length > 0) {
|
|
464773
|
-
results.push({
|
|
464774
|
-
layerId,
|
|
464775
|
-
layerName: config.name,
|
|
464776
|
-
features: features2
|
|
464777
|
-
});
|
|
464778
|
-
continue;
|
|
464779
|
-
}
|
|
464780
|
-
}
|
|
464781
|
-
} catch (error2) {
|
|
464782
|
-
console.warn(`自定义接口查询失败 (${layerId}):`, error2);
|
|
464783
|
-
}
|
|
464784
|
-
}
|
|
464785
|
-
}
|
|
464786
|
-
if (config.type === "wms" || config.type === "tile") {
|
|
464787
|
-
const layer2 = handler.getLayer();
|
|
464788
|
-
const source = layer2.getSource();
|
|
464789
|
-
if (source && typeof source.getFeatureInfoUrl === "function") {
|
|
464790
|
-
const featureInfoParams = {
|
|
464791
|
-
"INFO_FORMAT": infoFormat,
|
|
464792
|
-
"FEATURE_COUNT": featureCount,
|
|
464793
|
-
...(featureInfoConfig == null ? void 0 : featureInfoConfig.params) || {}
|
|
464794
|
-
};
|
|
464795
|
-
const url = source.getFeatureInfoUrl(
|
|
464796
|
-
coordinate,
|
|
464797
|
-
resolution,
|
|
464798
|
-
projection2,
|
|
464799
|
-
featureInfoParams
|
|
464800
|
-
);
|
|
464801
|
-
if (url) {
|
|
464802
|
-
const response = await fetch(url);
|
|
464803
|
-
if (response.ok) {
|
|
464804
|
-
const data2 = await response.json();
|
|
464805
|
-
if (data2.features && data2.features.length > 0) {
|
|
464806
|
-
results.push({
|
|
464807
|
-
layerId,
|
|
464808
|
-
layerName: config.name,
|
|
464809
|
-
features: data2.features
|
|
464810
|
-
});
|
|
464811
|
-
}
|
|
464812
|
-
}
|
|
464813
|
-
}
|
|
464814
|
-
}
|
|
464815
|
-
} else if (config.type === "wmts") {
|
|
464816
|
-
if (featureInfoConfig == null ? void 0 : featureInfoConfig.enabled) {
|
|
464817
|
-
}
|
|
464818
|
-
} else if (config.type === "vector") {
|
|
464819
|
-
if (featureInfoConfig == null ? void 0 : featureInfoConfig.enabled) {
|
|
464820
|
-
const layer2 = handler.getLayer();
|
|
464821
|
-
const pixel = this.map.getPixelFromCoordinate(coordinate);
|
|
464822
|
-
const features2 = [];
|
|
464823
|
-
this.map.forEachFeatureAtPixel(pixel, (feature2) => {
|
|
464824
|
-
features2.push({
|
|
464825
|
-
properties: feature2.getProperties(),
|
|
464826
|
-
geometry: feature2.getGeometry()
|
|
464827
|
-
});
|
|
464828
|
-
}, { layerFilter: (l2) => l2 === layer2 });
|
|
464829
|
-
if (features2.length > 0) {
|
|
464830
|
-
results.push({
|
|
464831
|
-
layerId,
|
|
464832
|
-
layerName: config.name,
|
|
464833
|
-
features: features2
|
|
464834
|
-
});
|
|
464835
|
-
}
|
|
464836
|
-
}
|
|
464837
|
-
} else if (config.type === "heatmap") {
|
|
464838
|
-
if (featureInfoConfig == null ? void 0 : featureInfoConfig.enabled) {
|
|
464839
|
-
const layer2 = handler.getLayer();
|
|
464840
|
-
const source = layer2.getSource();
|
|
464841
|
-
if (source && typeof source.getFeatures === "function") {
|
|
464842
|
-
const pixel = this.map.getPixelFromCoordinate(coordinate);
|
|
464843
|
-
const features2 = [];
|
|
464844
|
-
this.map.forEachFeatureAtPixel(pixel, (feature2) => {
|
|
464845
|
-
features2.push({
|
|
464846
|
-
properties: feature2.getProperties(),
|
|
464847
|
-
geometry: feature2.getGeometry()
|
|
464848
|
-
});
|
|
464849
|
-
}, { layerFilter: (l2) => l2 === layer2 });
|
|
464850
|
-
if (features2.length > 0) {
|
|
464851
|
-
results.push({
|
|
464852
|
-
layerId,
|
|
464853
|
-
layerName: config.name,
|
|
464854
|
-
features: features2
|
|
464855
|
-
});
|
|
464856
|
-
}
|
|
464857
|
-
}
|
|
464858
|
-
}
|
|
464859
|
-
} else if (["bing", "google", "arcgis", "mapbox", "xyz", "webgl", "canvas", "graticule"].includes(config.type)) {
|
|
464860
|
-
if (featureInfoConfig == null ? void 0 : featureInfoConfig.enabled) {
|
|
464861
|
-
console.log(`图层类型 ${config.type} 需要配置自定义接口来支持要素查询`);
|
|
464862
|
-
}
|
|
464863
|
-
}
|
|
464864
|
-
} catch (error2) {
|
|
464865
|
-
console.warn(`获取图层 ${layerId} 要素信息失败:`, error2);
|
|
464866
|
-
}
|
|
464867
|
-
}
|
|
464868
|
-
return results;
|
|
464869
|
-
}
|
|
464870
465621
|
/**
|
|
464871
465622
|
* 设置图层可见性(支持按需加载)
|
|
464872
465623
|
*/
|
|
@@ -465166,6 +465917,98 @@ ${this.attributes_.map(
|
|
|
465166
465917
|
return false;
|
|
465167
465918
|
}
|
|
465168
465919
|
}
|
|
465920
|
+
/**
|
|
465921
|
+
* 根据坐标获取图层要素信息(用于tooltip)
|
|
465922
|
+
*/
|
|
465923
|
+
async getFeatureInfoAtCoordinate(coordinate, options) {
|
|
465924
|
+
try {
|
|
465925
|
+
const results = [];
|
|
465926
|
+
const targetLayers = (options == null ? void 0 : options.layers) || Array.from(this.layerHandlers.keys());
|
|
465927
|
+
for (const layerId of targetLayers) {
|
|
465928
|
+
const handler = this.layerHandlers.get(layerId);
|
|
465929
|
+
const config = this.layerConfigs.get(layerId);
|
|
465930
|
+
if (!handler || !config || !config.visible) {
|
|
465931
|
+
continue;
|
|
465932
|
+
}
|
|
465933
|
+
try {
|
|
465934
|
+
if (config.type === "TileSuperMapRest" || config.type === "tilesupermaprest" || config.type === "TILESUPERMAPREST") {
|
|
465935
|
+
if ("getFeatureInfoAtCoordinate" in handler) {
|
|
465936
|
+
const features2 = await handler.getFeatureInfoAtCoordinate(
|
|
465937
|
+
coordinate,
|
|
465938
|
+
{
|
|
465939
|
+
bufferDistance: 80,
|
|
465940
|
+
// 默认5米缓冲区
|
|
465941
|
+
maxFeatures: (options == null ? void 0 : options.featureCount) || 10,
|
|
465942
|
+
returnContent: true
|
|
465943
|
+
}
|
|
465944
|
+
);
|
|
465945
|
+
if (features2 && features2.length > 0) {
|
|
465946
|
+
results.push({
|
|
465947
|
+
layerId,
|
|
465948
|
+
layerName: config.name,
|
|
465949
|
+
layerType: config.type,
|
|
465950
|
+
features: features2
|
|
465951
|
+
});
|
|
465952
|
+
}
|
|
465953
|
+
}
|
|
465954
|
+
} else if (config.type === "wms" || config.type === "WMS") {
|
|
465955
|
+
if ("getFeatureInfoAtCoordinate" in handler) {
|
|
465956
|
+
const features2 = await handler.getFeatureInfoAtCoordinate(
|
|
465957
|
+
coordinate,
|
|
465958
|
+
{
|
|
465959
|
+
infoFormat: (options == null ? void 0 : options.infoFormat) || "application/json",
|
|
465960
|
+
featureCount: (options == null ? void 0 : options.featureCount) || 10
|
|
465961
|
+
}
|
|
465962
|
+
);
|
|
465963
|
+
if (features2 && features2.length > 0) {
|
|
465964
|
+
results.push({
|
|
465965
|
+
layerId,
|
|
465966
|
+
layerName: config.name,
|
|
465967
|
+
layerType: config.type,
|
|
465968
|
+
features: features2
|
|
465969
|
+
});
|
|
465970
|
+
}
|
|
465971
|
+
}
|
|
465972
|
+
} else if (config.type === "vector" || config.type === "geojson") {
|
|
465973
|
+
const layer2 = handler.getLayer();
|
|
465974
|
+
if (layer2 && "getSource" in layer2) {
|
|
465975
|
+
const source = layer2.getSource();
|
|
465976
|
+
if (source && "getFeaturesAtCoordinate" in source) {
|
|
465977
|
+
const features2 = source.getFeaturesAtCoordinate(coordinate);
|
|
465978
|
+
if (features2 && features2.length > 0) {
|
|
465979
|
+
const processedFeatures = features2.slice(0, (options == null ? void 0 : options.featureCount) || 10).map((feature2) => {
|
|
465980
|
+
const properties = feature2.getProperties ? feature2.getProperties() : {};
|
|
465981
|
+
const enhancedProperties = {
|
|
465982
|
+
...properties,
|
|
465983
|
+
layerId,
|
|
465984
|
+
layerName: config.name,
|
|
465985
|
+
layerType: config.type
|
|
465986
|
+
};
|
|
465987
|
+
if (feature2.setProperties) {
|
|
465988
|
+
feature2.setProperties(enhancedProperties);
|
|
465989
|
+
}
|
|
465990
|
+
return feature2;
|
|
465991
|
+
});
|
|
465992
|
+
results.push({
|
|
465993
|
+
layerId,
|
|
465994
|
+
layerName: config.name,
|
|
465995
|
+
layerType: config.type,
|
|
465996
|
+
features: processedFeatures
|
|
465997
|
+
});
|
|
465998
|
+
}
|
|
465999
|
+
}
|
|
466000
|
+
}
|
|
466001
|
+
}
|
|
466002
|
+
} catch (error2) {
|
|
466003
|
+
console.warn(`图层 ${layerId} 要素查询失败:`, error2);
|
|
466004
|
+
}
|
|
466005
|
+
}
|
|
466006
|
+
return results;
|
|
466007
|
+
} catch (error2) {
|
|
466008
|
+
console.error("获取要素信息失败:", error2);
|
|
466009
|
+
return [];
|
|
466010
|
+
}
|
|
466011
|
+
}
|
|
465169
466012
|
/**
|
|
465170
466013
|
* 销毁图层管理器
|
|
465171
466014
|
*/
|
|
@@ -465680,21 +466523,24 @@ ${this.attributes_.map(
|
|
|
465680
466523
|
}
|
|
465681
466524
|
if (this.layerManager) {
|
|
465682
466525
|
try {
|
|
465683
|
-
const
|
|
465684
|
-
|
|
465685
|
-
|
|
465686
|
-
|
|
465687
|
-
const feature2 = wmsLayerData.features[0];
|
|
465688
|
-
const layer2 = {
|
|
465689
|
-
layerId: wmsLayerData.layerId,
|
|
465690
|
-
layerName: wmsLayerData.layerName
|
|
465691
|
-
};
|
|
465692
|
-
this.emit("feature-click", feature2, layer2, lonLatCoordinate);
|
|
465693
|
-
return;
|
|
466526
|
+
const featureInfoResults = await this.layerManager.getFeatureInfoAtCoordinate(
|
|
466527
|
+
lonLatCoordinate,
|
|
466528
|
+
{
|
|
466529
|
+
featureCount: 10
|
|
465694
466530
|
}
|
|
466531
|
+
);
|
|
466532
|
+
if (featureInfoResults && featureInfoResults.length > 0) {
|
|
466533
|
+
const tooltipData = featureInfoResults.map((result) => ({
|
|
466534
|
+
layerId: result.layerId,
|
|
466535
|
+
layerName: result.layerName,
|
|
466536
|
+
features: result.features,
|
|
466537
|
+
coordinate: lonLatCoordinate
|
|
466538
|
+
}));
|
|
466539
|
+
this.emit("feature-info", tooltipData);
|
|
466540
|
+
return;
|
|
465695
466541
|
}
|
|
465696
466542
|
} catch (error2) {
|
|
465697
|
-
console.warn("
|
|
466543
|
+
console.warn("查询图层要素信息失败:", error2);
|
|
465698
466544
|
}
|
|
465699
466545
|
}
|
|
465700
466546
|
this.emit("map-click", {
|
|
@@ -465945,7 +466791,7 @@ ${this.attributes_.map(
|
|
|
465945
466791
|
if (!this.map)
|
|
465946
466792
|
return;
|
|
465947
466793
|
this.map.on("singleclick", async (evt) => {
|
|
465948
|
-
var _a3, _b3, _c2
|
|
466794
|
+
var _a3, _b3, _c2;
|
|
465949
466795
|
const coordinate = evt.coordinate;
|
|
465950
466796
|
const pixel = evt.pixel;
|
|
465951
466797
|
const view = this.map.getView();
|
|
@@ -465977,24 +466823,7 @@ ${this.attributes_.map(
|
|
|
465977
466823
|
}
|
|
465978
466824
|
(_b3 = callbacks.onFeatureClick) == null ? void 0 : _b3.call(callbacks, feature2, layer2, lonLatCoordinate, mapCoordinate);
|
|
465979
466825
|
} else {
|
|
465980
|
-
|
|
465981
|
-
const wmsFeatures = await this.layerManager.getFeatureInfoAtCoordinate(coordinate);
|
|
465982
|
-
if (wmsFeatures.length > 0) {
|
|
465983
|
-
const wmsLayerData = wmsFeatures[0];
|
|
465984
|
-
if (wmsLayerData.features && wmsLayerData.features.length > 0) {
|
|
465985
|
-
const feature2 = wmsLayerData.features[0];
|
|
465986
|
-
const layer2 = {
|
|
465987
|
-
layerId: wmsLayerData.layerId,
|
|
465988
|
-
layerName: wmsLayerData.layerName
|
|
465989
|
-
};
|
|
465990
|
-
(_c2 = callbacks.onFeatureClick) == null ? void 0 : _c2.call(callbacks, feature2, layer2, lonLatCoordinate, mapCoordinate);
|
|
465991
|
-
return;
|
|
465992
|
-
}
|
|
465993
|
-
}
|
|
465994
|
-
} catch (error2) {
|
|
465995
|
-
console.warn("WMS GetFeatureInfo request failed:", error2);
|
|
465996
|
-
}
|
|
465997
|
-
(_d = callbacks.onMapClick) == null ? void 0 : _d.call(callbacks, {
|
|
466826
|
+
(_c2 = callbacks.onMapClick) == null ? void 0 : _c2.call(callbacks, {
|
|
465998
466827
|
coordinate: lonLatCoordinate,
|
|
465999
466828
|
mapCoordinate,
|
|
466000
466829
|
pixel,
|
|
@@ -466124,7 +466953,7 @@ ${this.attributes_.map(
|
|
|
466124
466953
|
loading: { type: Boolean, default: false },
|
|
466125
466954
|
userMarkers: {}
|
|
466126
466955
|
},
|
|
466127
|
-
emits: ["map-ready", "map-click", "map-dblclick", "map-contextmenu", "map-move", "zoom-change"],
|
|
466956
|
+
emits: ["map-ready", "map-click", "map-dblclick", "map-contextmenu", "map-move", "zoom-change", "feature-info"],
|
|
466128
466957
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
466129
466958
|
const props = __props;
|
|
466130
466959
|
const emit = __emit;
|
|
@@ -466211,6 +467040,9 @@ ${this.attributes_.map(
|
|
|
466211
467040
|
emit("map-contextmenu", { coordinate, pixel });
|
|
466212
467041
|
}
|
|
466213
467042
|
});
|
|
467043
|
+
mapManager.value.on("feature-info", (data2) => {
|
|
467044
|
+
emit("feature-info", data2);
|
|
467045
|
+
});
|
|
466214
467046
|
};
|
|
466215
467047
|
const updateMapConfig = (config) => {
|
|
466216
467048
|
if (!map2.value)
|
|
@@ -466275,7 +467107,7 @@ ${this.attributes_.map(
|
|
|
466275
467107
|
};
|
|
466276
467108
|
}
|
|
466277
467109
|
});
|
|
466278
|
-
const
|
|
467110
|
+
const MapContainer_vue_vue_type_style_index_0_scoped_9900e920_lang = "";
|
|
466279
467111
|
const _export_sfc = (sfc, props) => {
|
|
466280
467112
|
const target = sfc.__vccOpts || sfc;
|
|
466281
467113
|
for (const [key2, val] of props) {
|
|
@@ -466283,7 +467115,7 @@ ${this.attributes_.map(
|
|
|
466283
467115
|
}
|
|
466284
467116
|
return target;
|
|
466285
467117
|
};
|
|
466286
|
-
const MapContainer = /* @__PURE__ */ _export_sfc(_sfc_main$q, [["__scopeId", "data-v-
|
|
467118
|
+
const MapContainer = /* @__PURE__ */ _export_sfc(_sfc_main$q, [["__scopeId", "data-v-9900e920"]]);
|
|
466287
467119
|
const _hoisted_1$n = ["href"];
|
|
466288
467120
|
const _sfc_main$p = /* @__PURE__ */ vue.defineComponent({
|
|
466289
467121
|
__name: "index",
|
|
@@ -476240,6 +477072,10 @@ ${this.attributes_.map(
|
|
|
476240
477072
|
};
|
|
476241
477073
|
const initializeLayerManager = () => {
|
|
476242
477074
|
if (layerManager.value) {
|
|
477075
|
+
if (map2.value && layerManager.value) {
|
|
477076
|
+
layerTreeManager.initialize(map2.value, layerManager.value);
|
|
477077
|
+
layerConfigManager.initialize(layerManager.value);
|
|
477078
|
+
}
|
|
476243
477079
|
vue.nextTick(() => {
|
|
476244
477080
|
if (layerManager.value) {
|
|
476245
477081
|
layerManager.value.setLayersZIndexByOrder(1, 1);
|
|
@@ -476560,10 +477396,6 @@ ${this.attributes_.map(
|
|
|
476560
477396
|
});
|
|
476561
477397
|
};
|
|
476562
477398
|
vue.onMounted(() => {
|
|
476563
|
-
if (map2.value && layerManager.value) {
|
|
476564
|
-
layerTreeManager.initialize(map2.value, layerManager.value);
|
|
476565
|
-
layerConfigManager.initialize(layerManager.value);
|
|
476566
|
-
}
|
|
476567
477399
|
layerEventBus.on("basemap-changed", handleBasemapChanged);
|
|
476568
477400
|
layerEventBus.on("basemap-switch-request", handleBasemapSwitchRequest);
|
|
476569
477401
|
});
|
|
@@ -476704,8 +477536,8 @@ ${this.attributes_.map(
|
|
|
476704
477536
|
};
|
|
476705
477537
|
}
|
|
476706
477538
|
});
|
|
476707
|
-
const
|
|
476708
|
-
const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-
|
|
477539
|
+
const LayerPanel_vue_vue_type_style_index_0_scoped_6929b38c_lang = "";
|
|
477540
|
+
const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-6929b38c"]]);
|
|
476709
477541
|
const _hoisted_1$4 = {
|
|
476710
477542
|
key: 2,
|
|
476711
477543
|
class: "tooltip-content"
|
|
@@ -476978,6 +477810,12 @@ ${this.attributes_.map(
|
|
|
476978
477810
|
if (props.config.maxHeight) {
|
|
476979
477811
|
style.maxHeight = typeof props.config.maxHeight === "number" ? `${props.config.maxHeight}px` : props.config.maxHeight;
|
|
476980
477812
|
}
|
|
477813
|
+
if (props.config.vertical) {
|
|
477814
|
+
style.display = "flex";
|
|
477815
|
+
style.flexDirection = "column";
|
|
477816
|
+
style.minWidth = "200px";
|
|
477817
|
+
style.maxWidth = style.maxWidth || "300px";
|
|
477818
|
+
}
|
|
476981
477819
|
return style;
|
|
476982
477820
|
});
|
|
476983
477821
|
const handleClose = () => {
|
|
@@ -477033,21 +477871,28 @@ ${this.attributes_.map(
|
|
|
477033
477871
|
class: vue.normalizeClass([
|
|
477034
477872
|
"ol-popup",
|
|
477035
477873
|
`ol-popup-${position2.value}`,
|
|
477874
|
+
{ "ol-popup-vertical": _ctx.config.vertical },
|
|
477036
477875
|
_ctx.config.className
|
|
477037
477876
|
]),
|
|
477038
|
-
style: vue.normalizeStyle(popupStyle.value)
|
|
477877
|
+
style: vue.normalizeStyle(popupStyle.value),
|
|
477878
|
+
onClick: _cache[0] || (_cache[0] = vue.withModifiers(() => {
|
|
477879
|
+
}, ["stop"])),
|
|
477880
|
+
onMousedown: _cache[1] || (_cache[1] = vue.withModifiers(() => {
|
|
477881
|
+
}, ["stop"])),
|
|
477882
|
+
onMouseup: _cache[2] || (_cache[2] = vue.withModifiers(() => {
|
|
477883
|
+
}, ["stop"]))
|
|
477039
477884
|
}, [
|
|
477040
|
-
_cache[
|
|
477885
|
+
_cache[5] || (_cache[5] = vue.createElementVNode("div", { class: "ol-popup-tip" }, null, -1)),
|
|
477041
477886
|
_ctx.config.showCloseButton !== false ? (vue.openBlock(), vue.createBlock(vue.unref(ElButton), {
|
|
477042
477887
|
key: 0,
|
|
477043
477888
|
class: "ol-popup-closer",
|
|
477044
|
-
onClick: handleClose,
|
|
477889
|
+
onClick: vue.withModifiers(handleClose, ["stop"]),
|
|
477045
477890
|
title: "关闭",
|
|
477046
477891
|
text: "",
|
|
477047
477892
|
circle: "",
|
|
477048
477893
|
size: "small"
|
|
477049
477894
|
}, {
|
|
477050
|
-
default: vue.withCtx(() => [..._cache[
|
|
477895
|
+
default: vue.withCtx(() => [..._cache[3] || (_cache[3] = [
|
|
477051
477896
|
vue.createTextVNode(" × ", -1)
|
|
477052
477897
|
])]),
|
|
477053
477898
|
_: 1
|
|
@@ -477062,17 +477907,17 @@ ${this.attributes_.map(
|
|
|
477062
477907
|
coordinate: _ctx.coordinate,
|
|
477063
477908
|
config: _ctx.config
|
|
477064
477909
|
}, () => [
|
|
477065
|
-
_cache[
|
|
477910
|
+
_cache[4] || (_cache[4] = vue.createElementVNode("div", { class: "ol-popup-default" }, [
|
|
477066
477911
|
vue.createElementVNode("p", null, "请提供 popup 内容")
|
|
477067
477912
|
], -1))
|
|
477068
477913
|
], true)
|
|
477069
477914
|
], 512)
|
|
477070
|
-
],
|
|
477915
|
+
], 38)) : vue.createCommentVNode("", true);
|
|
477071
477916
|
};
|
|
477072
477917
|
}
|
|
477073
477918
|
});
|
|
477074
|
-
const
|
|
477075
|
-
const BasePopup = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-
|
|
477919
|
+
const BasePopup_vue_vue_type_style_index_0_scoped_9a5b6333_lang = "";
|
|
477920
|
+
const BasePopup = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-9a5b6333"]]);
|
|
477076
477921
|
const _hoisted_1$3 = { class: "html-popup-content" };
|
|
477077
477922
|
const _hoisted_2$3 = {
|
|
477078
477923
|
key: 0,
|
|
@@ -477883,8 +478728,8 @@ ${this.attributes_.map(
|
|
|
477883
478728
|
};
|
|
477884
478729
|
}
|
|
477885
478730
|
});
|
|
477886
|
-
const
|
|
477887
|
-
const ArrayPopup = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
478731
|
+
const ArrayPopup_vue_vue_type_style_index_0_scoped_4a372183_lang = "";
|
|
478732
|
+
const ArrayPopup = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-4a372183"]]);
|
|
477888
478733
|
class PopupManager {
|
|
477889
478734
|
constructor(map2, config = {}) {
|
|
477890
478735
|
__publicField(this, "map");
|
|
@@ -477896,6 +478741,11 @@ ${this.attributes_.map(
|
|
|
477896
478741
|
maxPopups: 5,
|
|
477897
478742
|
autoClose: true,
|
|
477898
478743
|
closeOnMapClick: true,
|
|
478744
|
+
defaultConfig: {
|
|
478745
|
+
vertical: true,
|
|
478746
|
+
maxHeight: 300,
|
|
478747
|
+
...config.defaultConfig
|
|
478748
|
+
},
|
|
477899
478749
|
...config
|
|
477900
478750
|
};
|
|
477901
478751
|
if (this.config.closeOnMapClick) {
|
|
@@ -478020,7 +478870,7 @@ ${this.attributes_.map(
|
|
|
478020
478870
|
switch (type) {
|
|
478021
478871
|
case "html":
|
|
478022
478872
|
app = vue.createApp(HtmlPopup, {
|
|
478023
|
-
config,
|
|
478873
|
+
config: { ...this.config.defaultConfig, ...config },
|
|
478024
478874
|
coordinate,
|
|
478025
478875
|
feature: feature2,
|
|
478026
478876
|
visible: true,
|
|
@@ -478029,7 +478879,7 @@ ${this.attributes_.map(
|
|
|
478029
478879
|
break;
|
|
478030
478880
|
case "image":
|
|
478031
478881
|
app = vue.createApp(ImagePopup, {
|
|
478032
|
-
config,
|
|
478882
|
+
config: { ...this.config.defaultConfig, ...config },
|
|
478033
478883
|
coordinate,
|
|
478034
478884
|
feature: feature2,
|
|
478035
478885
|
visible: true,
|
|
@@ -478038,7 +478888,7 @@ ${this.attributes_.map(
|
|
|
478038
478888
|
break;
|
|
478039
478889
|
case "array":
|
|
478040
478890
|
app = vue.createApp(ArrayPopup, {
|
|
478041
|
-
config,
|
|
478891
|
+
config: { ...this.config.defaultConfig, ...config },
|
|
478042
478892
|
coordinate,
|
|
478043
478893
|
feature: feature2,
|
|
478044
478894
|
visible: true,
|
|
@@ -478565,9 +479415,113 @@ ${this.attributes_.map(
|
|
|
478565
479415
|
emit("zoom-change", zoom, oldZoom);
|
|
478566
479416
|
};
|
|
478567
479417
|
const onFeatureInfo = (data2) => {
|
|
478568
|
-
|
|
479418
|
+
if (data2 && data2.length > 0) {
|
|
479419
|
+
const firstResult = data2[0];
|
|
479420
|
+
const { layerId, layerName, features: features2, coordinate } = firstResult;
|
|
479421
|
+
if (features2 && features2.length > 0) {
|
|
479422
|
+
const feature2 = features2[0];
|
|
479423
|
+
const layerInfo = {
|
|
479424
|
+
layerId,
|
|
479425
|
+
layerName
|
|
479426
|
+
};
|
|
479427
|
+
emit("feature-click", feature2, layerInfo, coordinate);
|
|
479428
|
+
if (popupManager.value) {
|
|
479429
|
+
const allLayers = [...finalMapConfig.value.baseLayers || [], ...finalMapConfig.value.overlayLayers || [], ...finalMapConfig.value.vectorLayers || []];
|
|
479430
|
+
const targetLayer = allLayers.find((l2) => l2.id === layerId || l2.name === layerName);
|
|
479431
|
+
if (targetLayer && targetLayer.popup) {
|
|
479432
|
+
const popupConfig = targetLayer.popup;
|
|
479433
|
+
console.log("显示SuperMap图层popup:", { layerId, layerName, feature: feature2, coordinate });
|
|
479434
|
+
let properties = feature2.properties || feature2;
|
|
479435
|
+
let content2 = {};
|
|
479436
|
+
if (popupConfig.fields && Array.isArray(popupConfig.fields)) {
|
|
479437
|
+
popupConfig.fields.forEach((field) => {
|
|
479438
|
+
if (typeof field === "string") {
|
|
479439
|
+
content2[field] = properties[field] || "--";
|
|
479440
|
+
} else if (field.name) {
|
|
479441
|
+
const displayName = field.label || field.name;
|
|
479442
|
+
content2[displayName] = properties[field.name] || "--";
|
|
479443
|
+
}
|
|
479444
|
+
});
|
|
479445
|
+
} else {
|
|
479446
|
+
content2 = properties;
|
|
479447
|
+
}
|
|
479448
|
+
const getPopupType = (config) => {
|
|
479449
|
+
if (config.type) {
|
|
479450
|
+
return config.type;
|
|
479451
|
+
}
|
|
479452
|
+
if (config.fields && Array.isArray(config.fields)) {
|
|
479453
|
+
return "array";
|
|
479454
|
+
}
|
|
479455
|
+
if (config.htmlContent || config.content) {
|
|
479456
|
+
return "html";
|
|
479457
|
+
}
|
|
479458
|
+
if (config.images && Array.isArray(config.images)) {
|
|
479459
|
+
return "image";
|
|
479460
|
+
}
|
|
479461
|
+
return "array";
|
|
479462
|
+
};
|
|
479463
|
+
const popupType = getPopupType(popupConfig);
|
|
479464
|
+
let finalConfig = {
|
|
479465
|
+
title: popupConfig.title || layerName || "要素信息",
|
|
479466
|
+
showCloseButton: true,
|
|
479467
|
+
maxWidth: 300,
|
|
479468
|
+
maxHeight: 400,
|
|
479469
|
+
...popupConfig
|
|
479470
|
+
};
|
|
479471
|
+
switch (popupType) {
|
|
479472
|
+
case "array":
|
|
479473
|
+
finalConfig = {
|
|
479474
|
+
...finalConfig,
|
|
479475
|
+
type: "array",
|
|
479476
|
+
fields: popupConfig.fields || Object.keys(properties).map((key2) => ({ name: key2, label: key2, type: "text" })),
|
|
479477
|
+
data: [properties],
|
|
479478
|
+
vertical: true
|
|
479479
|
+
};
|
|
479480
|
+
break;
|
|
479481
|
+
case "html":
|
|
479482
|
+
finalConfig = {
|
|
479483
|
+
...finalConfig,
|
|
479484
|
+
type: "html",
|
|
479485
|
+
content: popupConfig.htmlContent || popupConfig.content || content2
|
|
479486
|
+
};
|
|
479487
|
+
break;
|
|
479488
|
+
case "image":
|
|
479489
|
+
finalConfig = {
|
|
479490
|
+
...finalConfig,
|
|
479491
|
+
type: "image",
|
|
479492
|
+
images: popupConfig.images || []
|
|
479493
|
+
};
|
|
479494
|
+
break;
|
|
479495
|
+
default:
|
|
479496
|
+
finalConfig = {
|
|
479497
|
+
...finalConfig,
|
|
479498
|
+
htmlContent: content2
|
|
479499
|
+
};
|
|
479500
|
+
break;
|
|
479501
|
+
}
|
|
479502
|
+
showPopup(popupType, finalConfig, coordinate);
|
|
479503
|
+
}
|
|
479504
|
+
}
|
|
479505
|
+
}
|
|
479506
|
+
}
|
|
478569
479507
|
};
|
|
478570
479508
|
const onFeatureClick = (feature2, layer2, clickCoordinate, mapCoordinate) => {
|
|
479509
|
+
let popupConfig = null;
|
|
479510
|
+
const allLayers = [...finalMapConfig.value.baseLayers || [], ...finalMapConfig.value.overlayLayers || [], ...finalMapConfig.value.vectorLayers || []];
|
|
479511
|
+
console.log("点击事件调试信息:");
|
|
479512
|
+
console.log("layer对象:", layer2);
|
|
479513
|
+
console.log("所有图层配置:", allLayers.map((l2) => ({ id: l2.id, name: l2.name, hasPopup: !!l2.popup })));
|
|
479514
|
+
const targetLayer = allLayers.find((l2) => l2.id === layer2.values_.layerId || l2.name === layer2.layerName);
|
|
479515
|
+
console.log("匹配到的图层:", targetLayer);
|
|
479516
|
+
if (targetLayer && targetLayer.popup) {
|
|
479517
|
+
popupConfig = targetLayer.popup;
|
|
479518
|
+
console.log("找到popup配置:", popupConfig);
|
|
479519
|
+
}
|
|
479520
|
+
if (!popupConfig) {
|
|
479521
|
+
console.log("没有找到popup配置,跳过显示");
|
|
479522
|
+
emit("feature-click", feature2, layer2, clickCoordinate);
|
|
479523
|
+
return;
|
|
479524
|
+
}
|
|
478571
479525
|
if (feature2 && layer2 && popupManager.value && clickCoordinate) {
|
|
478572
479526
|
const coordinate = mapCoordinate || clickCoordinate;
|
|
478573
479527
|
if (coordinate) {
|
|
@@ -478579,22 +479533,20 @@ ${this.attributes_.map(
|
|
|
478579
479533
|
} else {
|
|
478580
479534
|
properties = feature2;
|
|
478581
479535
|
}
|
|
478582
|
-
|
|
478583
|
-
const allLayers = [...finalMapConfig.value.baseLayers || [], ...finalMapConfig.value.overlayLayers || [], ...finalMapConfig.value.vectorLayers || []];
|
|
478584
|
-
const targetLayer = allLayers.find((l2) => l2.id === layer2.layerId || l2.name === layer2.layerName);
|
|
478585
|
-
if (targetLayer && targetLayer.popup) {
|
|
478586
|
-
popupConfig = targetLayer.popup;
|
|
478587
|
-
}
|
|
479536
|
+
const popupType = (popupConfig == null ? void 0 : popupConfig.type) || "array";
|
|
478588
479537
|
if (popupConfig && popupConfig.fields) {
|
|
478589
479538
|
popupManager.value.replacePopup(
|
|
478590
|
-
|
|
479539
|
+
popupType,
|
|
478591
479540
|
{
|
|
478592
|
-
type:
|
|
479541
|
+
type: popupType,
|
|
478593
479542
|
title: (targetLayer == null ? void 0 : targetLayer.name) || layer2.layerName || "要素信息",
|
|
478594
479543
|
fields: popupConfig.fields,
|
|
478595
479544
|
data: [properties],
|
|
478596
479545
|
showCloseButton: true,
|
|
478597
|
-
maxWidth:
|
|
479546
|
+
maxWidth: 300,
|
|
479547
|
+
maxHeight: 400,
|
|
479548
|
+
vertical: true,
|
|
479549
|
+
...popupConfig
|
|
478598
479550
|
},
|
|
478599
479551
|
coordinate,
|
|
478600
479552
|
feature2
|
|
@@ -478603,14 +479555,17 @@ ${this.attributes_.map(
|
|
|
478603
479555
|
const fields = Object.keys(properties).filter((key2) => key2 !== "geometry").map((key2) => ({ name: key2, label: key2, type: "text" }));
|
|
478604
479556
|
if (fields.length > 0) {
|
|
478605
479557
|
popupManager.value.replacePopup(
|
|
478606
|
-
|
|
479558
|
+
popupType,
|
|
478607
479559
|
{
|
|
478608
|
-
type:
|
|
479560
|
+
type: popupType,
|
|
478609
479561
|
title: layer2.layerName || "要素信息",
|
|
478610
479562
|
fields,
|
|
478611
479563
|
data: [properties],
|
|
478612
479564
|
showCloseButton: true,
|
|
478613
|
-
maxWidth:
|
|
479565
|
+
maxWidth: 300,
|
|
479566
|
+
maxHeight: 400,
|
|
479567
|
+
vertical: true,
|
|
479568
|
+
...popupConfig
|
|
478614
479569
|
},
|
|
478615
479570
|
coordinate,
|
|
478616
479571
|
feature2
|
|
@@ -479364,8 +480319,8 @@ ${this.attributes_.map(
|
|
|
479364
480319
|
};
|
|
479365
480320
|
}
|
|
479366
480321
|
});
|
|
479367
|
-
const
|
|
479368
|
-
const CustomOpenlayer = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
480322
|
+
const index_vue_vue_type_style_index_0_scoped_78070f98_lang = "";
|
|
480323
|
+
const CustomOpenlayer = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-78070f98"]]);
|
|
479369
480324
|
const base = "";
|
|
479370
480325
|
var u8 = Uint8Array, u16 = Uint16Array, i32 = Int32Array;
|
|
479371
480326
|
var fleb = new u8([
|