vue-openlayers-plugin 1.0.49 → 1.0.50
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-2dac53c6.mjs → index-dd9c537c.mjs} +424 -45
- package/lib/{index.es-a3c51163.mjs → index.es-86beb4f4.mjs} +1 -1
- package/lib/index.esm.js +1 -1
- package/lib/index.umd.js +425 -46
- package/lib/style.css +5 -5
- package/package.json +1 -1
- package/types/src/components/CustomOpenlayer/components/MapContainer.vue.d.ts +5 -2
- package/types/src/components/CustomOpenlayer/components/MapContainer.vue.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/components/MapSearch/MapSearch.vue.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/index.vue.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/services/searchService.d.ts +16 -2
- package/types/src/components/CustomOpenlayer/services/searchService.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/types/index.d.ts +9 -1
- package/types/src/components/CustomOpenlayer/types/index.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/utils/layers/GeoJSONLayerHandler.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/utils/mapManager.d.ts +4 -0
- package/types/src/components/CustomOpenlayer/utils/mapManager.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/utils/styles/StyleManager.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/utils/styles/interfaces.d.ts +4 -0
- package/types/src/components/CustomOpenlayer/utils/styles/interfaces.d.ts.map +1 -1
package/lib/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z, B, d, C, D, a2, a3, u, y, a7, a6, I, H, Z, $, L, J, K, a4, h, M, a0, a1, X, Y, U, W, Q, S, P, A, F, G, N, O, a8, e, T, E, V, x, j, o, t, f, k, g, w, q, m, n, a5, i, s, l, v } from "./index-
|
|
1
|
+
import { z, B, d, C, D, a2, a3, u, y, a7, a6, I, H, Z, $, L, J, K, a4, h, M, a0, a1, X, Y, U, W, Q, S, P, A, F, G, N, O, a8, e, T, E, V, x, j, o, t, f, k, g, w, q, m, n, a5, i, s, l, v } from "./index-dd9c537c.mjs";
|
|
2
2
|
import "vue";
|
|
3
3
|
import "ol";
|
|
4
4
|
export {
|
package/lib/index.umd.js
CHANGED
|
@@ -83299,6 +83299,7 @@ ${this.attributes_.map(
|
|
|
83299
83299
|
const textStyle = new Text$5({
|
|
83300
83300
|
text: config.text,
|
|
83301
83301
|
font: config.font || `${config.fontSize || 12}px ${config.fontFamily || "Arial"}`,
|
|
83302
|
+
scale: config.scale,
|
|
83302
83303
|
fill: this.createFill(config.fill),
|
|
83303
83304
|
stroke: this.createStroke(config.stroke),
|
|
83304
83305
|
offsetX: config.offsetX,
|
|
@@ -83306,6 +83307,10 @@ ${this.attributes_.map(
|
|
|
83306
83307
|
textAlign: config.textAlign,
|
|
83307
83308
|
textBaseline: config.textBaseline,
|
|
83308
83309
|
rotation: config.rotation,
|
|
83310
|
+
rotateWithView: config.rotateWithView,
|
|
83311
|
+
maxAngle: config.maxAngle,
|
|
83312
|
+
placement: config.placement,
|
|
83313
|
+
overflow: config.overflow,
|
|
83309
83314
|
backgroundFill: this.createFill(config.backgroundFill),
|
|
83310
83315
|
backgroundStroke: this.createStroke(config.backgroundStroke),
|
|
83311
83316
|
padding: config.padding
|
|
@@ -83405,7 +83410,8 @@ ${this.attributes_.map(
|
|
|
83405
83410
|
});
|
|
83406
83411
|
}
|
|
83407
83412
|
if (config == null ? void 0 : config.text) {
|
|
83408
|
-
|
|
83413
|
+
const textCfg = { placement: "line", overflow: true, ...config.text };
|
|
83414
|
+
styleOptions.text = this.createText(textCfg);
|
|
83409
83415
|
}
|
|
83410
83416
|
return new Style$3(styleOptions);
|
|
83411
83417
|
}
|
|
@@ -83613,10 +83619,27 @@ ${this.attributes_.map(
|
|
|
83613
83619
|
*/
|
|
83614
83620
|
createStyleFunction(styleConfig) {
|
|
83615
83621
|
return (feature2, resolution) => {
|
|
83622
|
+
var _a3, _b3;
|
|
83616
83623
|
const geometryType = StyleFactory.getFeatureGeometryType(feature2);
|
|
83617
83624
|
const defaultConfig = this.getDefaultStyle(geometryType);
|
|
83618
83625
|
const customConfig = styleConfig == null ? void 0 : styleConfig[geometryType];
|
|
83619
83626
|
const finalConfig = this.mergeStyleConfig(defaultConfig, customConfig);
|
|
83627
|
+
if (finalConfig && finalConfig.text) {
|
|
83628
|
+
const textCfg = { ...finalConfig.text };
|
|
83629
|
+
let content2 = textCfg.text;
|
|
83630
|
+
if (!content2 && typeof textCfg.field === "string") {
|
|
83631
|
+
const v5 = (_a3 = feature2 == null ? void 0 : feature2.get) == null ? void 0 : _a3.call(feature2, textCfg.field);
|
|
83632
|
+
content2 = v5 !== void 0 && v5 !== null ? String(v5) : "";
|
|
83633
|
+
}
|
|
83634
|
+
if (typeof textCfg.template === "string" && textCfg.template.length > 0) {
|
|
83635
|
+
const props = ((_b3 = feature2 == null ? void 0 : feature2.getProperties) == null ? void 0 : _b3.call(feature2)) || {};
|
|
83636
|
+
content2 = textCfg.template.replace(/\{([^}]+)\}/g, (_m, key2) => {
|
|
83637
|
+
const v5 = props[key2];
|
|
83638
|
+
return v5 !== void 0 && v5 !== null ? String(v5) : "";
|
|
83639
|
+
});
|
|
83640
|
+
}
|
|
83641
|
+
finalConfig.text = { ...textCfg, text: content2 };
|
|
83642
|
+
}
|
|
83620
83643
|
return StyleFactory.createStyleByGeometryType(geometryType, finalConfig);
|
|
83621
83644
|
};
|
|
83622
83645
|
}
|
|
@@ -83702,11 +83725,15 @@ ${this.attributes_.map(
|
|
|
83702
83725
|
__publicField(this, "styleConfig");
|
|
83703
83726
|
}
|
|
83704
83727
|
createLayer() {
|
|
83728
|
+
var _a3, _b3, _c2;
|
|
83705
83729
|
const vectorSource = this.createVectorSource();
|
|
83730
|
+
const declutterOpt = (_c2 = (_b3 = (_a3 = this.config) == null ? void 0 : _a3.config) == null ? void 0 : _b3.vector) == null ? void 0 : _c2.declutter;
|
|
83706
83731
|
const vectorLayer = new VectorLayer$3({
|
|
83707
83732
|
className: this.config.className,
|
|
83708
83733
|
source: vectorSource,
|
|
83709
|
-
style: this.createStyleFunction()
|
|
83734
|
+
style: this.createStyleFunction(),
|
|
83735
|
+
// 默认关闭 declutter;如需避免标签重叠,可在 config.vector.declutter 设为 true
|
|
83736
|
+
declutter: declutterOpt !== void 0 ? !!declutterOpt : false
|
|
83710
83737
|
});
|
|
83711
83738
|
return vectorLayer;
|
|
83712
83739
|
}
|
|
@@ -83721,14 +83748,34 @@ ${this.attributes_.map(
|
|
|
83721
83748
|
const features2 = format2.readFeatures(this.config.data, {
|
|
83722
83749
|
featureProjection: mapProjection
|
|
83723
83750
|
});
|
|
83751
|
+
if (features2 && features2.length > 0) {
|
|
83752
|
+
try {
|
|
83753
|
+
console.log("[GeoJSONLayerHandler] 示例要素属性:", features2[0].getProperties());
|
|
83754
|
+
} catch (e3) {
|
|
83755
|
+
}
|
|
83756
|
+
}
|
|
83724
83757
|
return new VectorSource$2({ features: features2 });
|
|
83725
83758
|
} else if (this.config.url) {
|
|
83726
|
-
|
|
83759
|
+
const source = new VectorSource$2({
|
|
83727
83760
|
url: this.config.url,
|
|
83728
83761
|
format: new GeoJSON$4({
|
|
83729
83762
|
featureProjection: mapProjection
|
|
83730
83763
|
})
|
|
83731
83764
|
});
|
|
83765
|
+
try {
|
|
83766
|
+
const logOnce = (e3) => {
|
|
83767
|
+
var _a4, _b3;
|
|
83768
|
+
try {
|
|
83769
|
+
const props = ((_b3 = (_a4 = e3.feature) == null ? void 0 : _a4.getProperties) == null ? void 0 : _b3.call(_a4)) || {};
|
|
83770
|
+
console.log("[GeoJSONLayerHandler] addfeature 属性示例:", props);
|
|
83771
|
+
} catch (_2) {
|
|
83772
|
+
}
|
|
83773
|
+
source.un("addfeature", logOnce);
|
|
83774
|
+
};
|
|
83775
|
+
source.on("addfeature", logOnce);
|
|
83776
|
+
} catch (e3) {
|
|
83777
|
+
}
|
|
83778
|
+
return source;
|
|
83732
83779
|
} else {
|
|
83733
83780
|
return new VectorSource$2();
|
|
83734
83781
|
}
|
|
@@ -83738,15 +83785,92 @@ ${this.attributes_.map(
|
|
|
83738
83785
|
*/
|
|
83739
83786
|
createStyleFunction() {
|
|
83740
83787
|
this.parseStyleConfig();
|
|
83741
|
-
|
|
83788
|
+
const baseStyleFn = styleManager.createStyleFunction(this.styleConfig);
|
|
83789
|
+
return (feature2, resolution) => {
|
|
83790
|
+
var _a3, _b3, _c2, _d, _e2, _f;
|
|
83791
|
+
const style = baseStyleFn(feature2, resolution);
|
|
83792
|
+
try {
|
|
83793
|
+
const geometry2 = (_a3 = feature2 == null ? void 0 : feature2.getGeometry) == null ? void 0 : _a3.call(feature2);
|
|
83794
|
+
const geometryType = ((_b3 = geometry2 == null ? void 0 : geometry2.getType) == null ? void 0 : _b3.call(geometry2)) || "Point";
|
|
83795
|
+
const textCfg = (_d = (_c2 = this.styleConfig) == null ? void 0 : _c2[geometryType]) == null ? void 0 : _d.text;
|
|
83796
|
+
if (textCfg && this.map && typeof this.map.getView === "function") {
|
|
83797
|
+
const z2 = (_f = (_e2 = this.map.getView()).getZoom) == null ? void 0 : _f.call(_e2);
|
|
83798
|
+
if (typeof z2 === "number") {
|
|
83799
|
+
const minZ = textCfg.minZoom;
|
|
83800
|
+
const maxZ = textCfg.maxZoom;
|
|
83801
|
+
const outOfRange = minZ != null && z2 < minZ || maxZ != null && z2 > maxZ;
|
|
83802
|
+
if (outOfRange && typeof style.setText === "function") {
|
|
83803
|
+
style.setText(null);
|
|
83804
|
+
}
|
|
83805
|
+
}
|
|
83806
|
+
}
|
|
83807
|
+
} catch (_2) {
|
|
83808
|
+
}
|
|
83809
|
+
return style;
|
|
83810
|
+
};
|
|
83742
83811
|
}
|
|
83743
83812
|
/**
|
|
83744
83813
|
* 解析样式配置
|
|
83745
83814
|
*/
|
|
83746
83815
|
parseStyleConfig() {
|
|
83816
|
+
var _a3;
|
|
83747
83817
|
if (!this.styleConfig) {
|
|
83748
83818
|
this.styleConfig = {};
|
|
83749
83819
|
}
|
|
83820
|
+
const style = (_a3 = this.config) == null ? void 0 : _a3.style;
|
|
83821
|
+
if (style && typeof style === "object") {
|
|
83822
|
+
const polygonStyle2 = {};
|
|
83823
|
+
if (style.fill)
|
|
83824
|
+
polygonStyle2.fill = style.fill;
|
|
83825
|
+
if (style.stroke)
|
|
83826
|
+
polygonStyle2.stroke = style.stroke;
|
|
83827
|
+
if (style.text)
|
|
83828
|
+
polygonStyle2.text = style.text;
|
|
83829
|
+
if (Object.keys(polygonStyle2).length > 0) {
|
|
83830
|
+
this.styleConfig.Polygon = {
|
|
83831
|
+
...this.styleConfig.Polygon || {},
|
|
83832
|
+
...polygonStyle2
|
|
83833
|
+
};
|
|
83834
|
+
this.styleConfig.MultiPolygon = {
|
|
83835
|
+
...this.styleConfig.MultiPolygon || {},
|
|
83836
|
+
...polygonStyle2
|
|
83837
|
+
};
|
|
83838
|
+
}
|
|
83839
|
+
const lineStyle2 = {};
|
|
83840
|
+
if (style.stroke)
|
|
83841
|
+
lineStyle2.stroke = style.stroke;
|
|
83842
|
+
if (style.text)
|
|
83843
|
+
lineStyle2.text = style.text;
|
|
83844
|
+
if (Object.keys(lineStyle2).length > 0) {
|
|
83845
|
+
this.styleConfig.LineString = {
|
|
83846
|
+
...this.styleConfig.LineString || {},
|
|
83847
|
+
...lineStyle2
|
|
83848
|
+
};
|
|
83849
|
+
this.styleConfig.MultiLineString = {
|
|
83850
|
+
...this.styleConfig.MultiLineString || {},
|
|
83851
|
+
...lineStyle2
|
|
83852
|
+
};
|
|
83853
|
+
}
|
|
83854
|
+
const pointStyle2 = {};
|
|
83855
|
+
if (style.circle)
|
|
83856
|
+
pointStyle2.circle = style.circle;
|
|
83857
|
+
if (style.icon)
|
|
83858
|
+
pointStyle2.icon = style.icon;
|
|
83859
|
+
if (style.regularShape)
|
|
83860
|
+
pointStyle2.regularShape = style.regularShape;
|
|
83861
|
+
if (style.text)
|
|
83862
|
+
pointStyle2.text = style.text;
|
|
83863
|
+
if (Object.keys(pointStyle2).length > 0) {
|
|
83864
|
+
this.styleConfig.Point = {
|
|
83865
|
+
...this.styleConfig.Point || {},
|
|
83866
|
+
...pointStyle2
|
|
83867
|
+
};
|
|
83868
|
+
this.styleConfig.MultiPoint = {
|
|
83869
|
+
...this.styleConfig.MultiPoint || {},
|
|
83870
|
+
...pointStyle2
|
|
83871
|
+
};
|
|
83872
|
+
}
|
|
83873
|
+
}
|
|
83750
83874
|
}
|
|
83751
83875
|
/**
|
|
83752
83876
|
* 转换旧的样式配置为新格式
|
|
@@ -469578,7 +469702,7 @@ ${this.attributes_.map(
|
|
|
469578
469702
|
...this.config.eventManager
|
|
469579
469703
|
};
|
|
469580
469704
|
this.eventManager = new EventManager(this.map, this.layerManager, eventManagerConfig);
|
|
469581
|
-
const
|
|
469705
|
+
const defaultSearchConfig2 = {
|
|
469582
469706
|
enabled: true,
|
|
469583
469707
|
position: "top-left",
|
|
469584
469708
|
placeholder: "搜索地点...",
|
|
@@ -469594,7 +469718,7 @@ ${this.attributes_.map(
|
|
|
469594
469718
|
zoomLevel: 16
|
|
469595
469719
|
}
|
|
469596
469720
|
};
|
|
469597
|
-
this.searchMarkerManager = new SearchMarkerManager(this.map,
|
|
469721
|
+
this.searchMarkerManager = new SearchMarkerManager(this.map, defaultSearchConfig2);
|
|
469598
469722
|
this.featureHighlightManager = new FeatureHighlightManager(this.map);
|
|
469599
469723
|
this.markerAdapter = new MarkerDrawingAdapter(this.map);
|
|
469600
469724
|
this.drawingManager = new DrawingManager({ map: this.map });
|
|
@@ -470040,23 +470164,30 @@ ${this.attributes_.map(
|
|
|
470040
470164
|
* 搜索位置
|
|
470041
470165
|
*/
|
|
470042
470166
|
async searchLocation(query) {
|
|
470167
|
+
var _a3, _b3;
|
|
470043
470168
|
if (!this.searchMarkerManager || !this.map)
|
|
470044
470169
|
return [];
|
|
470045
470170
|
try {
|
|
470046
|
-
const {
|
|
470047
|
-
const
|
|
470048
|
-
if (
|
|
470049
|
-
|
|
470050
|
-
|
|
470051
|
-
|
|
470052
|
-
const
|
|
470053
|
-
|
|
470054
|
-
|
|
470055
|
-
|
|
470056
|
-
|
|
470057
|
-
|
|
470058
|
-
|
|
470059
|
-
|
|
470171
|
+
const { MapSearchService: MapSearchService2, defaultSearchConfig: defaultSearchConfig2 } = await Promise.resolve().then(() => searchService);
|
|
470172
|
+
const searchConfig = ((_b3 = (_a3 = this.config) == null ? void 0 : _a3.controls) == null ? void 0 : _b3.search) ? { ...defaultSearchConfig2, ...this.config.controls.search } : defaultSearchConfig2;
|
|
470173
|
+
if (searchConfig.enabled === false) {
|
|
470174
|
+
return [];
|
|
470175
|
+
}
|
|
470176
|
+
if (searchConfig.provider === "layer") {
|
|
470177
|
+
const layerResults = await this.searchLayersByAttribute(query, searchConfig);
|
|
470178
|
+
if (layerResults && layerResults.length > 0) {
|
|
470179
|
+
this.searchMarkerManager.updateConfig(searchConfig);
|
|
470180
|
+
this.searchMarkerManager.addSearchMarkers(layerResults);
|
|
470181
|
+
this.searchMarkerManager.locateToResult(layerResults[0]);
|
|
470182
|
+
}
|
|
470183
|
+
return layerResults;
|
|
470184
|
+
}
|
|
470185
|
+
const searchService$1 = new MapSearchService2(searchConfig);
|
|
470186
|
+
const results = await searchService$1.search(query);
|
|
470187
|
+
if (results && results.length > 0) {
|
|
470188
|
+
this.searchMarkerManager.updateConfig(searchConfig);
|
|
470189
|
+
this.searchMarkerManager.addSearchMarkers(results);
|
|
470190
|
+
this.searchMarkerManager.locateToResult(results[0]);
|
|
470060
470191
|
}
|
|
470061
470192
|
return results;
|
|
470062
470193
|
} catch (error2) {
|
|
@@ -470064,6 +470195,101 @@ ${this.attributes_.map(
|
|
|
470064
470195
|
throw error2;
|
|
470065
470196
|
}
|
|
470066
470197
|
}
|
|
470198
|
+
/**
|
|
470199
|
+
* 在已加载的矢量图层中按属性搜索
|
|
470200
|
+
*/
|
|
470201
|
+
async searchLayersByAttribute(query, searchConfig) {
|
|
470202
|
+
var _a3, _b3, _c2, _d, _e2, _f;
|
|
470203
|
+
try {
|
|
470204
|
+
if (!this.layerManager || !this.map || !query || query.trim().length < (searchConfig.minSearchLength || 2)) {
|
|
470205
|
+
return [];
|
|
470206
|
+
}
|
|
470207
|
+
const q2 = query.trim().toLowerCase();
|
|
470208
|
+
const results = [];
|
|
470209
|
+
const mapProj = this.map.getView().getProjection();
|
|
470210
|
+
const layerSearch = searchConfig.layerSearch || {};
|
|
470211
|
+
const onlyVisible = layerSearch.onlyVisible ?? true;
|
|
470212
|
+
const targetLayerIds = Array.isArray(layerSearch.layers) ? new Set(layerSearch.layers) : null;
|
|
470213
|
+
const attrKeys = Array.isArray(layerSearch.attributeKeys) ? layerSearch.attributeKeys : void 0;
|
|
470214
|
+
const perLayerLimit = layerSearch.maxPerLayer ?? searchConfig.maxResults ?? 10;
|
|
470215
|
+
const allConfigs = this.layerManager.getAllLayerConfigs();
|
|
470216
|
+
const targetConfigs = allConfigs.filter((cfg) => {
|
|
470217
|
+
if (targetLayerIds && !targetLayerIds.has(cfg.id))
|
|
470218
|
+
return false;
|
|
470219
|
+
if (onlyVisible && cfg.visible === false)
|
|
470220
|
+
return false;
|
|
470221
|
+
const t2 = (cfg.type || "").toLowerCase();
|
|
470222
|
+
return t2 === "vector" || t2 === "geojson" || t2 === "wfs";
|
|
470223
|
+
});
|
|
470224
|
+
for (const cfg of targetConfigs) {
|
|
470225
|
+
const handler = this.layerManager.getLayerHandler(cfg.id);
|
|
470226
|
+
if (!handler)
|
|
470227
|
+
continue;
|
|
470228
|
+
const layer2 = (_a3 = handler.getLayer) == null ? void 0 : _a3.call(handler);
|
|
470229
|
+
if (!layer2 || typeof layer2.getSource !== "function")
|
|
470230
|
+
continue;
|
|
470231
|
+
const source = layer2.getSource();
|
|
470232
|
+
if (!source || typeof source.getFeatures !== "function")
|
|
470233
|
+
continue;
|
|
470234
|
+
const features2 = source.getFeatures() || [];
|
|
470235
|
+
let count2 = 0;
|
|
470236
|
+
for (const feature2 of features2) {
|
|
470237
|
+
if (perLayerLimit && count2 >= perLayerLimit)
|
|
470238
|
+
break;
|
|
470239
|
+
const props = typeof feature2.getProperties === "function" ? feature2.getProperties() : {};
|
|
470240
|
+
const { geometry: geometry2, ...dataProps } = props || {};
|
|
470241
|
+
const keysToCheck = attrKeys && attrKeys.length > 0 ? attrKeys : Object.keys(dataProps).filter((k2) => {
|
|
470242
|
+
const v5 = dataProps[k2];
|
|
470243
|
+
return typeof v5 === "string" || typeof v5 === "number";
|
|
470244
|
+
});
|
|
470245
|
+
let matchedLabel;
|
|
470246
|
+
for (const k2 of keysToCheck) {
|
|
470247
|
+
const v5 = dataProps[k2];
|
|
470248
|
+
if (v5 == null)
|
|
470249
|
+
continue;
|
|
470250
|
+
const s2 = String(v5).toLowerCase();
|
|
470251
|
+
if (s2.includes(q2)) {
|
|
470252
|
+
matchedLabel = String(v5);
|
|
470253
|
+
break;
|
|
470254
|
+
}
|
|
470255
|
+
}
|
|
470256
|
+
if (!matchedLabel)
|
|
470257
|
+
continue;
|
|
470258
|
+
const geom = typeof feature2.getGeometry === "function" ? feature2.getGeometry() : null;
|
|
470259
|
+
if (!geom)
|
|
470260
|
+
continue;
|
|
470261
|
+
let center2;
|
|
470262
|
+
const type = (_b3 = geom.getType) == null ? void 0 : _b3.call(geom);
|
|
470263
|
+
if (type === "Point" && typeof geom.getCoordinates === "function") {
|
|
470264
|
+
center2 = geom.getCoordinates();
|
|
470265
|
+
} else {
|
|
470266
|
+
const extent3 = (_c2 = geom.getExtent) == null ? void 0 : _c2.call(geom);
|
|
470267
|
+
if (!extent3 || extent3.length < 4)
|
|
470268
|
+
continue;
|
|
470269
|
+
center2 = [(extent3[0] + extent3[2]) / 2, (extent3[1] + extent3[3]) / 2];
|
|
470270
|
+
}
|
|
470271
|
+
const [lng, lat2] = toLonLat$1(center2, mapProj);
|
|
470272
|
+
const id2 = String(((_d = feature2.getId) == null ? void 0 : _d.call(feature2)) ?? ((_e2 = feature2.get) == null ? void 0 : _e2.call(feature2, "id")) ?? `${cfg.id}-${results.length + 1}`);
|
|
470273
|
+
results.push({
|
|
470274
|
+
id: id2,
|
|
470275
|
+
name: matchedLabel || cfg.name,
|
|
470276
|
+
address: cfg.name || "",
|
|
470277
|
+
location: [lng, lat2],
|
|
470278
|
+
type: "layer-feature",
|
|
470279
|
+
bounds: (_f = geom.getExtent) == null ? void 0 : _f.call(geom)
|
|
470280
|
+
});
|
|
470281
|
+
count2++;
|
|
470282
|
+
}
|
|
470283
|
+
}
|
|
470284
|
+
if (searchConfig.maxResults && results.length > searchConfig.maxResults) {
|
|
470285
|
+
return results.slice(0, searchConfig.maxResults);
|
|
470286
|
+
}
|
|
470287
|
+
return results;
|
|
470288
|
+
} catch (err2) {
|
|
470289
|
+
console.error("图层属性搜索失败:", err2);
|
|
470290
|
+
return [];
|
|
470291
|
+
}
|
|
470292
|
+
}
|
|
470067
470293
|
/**
|
|
470068
470294
|
* 清除搜索标记
|
|
470069
470295
|
*/
|
|
@@ -470213,6 +470439,10 @@ ${this.attributes_.map(
|
|
|
470213
470439
|
});
|
|
470214
470440
|
};
|
|
470215
470441
|
const updateMapConfig = (config) => {
|
|
470442
|
+
if (mapManager.value) {
|
|
470443
|
+
mapManager.value.updateConfig(config);
|
|
470444
|
+
return;
|
|
470445
|
+
}
|
|
470216
470446
|
if (!map2.value)
|
|
470217
470447
|
return;
|
|
470218
470448
|
const view = map2.value.getView();
|
|
@@ -470235,6 +470465,27 @@ ${this.attributes_.map(
|
|
|
470235
470465
|
width: typeof props.width === "number" ? `${props.width}px` : props.width,
|
|
470236
470466
|
height: typeof props.height === "number" ? `${props.height}px` : props.height
|
|
470237
470467
|
}));
|
|
470468
|
+
const handleSearch = async (query) => {
|
|
470469
|
+
if (!mapManager.value)
|
|
470470
|
+
return;
|
|
470471
|
+
try {
|
|
470472
|
+
await mapManager.value.searchLocation(query);
|
|
470473
|
+
} catch (error2) {
|
|
470474
|
+
console.error("处理搜索失败:", error2);
|
|
470475
|
+
}
|
|
470476
|
+
};
|
|
470477
|
+
const handleSearchSelect = (result) => {
|
|
470478
|
+
var _a3;
|
|
470479
|
+
const manager = (_a3 = mapManager.value) == null ? void 0 : _a3.getSearchMarkerManager();
|
|
470480
|
+
if (manager) {
|
|
470481
|
+
manager.locateToResult(result);
|
|
470482
|
+
}
|
|
470483
|
+
};
|
|
470484
|
+
const handleSearchClear = () => {
|
|
470485
|
+
if (mapManager.value) {
|
|
470486
|
+
mapManager.value.clearSearchMarkers();
|
|
470487
|
+
}
|
|
470488
|
+
};
|
|
470238
470489
|
__expose({
|
|
470239
470490
|
getMap: () => map2.value,
|
|
470240
470491
|
getMapManager: () => mapManager.value,
|
|
@@ -470254,7 +470505,11 @@ ${this.attributes_.map(
|
|
|
470254
470505
|
var _a3;
|
|
470255
470506
|
return (_a3 = mapManager.value) == null ? void 0 : _a3.getEventManager();
|
|
470256
470507
|
},
|
|
470257
|
-
updateMapConfig
|
|
470508
|
+
updateMapConfig,
|
|
470509
|
+
// 搜索相关方法
|
|
470510
|
+
handleSearch,
|
|
470511
|
+
handleSearchSelect,
|
|
470512
|
+
handleSearchClear
|
|
470258
470513
|
});
|
|
470259
470514
|
return (_ctx, _cache) => {
|
|
470260
470515
|
const _directive_loading = vue.resolveDirective("loading");
|
|
@@ -470275,8 +470530,8 @@ ${this.attributes_.map(
|
|
|
470275
470530
|
};
|
|
470276
470531
|
}
|
|
470277
470532
|
});
|
|
470278
|
-
const
|
|
470279
|
-
const MapContainer = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["__scopeId", "data-v-
|
|
470533
|
+
const MapContainer_vue_vue_type_style_index_0_scoped_9ef2c9f4_lang = "";
|
|
470534
|
+
const MapContainer = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["__scopeId", "data-v-9ef2c9f4"]]);
|
|
470280
470535
|
const _hoisted_1$k = ["href"];
|
|
470281
470536
|
const _sfc_main$l = /* @__PURE__ */ vue.defineComponent({
|
|
470282
470537
|
__name: "index",
|
|
@@ -477448,19 +477703,16 @@ ${this.attributes_.map(
|
|
|
477448
477703
|
}
|
|
477449
477704
|
}
|
|
477450
477705
|
const tiandituSearchApi = new TiandituSearchApi();
|
|
477451
|
-
const tiandituSearchApi$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
477452
|
-
__proto__: null,
|
|
477453
|
-
TiandituSearchApi,
|
|
477454
|
-
tiandituSearchApi
|
|
477455
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
477456
477706
|
class MapSearchService {
|
|
477457
|
-
|
|
477458
|
-
constructor(config) {
|
|
477707
|
+
constructor(config, deps) {
|
|
477459
477708
|
__publicField(this, "config");
|
|
477460
477709
|
__publicField(this, "cache", /* @__PURE__ */ new Map());
|
|
477461
477710
|
__publicField(this, "cacheExpiry", /* @__PURE__ */ new Map());
|
|
477462
477711
|
__publicField(this, "CACHE_DURATION", 5 * 60 * 1e3);
|
|
477712
|
+
// 5分钟缓存
|
|
477713
|
+
__publicField(this, "layerManager", null);
|
|
477463
477714
|
this.config = config;
|
|
477715
|
+
this.layerManager = (deps == null ? void 0 : deps.layerManager) ?? null;
|
|
477464
477716
|
}
|
|
477465
477717
|
/**
|
|
477466
477718
|
* 搜索地址
|
|
@@ -477491,6 +477743,9 @@ ${this.attributes_.map(
|
|
|
477491
477743
|
case "custom":
|
|
477492
477744
|
results = await this.searchCustom(query);
|
|
477493
477745
|
break;
|
|
477746
|
+
case "layer":
|
|
477747
|
+
results = await this.searchLayer(query);
|
|
477748
|
+
break;
|
|
477494
477749
|
default:
|
|
477495
477750
|
results = await this.searchTianditu(query);
|
|
477496
477751
|
}
|
|
@@ -477665,6 +477920,106 @@ ${this.attributes_.map(
|
|
|
477665
477920
|
throw error2;
|
|
477666
477921
|
}
|
|
477667
477922
|
}
|
|
477923
|
+
/**
|
|
477924
|
+
* 图层属性搜索(本地矢量要素,纯列表,不进行地图操作)
|
|
477925
|
+
*/
|
|
477926
|
+
async searchLayer(query) {
|
|
477927
|
+
var _a3, _b3, _c2, _d;
|
|
477928
|
+
try {
|
|
477929
|
+
if (!this.layerManager) {
|
|
477930
|
+
return [];
|
|
477931
|
+
}
|
|
477932
|
+
const minLen = this.config.minSearchLength || 2;
|
|
477933
|
+
if (!query || query.trim().length < minLen) {
|
|
477934
|
+
return [];
|
|
477935
|
+
}
|
|
477936
|
+
const q2 = query.trim().toLowerCase();
|
|
477937
|
+
const results = [];
|
|
477938
|
+
const layerSearch = this.config.layerSearch || {};
|
|
477939
|
+
const onlyVisible = layerSearch.onlyVisible ?? true;
|
|
477940
|
+
const targetLayerIds = Array.isArray(layerSearch.layers) ? new Set(layerSearch.layers) : null;
|
|
477941
|
+
const attrKeys = Array.isArray(layerSearch.attributeKeys) ? layerSearch.attributeKeys : void 0;
|
|
477942
|
+
const perLayerLimit = layerSearch.maxPerLayer ?? this.config.maxResults ?? 10;
|
|
477943
|
+
const allConfigs = this.layerManager.getAllLayerConfigs();
|
|
477944
|
+
const targetConfigs = allConfigs.filter((cfg) => {
|
|
477945
|
+
if (targetLayerIds && !targetLayerIds.has(cfg.id))
|
|
477946
|
+
return false;
|
|
477947
|
+
if (onlyVisible && cfg.visible === false)
|
|
477948
|
+
return false;
|
|
477949
|
+
const t2 = (cfg.type || "").toLowerCase();
|
|
477950
|
+
return t2 === "vector" || t2 === "geojson" || t2 === "wfs";
|
|
477951
|
+
});
|
|
477952
|
+
for (const cfg of targetConfigs) {
|
|
477953
|
+
const handler = this.layerManager.getLayerHandler(cfg.id);
|
|
477954
|
+
if (!handler)
|
|
477955
|
+
continue;
|
|
477956
|
+
const layer2 = (_a3 = handler.getLayer) == null ? void 0 : _a3.call(handler);
|
|
477957
|
+
if (!layer2 || typeof layer2.getSource !== "function")
|
|
477958
|
+
continue;
|
|
477959
|
+
const source = layer2.getSource();
|
|
477960
|
+
if (!source || typeof source.getFeatures !== "function")
|
|
477961
|
+
continue;
|
|
477962
|
+
const features2 = source.getFeatures() || [];
|
|
477963
|
+
let count2 = 0;
|
|
477964
|
+
for (const feature2 of features2) {
|
|
477965
|
+
if (perLayerLimit && count2 >= perLayerLimit)
|
|
477966
|
+
break;
|
|
477967
|
+
const props = typeof feature2.getProperties === "function" ? feature2.getProperties() : {};
|
|
477968
|
+
const { geometry: geometry2, ...dataProps } = props || {};
|
|
477969
|
+
if (!geometry2 && typeof feature2.getGeometry === "function") {
|
|
477970
|
+
dataProps.geometry = feature2.getGeometry();
|
|
477971
|
+
}
|
|
477972
|
+
const keysToCheck = attrKeys && attrKeys.length > 0 ? attrKeys : Object.keys(dataProps).filter((k2) => {
|
|
477973
|
+
const v5 = dataProps[k2];
|
|
477974
|
+
return typeof v5 === "string" || typeof v5 === "number";
|
|
477975
|
+
});
|
|
477976
|
+
let matchedLabel;
|
|
477977
|
+
for (const k2 of keysToCheck) {
|
|
477978
|
+
const v5 = dataProps[k2];
|
|
477979
|
+
if (v5 == null)
|
|
477980
|
+
continue;
|
|
477981
|
+
const s2 = String(v5).toLowerCase();
|
|
477982
|
+
if (s2.includes(q2)) {
|
|
477983
|
+
matchedLabel = String(v5);
|
|
477984
|
+
break;
|
|
477985
|
+
}
|
|
477986
|
+
}
|
|
477987
|
+
if (!matchedLabel)
|
|
477988
|
+
continue;
|
|
477989
|
+
const geom = typeof feature2.getGeometry === "function" ? feature2.getGeometry() : geometry2;
|
|
477990
|
+
if (!geom)
|
|
477991
|
+
continue;
|
|
477992
|
+
let center2;
|
|
477993
|
+
const type = (_b3 = geom.getType) == null ? void 0 : _b3.call(geom);
|
|
477994
|
+
if (type === "Point" && typeof geom.getCoordinates === "function") {
|
|
477995
|
+
center2 = geom.getCoordinates();
|
|
477996
|
+
} else if (typeof geom.getExtent === "function") {
|
|
477997
|
+
const extent3 = geom.getExtent();
|
|
477998
|
+
if (extent3 && extent3.length >= 4) {
|
|
477999
|
+
center2 = [(extent3[0] + extent3[2]) / 2, (extent3[1] + extent3[3]) / 2];
|
|
478000
|
+
}
|
|
478001
|
+
}
|
|
478002
|
+
const id2 = String(((_c2 = feature2.getId) == null ? void 0 : _c2.call(feature2)) ?? ((_d = feature2.get) == null ? void 0 : _d.call(feature2, "id")) ?? `${cfg.id}-${results.length + 1}`);
|
|
478003
|
+
results.push({
|
|
478004
|
+
id: id2,
|
|
478005
|
+
name: matchedLabel || cfg.name,
|
|
478006
|
+
address: cfg.name || "",
|
|
478007
|
+
location: center2 || [0, 0],
|
|
478008
|
+
type: "layer-feature",
|
|
478009
|
+
bounds: typeof geom.getExtent === "function" ? geom.getExtent() : void 0
|
|
478010
|
+
});
|
|
478011
|
+
count2++;
|
|
478012
|
+
}
|
|
478013
|
+
}
|
|
478014
|
+
if (this.config.maxResults && results.length > this.config.maxResults) {
|
|
478015
|
+
return results.slice(0, this.config.maxResults);
|
|
478016
|
+
}
|
|
478017
|
+
return results;
|
|
478018
|
+
} catch (error2) {
|
|
478019
|
+
console.error("图层属性搜索失败:", error2);
|
|
478020
|
+
return [];
|
|
478021
|
+
}
|
|
478022
|
+
}
|
|
477668
478023
|
/**
|
|
477669
478024
|
* 解析百度地图结果
|
|
477670
478025
|
*/
|
|
@@ -477777,7 +478132,34 @@ ${this.attributes_.map(
|
|
|
477777
478132
|
this.config = config;
|
|
477778
478133
|
this.clearCache();
|
|
477779
478134
|
}
|
|
478135
|
+
/**
|
|
478136
|
+
* 设置图层管理器(用于图层搜索)
|
|
478137
|
+
*/
|
|
478138
|
+
setLayerManager(manager) {
|
|
478139
|
+
this.layerManager = manager ?? null;
|
|
478140
|
+
}
|
|
477780
478141
|
}
|
|
478142
|
+
const defaultSearchConfig = {
|
|
478143
|
+
enabled: true,
|
|
478144
|
+
position: "top-left",
|
|
478145
|
+
placeholder: "搜索地点...",
|
|
478146
|
+
provider: "tianditu",
|
|
478147
|
+
maxResults: 10,
|
|
478148
|
+
showHistory: true,
|
|
478149
|
+
searchDelay: 300,
|
|
478150
|
+
minSearchLength: 2,
|
|
478151
|
+
resultStyle: {
|
|
478152
|
+
markerColor: "#409eff",
|
|
478153
|
+
markerSize: 20,
|
|
478154
|
+
highlightColor: "#67c23a",
|
|
478155
|
+
zoomLevel: 16
|
|
478156
|
+
}
|
|
478157
|
+
};
|
|
478158
|
+
const searchService = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
478159
|
+
__proto__: null,
|
|
478160
|
+
MapSearchService,
|
|
478161
|
+
defaultSearchConfig
|
|
478162
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
477781
478163
|
const _hoisted_1$7 = { class: "search-input-wrapper" };
|
|
477782
478164
|
const _hoisted_2$7 = { class: "search-results" };
|
|
477783
478165
|
const _hoisted_3$7 = {
|
|
@@ -477834,7 +478216,8 @@ ${this.attributes_.map(
|
|
|
477834
478216
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
477835
478217
|
const props = __props;
|
|
477836
478218
|
const emit = __emit;
|
|
477837
|
-
const
|
|
478219
|
+
const injectedLayerManager = vue.inject("layerManager");
|
|
478220
|
+
const searchService2 = new MapSearchService(props.config, { layerManager: (injectedLayerManager == null ? void 0 : injectedLayerManager.value) || null });
|
|
477838
478221
|
const searchQuery = vue.ref("");
|
|
477839
478222
|
const searchResults = vue.ref([]);
|
|
477840
478223
|
const searchHistory = vue.ref([]);
|
|
@@ -477936,7 +478319,7 @@ ${this.attributes_.map(
|
|
|
477936
478319
|
isLoading.value = true;
|
|
477937
478320
|
showResults.value = true;
|
|
477938
478321
|
try {
|
|
477939
|
-
const results = await
|
|
478322
|
+
const results = await searchService2.search(query);
|
|
477940
478323
|
searchResults.value = results;
|
|
477941
478324
|
emit("search", query);
|
|
477942
478325
|
} catch (error2) {
|
|
@@ -478033,13 +478416,20 @@ ${this.attributes_.map(
|
|
|
478033
478416
|
vue.watch(
|
|
478034
478417
|
() => props.config,
|
|
478035
478418
|
(newConfig) => {
|
|
478036
|
-
|
|
478419
|
+
searchService2.updateConfig(newConfig);
|
|
478037
478420
|
searchResults.value = [];
|
|
478038
478421
|
selectedIndex.value = -1;
|
|
478039
478422
|
console.log("MapSearch配置已更新:", newConfig);
|
|
478040
478423
|
},
|
|
478041
478424
|
{ deep: true }
|
|
478042
478425
|
);
|
|
478426
|
+
vue.watch(
|
|
478427
|
+
() => injectedLayerManager == null ? void 0 : injectedLayerManager.value,
|
|
478428
|
+
(lm) => {
|
|
478429
|
+
searchService2.setLayerManager(lm || null);
|
|
478430
|
+
},
|
|
478431
|
+
{ immediate: true }
|
|
478432
|
+
);
|
|
478043
478433
|
__expose({
|
|
478044
478434
|
updateResults,
|
|
478045
478435
|
clearResults,
|
|
@@ -482017,23 +482407,12 @@ ${this.attributes_.map(
|
|
|
482017
482407
|
});
|
|
482018
482408
|
};
|
|
482019
482409
|
const onSearch = (query) => {
|
|
482020
|
-
debugger;
|
|
482021
|
-
if (mapContainerRef.value && mapContainerRef.value.handleSearch) {
|
|
482022
|
-
mapContainerRef.value.handleSearch(query);
|
|
482023
|
-
}
|
|
482024
482410
|
emit("search", query);
|
|
482025
482411
|
};
|
|
482026
482412
|
const onSearchSelect = (result) => {
|
|
482027
|
-
if (mapContainerRef.value && mapContainerRef.value.handleSearchSelect) {
|
|
482028
|
-
mapContainerRef.value.handleSearchSelect(result);
|
|
482029
|
-
}
|
|
482030
|
-
debugger;
|
|
482031
482413
|
emit("search-select", result);
|
|
482032
482414
|
};
|
|
482033
482415
|
const onSearchClear = () => {
|
|
482034
|
-
if (mapContainerRef.value && mapContainerRef.value.handleSearchClear) {
|
|
482035
|
-
mapContainerRef.value.handleSearchClear();
|
|
482036
|
-
}
|
|
482037
482416
|
emit("search-clear");
|
|
482038
482417
|
};
|
|
482039
482418
|
const onLayerChange = (layer2) => {
|
|
@@ -482662,8 +483041,8 @@ ${this.attributes_.map(
|
|
|
482662
483041
|
};
|
|
482663
483042
|
}
|
|
482664
483043
|
});
|
|
482665
|
-
const
|
|
482666
|
-
const CustomOpenlayer = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
483044
|
+
const index_vue_vue_type_style_index_0_scoped_c8137b4e_lang = "";
|
|
483045
|
+
const CustomOpenlayer = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c8137b4e"]]);
|
|
482667
483046
|
const base = "";
|
|
482668
483047
|
var u8 = Uint8Array, u16 = Uint16Array, i32 = Int32Array;
|
|
482669
483048
|
var fleb = new u8([
|