vue-openlayers-plugin 1.0.49 → 1.0.51
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-0cfcd57c.mjs} +443 -54
- package/lib/{index.es-a3c51163.mjs → index.es-7867bf7f.mjs} +1 -1
- package/lib/index.esm.js +1 -1
- package/lib/index.umd.js +444 -55
- 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
|
@@ -82790,6 +82790,7 @@ class StyleFactory {
|
|
|
82790
82790
|
const textStyle = new Text$5({
|
|
82791
82791
|
text: config.text,
|
|
82792
82792
|
font: config.font || `${config.fontSize || 12}px ${config.fontFamily || "Arial"}`,
|
|
82793
|
+
scale: config.scale,
|
|
82793
82794
|
fill: this.createFill(config.fill),
|
|
82794
82795
|
stroke: this.createStroke(config.stroke),
|
|
82795
82796
|
offsetX: config.offsetX,
|
|
@@ -82797,6 +82798,10 @@ class StyleFactory {
|
|
|
82797
82798
|
textAlign: config.textAlign,
|
|
82798
82799
|
textBaseline: config.textBaseline,
|
|
82799
82800
|
rotation: config.rotation,
|
|
82801
|
+
rotateWithView: config.rotateWithView,
|
|
82802
|
+
maxAngle: config.maxAngle,
|
|
82803
|
+
placement: config.placement,
|
|
82804
|
+
overflow: config.overflow,
|
|
82800
82805
|
backgroundFill: this.createFill(config.backgroundFill),
|
|
82801
82806
|
backgroundStroke: this.createStroke(config.backgroundStroke),
|
|
82802
82807
|
padding: config.padding
|
|
@@ -82896,7 +82901,8 @@ class StyleFactory {
|
|
|
82896
82901
|
});
|
|
82897
82902
|
}
|
|
82898
82903
|
if (config == null ? void 0 : config.text) {
|
|
82899
|
-
|
|
82904
|
+
const textCfg = { placement: "line", overflow: true, ...config.text };
|
|
82905
|
+
styleOptions.text = this.createText(textCfg);
|
|
82900
82906
|
}
|
|
82901
82907
|
return new Style$3(styleOptions);
|
|
82902
82908
|
}
|
|
@@ -83104,10 +83110,27 @@ const _StyleManager = class _StyleManager {
|
|
|
83104
83110
|
*/
|
|
83105
83111
|
createStyleFunction(styleConfig) {
|
|
83106
83112
|
return (feature2, resolution) => {
|
|
83113
|
+
var _a3, _b3;
|
|
83107
83114
|
const geometryType = StyleFactory.getFeatureGeometryType(feature2);
|
|
83108
83115
|
const defaultConfig = this.getDefaultStyle(geometryType);
|
|
83109
83116
|
const customConfig = styleConfig == null ? void 0 : styleConfig[geometryType];
|
|
83110
83117
|
const finalConfig = this.mergeStyleConfig(defaultConfig, customConfig);
|
|
83118
|
+
if (finalConfig && finalConfig.text) {
|
|
83119
|
+
const textCfg = { ...finalConfig.text };
|
|
83120
|
+
let content2 = textCfg.text;
|
|
83121
|
+
if (!content2 && typeof textCfg.field === "string") {
|
|
83122
|
+
const v5 = (_a3 = feature2 == null ? void 0 : feature2.get) == null ? void 0 : _a3.call(feature2, textCfg.field);
|
|
83123
|
+
content2 = v5 !== void 0 && v5 !== null ? String(v5) : "";
|
|
83124
|
+
}
|
|
83125
|
+
if (typeof textCfg.template === "string" && textCfg.template.length > 0) {
|
|
83126
|
+
const props = ((_b3 = feature2 == null ? void 0 : feature2.getProperties) == null ? void 0 : _b3.call(feature2)) || {};
|
|
83127
|
+
content2 = textCfg.template.replace(/\{([^}]+)\}/g, (_m, key) => {
|
|
83128
|
+
const v5 = props[key];
|
|
83129
|
+
return v5 !== void 0 && v5 !== null ? String(v5) : "";
|
|
83130
|
+
});
|
|
83131
|
+
}
|
|
83132
|
+
finalConfig.text = { ...textCfg, text: content2 };
|
|
83133
|
+
}
|
|
83111
83134
|
return StyleFactory.createStyleByGeometryType(geometryType, finalConfig);
|
|
83112
83135
|
};
|
|
83113
83136
|
}
|
|
@@ -83193,11 +83216,15 @@ class GeoJSONLayerHandler extends BaseLayer$2 {
|
|
|
83193
83216
|
__publicField(this, "styleConfig");
|
|
83194
83217
|
}
|
|
83195
83218
|
createLayer() {
|
|
83219
|
+
var _a3, _b3, _c2;
|
|
83196
83220
|
const vectorSource = this.createVectorSource();
|
|
83221
|
+
const declutterOpt = (_c2 = (_b3 = (_a3 = this.config) == null ? void 0 : _a3.config) == null ? void 0 : _b3.vector) == null ? void 0 : _c2.declutter;
|
|
83197
83222
|
const vectorLayer = new VectorLayer$3({
|
|
83198
83223
|
className: this.config.className,
|
|
83199
83224
|
source: vectorSource,
|
|
83200
|
-
style: this.createStyleFunction()
|
|
83225
|
+
style: this.createStyleFunction(),
|
|
83226
|
+
// 默认关闭 declutter;如需避免标签重叠,可在 config.vector.declutter 设为 true
|
|
83227
|
+
declutter: declutterOpt !== void 0 ? !!declutterOpt : false
|
|
83201
83228
|
});
|
|
83202
83229
|
return vectorLayer;
|
|
83203
83230
|
}
|
|
@@ -83212,14 +83239,34 @@ class GeoJSONLayerHandler extends BaseLayer$2 {
|
|
|
83212
83239
|
const features2 = format2.readFeatures(this.config.data, {
|
|
83213
83240
|
featureProjection: mapProjection
|
|
83214
83241
|
});
|
|
83242
|
+
if (features2 && features2.length > 0) {
|
|
83243
|
+
try {
|
|
83244
|
+
console.log("[GeoJSONLayerHandler] 示例要素属性:", features2[0].getProperties());
|
|
83245
|
+
} catch (e8) {
|
|
83246
|
+
}
|
|
83247
|
+
}
|
|
83215
83248
|
return new VectorSource$2({ features: features2 });
|
|
83216
83249
|
} else if (this.config.url) {
|
|
83217
|
-
|
|
83250
|
+
const source = new VectorSource$2({
|
|
83218
83251
|
url: this.config.url,
|
|
83219
83252
|
format: new GeoJSON$4({
|
|
83220
83253
|
featureProjection: mapProjection
|
|
83221
83254
|
})
|
|
83222
83255
|
});
|
|
83256
|
+
try {
|
|
83257
|
+
const logOnce = (e8) => {
|
|
83258
|
+
var _a4, _b3;
|
|
83259
|
+
try {
|
|
83260
|
+
const props = ((_b3 = (_a4 = e8.feature) == null ? void 0 : _a4.getProperties) == null ? void 0 : _b3.call(_a4)) || {};
|
|
83261
|
+
console.log("[GeoJSONLayerHandler] addfeature 属性示例:", props);
|
|
83262
|
+
} catch (_2) {
|
|
83263
|
+
}
|
|
83264
|
+
source.un("addfeature", logOnce);
|
|
83265
|
+
};
|
|
83266
|
+
source.on("addfeature", logOnce);
|
|
83267
|
+
} catch (e8) {
|
|
83268
|
+
}
|
|
83269
|
+
return source;
|
|
83223
83270
|
} else {
|
|
83224
83271
|
return new VectorSource$2();
|
|
83225
83272
|
}
|
|
@@ -83229,15 +83276,92 @@ class GeoJSONLayerHandler extends BaseLayer$2 {
|
|
|
83229
83276
|
*/
|
|
83230
83277
|
createStyleFunction() {
|
|
83231
83278
|
this.parseStyleConfig();
|
|
83232
|
-
|
|
83279
|
+
const baseStyleFn = styleManager.createStyleFunction(this.styleConfig);
|
|
83280
|
+
return (feature2, resolution) => {
|
|
83281
|
+
var _a3, _b3, _c2, _d, _e2, _f;
|
|
83282
|
+
const style = baseStyleFn(feature2, resolution);
|
|
83283
|
+
try {
|
|
83284
|
+
const geometry2 = (_a3 = feature2 == null ? void 0 : feature2.getGeometry) == null ? void 0 : _a3.call(feature2);
|
|
83285
|
+
const geometryType = ((_b3 = geometry2 == null ? void 0 : geometry2.getType) == null ? void 0 : _b3.call(geometry2)) || "Point";
|
|
83286
|
+
const textCfg = (_d = (_c2 = this.styleConfig) == null ? void 0 : _c2[geometryType]) == null ? void 0 : _d.text;
|
|
83287
|
+
if (textCfg && this.map && typeof this.map.getView === "function") {
|
|
83288
|
+
const z2 = (_f = (_e2 = this.map.getView()).getZoom) == null ? void 0 : _f.call(_e2);
|
|
83289
|
+
if (typeof z2 === "number") {
|
|
83290
|
+
const minZ = textCfg.minZoom;
|
|
83291
|
+
const maxZ = textCfg.maxZoom;
|
|
83292
|
+
const outOfRange = minZ != null && z2 < minZ || maxZ != null && z2 > maxZ;
|
|
83293
|
+
if (outOfRange && typeof style.setText === "function") {
|
|
83294
|
+
style.setText(null);
|
|
83295
|
+
}
|
|
83296
|
+
}
|
|
83297
|
+
}
|
|
83298
|
+
} catch (_2) {
|
|
83299
|
+
}
|
|
83300
|
+
return style;
|
|
83301
|
+
};
|
|
83233
83302
|
}
|
|
83234
83303
|
/**
|
|
83235
83304
|
* 解析样式配置
|
|
83236
83305
|
*/
|
|
83237
83306
|
parseStyleConfig() {
|
|
83307
|
+
var _a3;
|
|
83238
83308
|
if (!this.styleConfig) {
|
|
83239
83309
|
this.styleConfig = {};
|
|
83240
83310
|
}
|
|
83311
|
+
const style = (_a3 = this.config) == null ? void 0 : _a3.style;
|
|
83312
|
+
if (style && typeof style === "object") {
|
|
83313
|
+
const polygonStyle2 = {};
|
|
83314
|
+
if (style.fill)
|
|
83315
|
+
polygonStyle2.fill = style.fill;
|
|
83316
|
+
if (style.stroke)
|
|
83317
|
+
polygonStyle2.stroke = style.stroke;
|
|
83318
|
+
if (style.text)
|
|
83319
|
+
polygonStyle2.text = style.text;
|
|
83320
|
+
if (Object.keys(polygonStyle2).length > 0) {
|
|
83321
|
+
this.styleConfig.Polygon = {
|
|
83322
|
+
...this.styleConfig.Polygon || {},
|
|
83323
|
+
...polygonStyle2
|
|
83324
|
+
};
|
|
83325
|
+
this.styleConfig.MultiPolygon = {
|
|
83326
|
+
...this.styleConfig.MultiPolygon || {},
|
|
83327
|
+
...polygonStyle2
|
|
83328
|
+
};
|
|
83329
|
+
}
|
|
83330
|
+
const lineStyle2 = {};
|
|
83331
|
+
if (style.stroke)
|
|
83332
|
+
lineStyle2.stroke = style.stroke;
|
|
83333
|
+
if (style.text)
|
|
83334
|
+
lineStyle2.text = style.text;
|
|
83335
|
+
if (Object.keys(lineStyle2).length > 0) {
|
|
83336
|
+
this.styleConfig.LineString = {
|
|
83337
|
+
...this.styleConfig.LineString || {},
|
|
83338
|
+
...lineStyle2
|
|
83339
|
+
};
|
|
83340
|
+
this.styleConfig.MultiLineString = {
|
|
83341
|
+
...this.styleConfig.MultiLineString || {},
|
|
83342
|
+
...lineStyle2
|
|
83343
|
+
};
|
|
83344
|
+
}
|
|
83345
|
+
const pointStyle2 = {};
|
|
83346
|
+
if (style.circle)
|
|
83347
|
+
pointStyle2.circle = style.circle;
|
|
83348
|
+
if (style.icon)
|
|
83349
|
+
pointStyle2.icon = style.icon;
|
|
83350
|
+
if (style.regularShape)
|
|
83351
|
+
pointStyle2.regularShape = style.regularShape;
|
|
83352
|
+
if (style.text)
|
|
83353
|
+
pointStyle2.text = style.text;
|
|
83354
|
+
if (Object.keys(pointStyle2).length > 0) {
|
|
83355
|
+
this.styleConfig.Point = {
|
|
83356
|
+
...this.styleConfig.Point || {},
|
|
83357
|
+
...pointStyle2
|
|
83358
|
+
};
|
|
83359
|
+
this.styleConfig.MultiPoint = {
|
|
83360
|
+
...this.styleConfig.MultiPoint || {},
|
|
83361
|
+
...pointStyle2
|
|
83362
|
+
};
|
|
83363
|
+
}
|
|
83364
|
+
}
|
|
83241
83365
|
}
|
|
83242
83366
|
/**
|
|
83243
83367
|
* 转换旧的样式配置为新格式
|
|
@@ -83611,16 +83735,20 @@ class GeoJSONLayerHandler extends BaseLayer$2 {
|
|
|
83611
83735
|
parseCQLExpression(cqlExpression) {
|
|
83612
83736
|
const filters = [];
|
|
83613
83737
|
let expression = cqlExpression.trim();
|
|
83614
|
-
|
|
83738
|
+
const stripOuter = (s2) => {
|
|
83739
|
+
if (!(s2.startsWith("(") || s2.startsWith("(")))
|
|
83740
|
+
return s2;
|
|
83741
|
+
const openChar = s2[0];
|
|
83742
|
+
const closeChar = openChar === "(" ? ")" : ")";
|
|
83615
83743
|
let depth = 0;
|
|
83616
83744
|
let wrapsWhole = true;
|
|
83617
|
-
for (let i = 0; i <
|
|
83618
|
-
const ch =
|
|
83619
|
-
if (ch ===
|
|
83745
|
+
for (let i = 0; i < s2.length; i++) {
|
|
83746
|
+
const ch = s2[i];
|
|
83747
|
+
if (ch === openChar)
|
|
83620
83748
|
depth++;
|
|
83621
|
-
else if (ch ===
|
|
83749
|
+
else if (ch === closeChar) {
|
|
83622
83750
|
depth--;
|
|
83623
|
-
if (depth === 0 && i <
|
|
83751
|
+
if (depth === 0 && i < s2.length - 1) {
|
|
83624
83752
|
wrapsWhole = false;
|
|
83625
83753
|
break;
|
|
83626
83754
|
}
|
|
@@ -83631,9 +83759,15 @@ class GeoJSONLayerHandler extends BaseLayer$2 {
|
|
|
83631
83759
|
}
|
|
83632
83760
|
}
|
|
83633
83761
|
if (wrapsWhole && depth === 0) {
|
|
83634
|
-
|
|
83762
|
+
return s2.slice(1, -1).trim();
|
|
83635
83763
|
}
|
|
83636
|
-
|
|
83764
|
+
return s2;
|
|
83765
|
+
};
|
|
83766
|
+
let prevExp;
|
|
83767
|
+
do {
|
|
83768
|
+
prevExp = expression;
|
|
83769
|
+
expression = stripOuter(expression);
|
|
83770
|
+
} while (expression !== prevExp);
|
|
83637
83771
|
const conditions = expression.split(/\s+AND\s+/i);
|
|
83638
83772
|
for (let i = 0; i < conditions.length; i++) {
|
|
83639
83773
|
const condition = conditions[i].trim();
|
|
@@ -83666,7 +83800,7 @@ class GeoJSONLayerHandler extends BaseLayer$2 {
|
|
|
83666
83800
|
// property LIKE 'pattern'
|
|
83667
83801
|
{ regex: /^(\w+)\s+LIKE\s+'([^']*)'$/i, operator: FilterOperator.LIKE },
|
|
83668
83802
|
// property IN ('a','b',...) 或 property IN (1,2,...)
|
|
83669
|
-
{ regex: /^(\w+)\s+IN\s
|
|
83803
|
+
{ regex: /^(\w+)\s+IN\s*[\((]\s*([\s\S]+?)\s*[\))]\s*$/i, operator: FilterOperator.IN }
|
|
83670
83804
|
];
|
|
83671
83805
|
for (const pattern of patterns) {
|
|
83672
83806
|
const match2 = condition.match(pattern.regex);
|
|
@@ -468798,7 +468932,7 @@ class MapManager {
|
|
|
468798
468932
|
...this.config.eventManager
|
|
468799
468933
|
};
|
|
468800
468934
|
this.eventManager = new EventManager(this.map, this.layerManager, eventManagerConfig);
|
|
468801
|
-
const
|
|
468935
|
+
const defaultSearchConfig2 = {
|
|
468802
468936
|
enabled: true,
|
|
468803
468937
|
position: "top-left",
|
|
468804
468938
|
placeholder: "搜索地点...",
|
|
@@ -468814,7 +468948,7 @@ class MapManager {
|
|
|
468814
468948
|
zoomLevel: 16
|
|
468815
468949
|
}
|
|
468816
468950
|
};
|
|
468817
|
-
this.searchMarkerManager = new SearchMarkerManager(this.map,
|
|
468951
|
+
this.searchMarkerManager = new SearchMarkerManager(this.map, defaultSearchConfig2);
|
|
468818
468952
|
this.featureHighlightManager = new FeatureHighlightManager(this.map);
|
|
468819
468953
|
this.markerAdapter = new MarkerDrawingAdapter(this.map);
|
|
468820
468954
|
this.drawingManager = new DrawingManager({ map: this.map });
|
|
@@ -469260,23 +469394,30 @@ class MapManager {
|
|
|
469260
469394
|
* 搜索位置
|
|
469261
469395
|
*/
|
|
469262
469396
|
async searchLocation(query) {
|
|
469397
|
+
var _a3, _b3;
|
|
469263
469398
|
if (!this.searchMarkerManager || !this.map)
|
|
469264
469399
|
return [];
|
|
469265
469400
|
try {
|
|
469266
|
-
const {
|
|
469267
|
-
const
|
|
469268
|
-
if (
|
|
469269
|
-
|
|
469270
|
-
|
|
469271
|
-
|
|
469272
|
-
const
|
|
469273
|
-
|
|
469274
|
-
|
|
469275
|
-
|
|
469276
|
-
|
|
469277
|
-
|
|
469278
|
-
|
|
469279
|
-
|
|
469401
|
+
const { MapSearchService: MapSearchService2, defaultSearchConfig: defaultSearchConfig2 } = await Promise.resolve().then(() => searchService);
|
|
469402
|
+
const searchConfig = ((_b3 = (_a3 = this.config) == null ? void 0 : _a3.controls) == null ? void 0 : _b3.search) ? { ...defaultSearchConfig2, ...this.config.controls.search } : defaultSearchConfig2;
|
|
469403
|
+
if (searchConfig.enabled === false) {
|
|
469404
|
+
return [];
|
|
469405
|
+
}
|
|
469406
|
+
if (searchConfig.provider === "layer") {
|
|
469407
|
+
const layerResults = await this.searchLayersByAttribute(query, searchConfig);
|
|
469408
|
+
if (layerResults && layerResults.length > 0) {
|
|
469409
|
+
this.searchMarkerManager.updateConfig(searchConfig);
|
|
469410
|
+
this.searchMarkerManager.addSearchMarkers(layerResults);
|
|
469411
|
+
this.searchMarkerManager.locateToResult(layerResults[0]);
|
|
469412
|
+
}
|
|
469413
|
+
return layerResults;
|
|
469414
|
+
}
|
|
469415
|
+
const searchService$1 = new MapSearchService2(searchConfig);
|
|
469416
|
+
const results = await searchService$1.search(query);
|
|
469417
|
+
if (results && results.length > 0) {
|
|
469418
|
+
this.searchMarkerManager.updateConfig(searchConfig);
|
|
469419
|
+
this.searchMarkerManager.addSearchMarkers(results);
|
|
469420
|
+
this.searchMarkerManager.locateToResult(results[0]);
|
|
469280
469421
|
}
|
|
469281
469422
|
return results;
|
|
469282
469423
|
} catch (error2) {
|
|
@@ -469284,6 +469425,101 @@ class MapManager {
|
|
|
469284
469425
|
throw error2;
|
|
469285
469426
|
}
|
|
469286
469427
|
}
|
|
469428
|
+
/**
|
|
469429
|
+
* 在已加载的矢量图层中按属性搜索
|
|
469430
|
+
*/
|
|
469431
|
+
async searchLayersByAttribute(query, searchConfig) {
|
|
469432
|
+
var _a3, _b3, _c2, _d, _e2, _f;
|
|
469433
|
+
try {
|
|
469434
|
+
if (!this.layerManager || !this.map || !query || query.trim().length < (searchConfig.minSearchLength || 2)) {
|
|
469435
|
+
return [];
|
|
469436
|
+
}
|
|
469437
|
+
const q2 = query.trim().toLowerCase();
|
|
469438
|
+
const results = [];
|
|
469439
|
+
const mapProj = this.map.getView().getProjection();
|
|
469440
|
+
const layerSearch = searchConfig.layerSearch || {};
|
|
469441
|
+
const onlyVisible = layerSearch.onlyVisible ?? true;
|
|
469442
|
+
const targetLayerIds = Array.isArray(layerSearch.layers) ? new Set(layerSearch.layers) : null;
|
|
469443
|
+
const attrKeys = Array.isArray(layerSearch.attributeKeys) ? layerSearch.attributeKeys : void 0;
|
|
469444
|
+
const perLayerLimit = layerSearch.maxPerLayer ?? searchConfig.maxResults ?? 10;
|
|
469445
|
+
const allConfigs = this.layerManager.getAllLayerConfigs();
|
|
469446
|
+
const targetConfigs = allConfigs.filter((cfg) => {
|
|
469447
|
+
if (targetLayerIds && !targetLayerIds.has(cfg.id))
|
|
469448
|
+
return false;
|
|
469449
|
+
if (onlyVisible && cfg.visible === false)
|
|
469450
|
+
return false;
|
|
469451
|
+
const t3 = (cfg.type || "").toLowerCase();
|
|
469452
|
+
return t3 === "vector" || t3 === "geojson" || t3 === "wfs";
|
|
469453
|
+
});
|
|
469454
|
+
for (const cfg of targetConfigs) {
|
|
469455
|
+
const handler = this.layerManager.getLayerHandler(cfg.id);
|
|
469456
|
+
if (!handler)
|
|
469457
|
+
continue;
|
|
469458
|
+
const layer2 = (_a3 = handler.getLayer) == null ? void 0 : _a3.call(handler);
|
|
469459
|
+
if (!layer2 || typeof layer2.getSource !== "function")
|
|
469460
|
+
continue;
|
|
469461
|
+
const source = layer2.getSource();
|
|
469462
|
+
if (!source || typeof source.getFeatures !== "function")
|
|
469463
|
+
continue;
|
|
469464
|
+
const features2 = source.getFeatures() || [];
|
|
469465
|
+
let count2 = 0;
|
|
469466
|
+
for (const feature2 of features2) {
|
|
469467
|
+
if (perLayerLimit && count2 >= perLayerLimit)
|
|
469468
|
+
break;
|
|
469469
|
+
const props = typeof feature2.getProperties === "function" ? feature2.getProperties() : {};
|
|
469470
|
+
const { geometry: geometry2, ...dataProps } = props || {};
|
|
469471
|
+
const keysToCheck = attrKeys && attrKeys.length > 0 ? attrKeys : Object.keys(dataProps).filter((k2) => {
|
|
469472
|
+
const v5 = dataProps[k2];
|
|
469473
|
+
return typeof v5 === "string" || typeof v5 === "number";
|
|
469474
|
+
});
|
|
469475
|
+
let matchedLabel;
|
|
469476
|
+
for (const k2 of keysToCheck) {
|
|
469477
|
+
const v5 = dataProps[k2];
|
|
469478
|
+
if (v5 == null)
|
|
469479
|
+
continue;
|
|
469480
|
+
const s2 = String(v5).toLowerCase();
|
|
469481
|
+
if (s2.includes(q2)) {
|
|
469482
|
+
matchedLabel = String(v5);
|
|
469483
|
+
break;
|
|
469484
|
+
}
|
|
469485
|
+
}
|
|
469486
|
+
if (!matchedLabel)
|
|
469487
|
+
continue;
|
|
469488
|
+
const geom = typeof feature2.getGeometry === "function" ? feature2.getGeometry() : null;
|
|
469489
|
+
if (!geom)
|
|
469490
|
+
continue;
|
|
469491
|
+
let center2;
|
|
469492
|
+
const type = (_b3 = geom.getType) == null ? void 0 : _b3.call(geom);
|
|
469493
|
+
if (type === "Point" && typeof geom.getCoordinates === "function") {
|
|
469494
|
+
center2 = geom.getCoordinates();
|
|
469495
|
+
} else {
|
|
469496
|
+
const extent3 = (_c2 = geom.getExtent) == null ? void 0 : _c2.call(geom);
|
|
469497
|
+
if (!extent3 || extent3.length < 4)
|
|
469498
|
+
continue;
|
|
469499
|
+
center2 = [(extent3[0] + extent3[2]) / 2, (extent3[1] + extent3[3]) / 2];
|
|
469500
|
+
}
|
|
469501
|
+
const [lng, lat2] = toLonLat$1(center2, mapProj);
|
|
469502
|
+
const id = 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}`);
|
|
469503
|
+
results.push({
|
|
469504
|
+
id,
|
|
469505
|
+
name: matchedLabel || cfg.name,
|
|
469506
|
+
address: cfg.name || "",
|
|
469507
|
+
location: [lng, lat2],
|
|
469508
|
+
type: "layer-feature",
|
|
469509
|
+
bounds: (_f = geom.getExtent) == null ? void 0 : _f.call(geom)
|
|
469510
|
+
});
|
|
469511
|
+
count2++;
|
|
469512
|
+
}
|
|
469513
|
+
}
|
|
469514
|
+
if (searchConfig.maxResults && results.length > searchConfig.maxResults) {
|
|
469515
|
+
return results.slice(0, searchConfig.maxResults);
|
|
469516
|
+
}
|
|
469517
|
+
return results;
|
|
469518
|
+
} catch (err2) {
|
|
469519
|
+
console.error("图层属性搜索失败:", err2);
|
|
469520
|
+
return [];
|
|
469521
|
+
}
|
|
469522
|
+
}
|
|
469287
469523
|
/**
|
|
469288
469524
|
* 清除搜索标记
|
|
469289
469525
|
*/
|
|
@@ -469433,6 +469669,10 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
|
469433
469669
|
});
|
|
469434
469670
|
};
|
|
469435
469671
|
const updateMapConfig = (config) => {
|
|
469672
|
+
if (mapManager.value) {
|
|
469673
|
+
mapManager.value.updateConfig(config);
|
|
469674
|
+
return;
|
|
469675
|
+
}
|
|
469436
469676
|
if (!map2.value)
|
|
469437
469677
|
return;
|
|
469438
469678
|
const view = map2.value.getView();
|
|
@@ -469455,6 +469695,27 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
|
469455
469695
|
width: typeof props.width === "number" ? `${props.width}px` : props.width,
|
|
469456
469696
|
height: typeof props.height === "number" ? `${props.height}px` : props.height
|
|
469457
469697
|
}));
|
|
469698
|
+
const handleSearch = async (query) => {
|
|
469699
|
+
if (!mapManager.value)
|
|
469700
|
+
return;
|
|
469701
|
+
try {
|
|
469702
|
+
await mapManager.value.searchLocation(query);
|
|
469703
|
+
} catch (error2) {
|
|
469704
|
+
console.error("处理搜索失败:", error2);
|
|
469705
|
+
}
|
|
469706
|
+
};
|
|
469707
|
+
const handleSearchSelect = (result) => {
|
|
469708
|
+
var _a3;
|
|
469709
|
+
const manager = (_a3 = mapManager.value) == null ? void 0 : _a3.getSearchMarkerManager();
|
|
469710
|
+
if (manager) {
|
|
469711
|
+
manager.locateToResult(result);
|
|
469712
|
+
}
|
|
469713
|
+
};
|
|
469714
|
+
const handleSearchClear = () => {
|
|
469715
|
+
if (mapManager.value) {
|
|
469716
|
+
mapManager.value.clearSearchMarkers();
|
|
469717
|
+
}
|
|
469718
|
+
};
|
|
469458
469719
|
__expose({
|
|
469459
469720
|
getMap: () => map2.value,
|
|
469460
469721
|
getMapManager: () => mapManager.value,
|
|
@@ -469474,7 +469735,11 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
|
469474
469735
|
var _a3;
|
|
469475
469736
|
return (_a3 = mapManager.value) == null ? void 0 : _a3.getEventManager();
|
|
469476
469737
|
},
|
|
469477
|
-
updateMapConfig
|
|
469738
|
+
updateMapConfig,
|
|
469739
|
+
// 搜索相关方法
|
|
469740
|
+
handleSearch,
|
|
469741
|
+
handleSearchSelect,
|
|
469742
|
+
handleSearchClear
|
|
469478
469743
|
});
|
|
469479
469744
|
return (_ctx, _cache) => {
|
|
469480
469745
|
const _directive_loading = resolveDirective("loading");
|
|
@@ -469495,7 +469760,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
|
469495
469760
|
};
|
|
469496
469761
|
}
|
|
469497
469762
|
});
|
|
469498
|
-
const MapContainer = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["__scopeId", "data-v-
|
|
469763
|
+
const MapContainer = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["__scopeId", "data-v-9ef2c9f4"]]);
|
|
469499
469764
|
const _hoisted_1$k = ["href"];
|
|
469500
469765
|
const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
469501
469766
|
__name: "index",
|
|
@@ -476654,19 +476919,16 @@ class TiandituSearchApi {
|
|
|
476654
476919
|
}
|
|
476655
476920
|
}
|
|
476656
476921
|
const tiandituSearchApi = new TiandituSearchApi();
|
|
476657
|
-
const tiandituSearchApi$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
476658
|
-
__proto__: null,
|
|
476659
|
-
TiandituSearchApi,
|
|
476660
|
-
tiandituSearchApi
|
|
476661
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
476662
476922
|
class MapSearchService {
|
|
476663
|
-
|
|
476664
|
-
constructor(config) {
|
|
476923
|
+
constructor(config, deps) {
|
|
476665
476924
|
__publicField(this, "config");
|
|
476666
476925
|
__publicField(this, "cache", /* @__PURE__ */ new Map());
|
|
476667
476926
|
__publicField(this, "cacheExpiry", /* @__PURE__ */ new Map());
|
|
476668
476927
|
__publicField(this, "CACHE_DURATION", 5 * 60 * 1e3);
|
|
476928
|
+
// 5分钟缓存
|
|
476929
|
+
__publicField(this, "layerManager", null);
|
|
476669
476930
|
this.config = config;
|
|
476931
|
+
this.layerManager = (deps == null ? void 0 : deps.layerManager) ?? null;
|
|
476670
476932
|
}
|
|
476671
476933
|
/**
|
|
476672
476934
|
* 搜索地址
|
|
@@ -476697,6 +476959,9 @@ class MapSearchService {
|
|
|
476697
476959
|
case "custom":
|
|
476698
476960
|
results = await this.searchCustom(query);
|
|
476699
476961
|
break;
|
|
476962
|
+
case "layer":
|
|
476963
|
+
results = await this.searchLayer(query);
|
|
476964
|
+
break;
|
|
476700
476965
|
default:
|
|
476701
476966
|
results = await this.searchTianditu(query);
|
|
476702
476967
|
}
|
|
@@ -476871,6 +477136,106 @@ class MapSearchService {
|
|
|
476871
477136
|
throw error2;
|
|
476872
477137
|
}
|
|
476873
477138
|
}
|
|
477139
|
+
/**
|
|
477140
|
+
* 图层属性搜索(本地矢量要素,纯列表,不进行地图操作)
|
|
477141
|
+
*/
|
|
477142
|
+
async searchLayer(query) {
|
|
477143
|
+
var _a3, _b3, _c2, _d;
|
|
477144
|
+
try {
|
|
477145
|
+
if (!this.layerManager) {
|
|
477146
|
+
return [];
|
|
477147
|
+
}
|
|
477148
|
+
const minLen = this.config.minSearchLength || 2;
|
|
477149
|
+
if (!query || query.trim().length < minLen) {
|
|
477150
|
+
return [];
|
|
477151
|
+
}
|
|
477152
|
+
const q2 = query.trim().toLowerCase();
|
|
477153
|
+
const results = [];
|
|
477154
|
+
const layerSearch = this.config.layerSearch || {};
|
|
477155
|
+
const onlyVisible = layerSearch.onlyVisible ?? true;
|
|
477156
|
+
const targetLayerIds = Array.isArray(layerSearch.layers) ? new Set(layerSearch.layers) : null;
|
|
477157
|
+
const attrKeys = Array.isArray(layerSearch.attributeKeys) ? layerSearch.attributeKeys : void 0;
|
|
477158
|
+
const perLayerLimit = layerSearch.maxPerLayer ?? this.config.maxResults ?? 10;
|
|
477159
|
+
const allConfigs = this.layerManager.getAllLayerConfigs();
|
|
477160
|
+
const targetConfigs = allConfigs.filter((cfg) => {
|
|
477161
|
+
if (targetLayerIds && !targetLayerIds.has(cfg.id))
|
|
477162
|
+
return false;
|
|
477163
|
+
if (onlyVisible && cfg.visible === false)
|
|
477164
|
+
return false;
|
|
477165
|
+
const t3 = (cfg.type || "").toLowerCase();
|
|
477166
|
+
return t3 === "vector" || t3 === "geojson" || t3 === "wfs";
|
|
477167
|
+
});
|
|
477168
|
+
for (const cfg of targetConfigs) {
|
|
477169
|
+
const handler = this.layerManager.getLayerHandler(cfg.id);
|
|
477170
|
+
if (!handler)
|
|
477171
|
+
continue;
|
|
477172
|
+
const layer2 = (_a3 = handler.getLayer) == null ? void 0 : _a3.call(handler);
|
|
477173
|
+
if (!layer2 || typeof layer2.getSource !== "function")
|
|
477174
|
+
continue;
|
|
477175
|
+
const source = layer2.getSource();
|
|
477176
|
+
if (!source || typeof source.getFeatures !== "function")
|
|
477177
|
+
continue;
|
|
477178
|
+
const features2 = source.getFeatures() || [];
|
|
477179
|
+
let count2 = 0;
|
|
477180
|
+
for (const feature2 of features2) {
|
|
477181
|
+
if (perLayerLimit && count2 >= perLayerLimit)
|
|
477182
|
+
break;
|
|
477183
|
+
const props = typeof feature2.getProperties === "function" ? feature2.getProperties() : {};
|
|
477184
|
+
const { geometry: geometry2, ...dataProps } = props || {};
|
|
477185
|
+
if (!geometry2 && typeof feature2.getGeometry === "function") {
|
|
477186
|
+
dataProps.geometry = feature2.getGeometry();
|
|
477187
|
+
}
|
|
477188
|
+
const keysToCheck = attrKeys && attrKeys.length > 0 ? attrKeys : Object.keys(dataProps).filter((k2) => {
|
|
477189
|
+
const v5 = dataProps[k2];
|
|
477190
|
+
return typeof v5 === "string" || typeof v5 === "number";
|
|
477191
|
+
});
|
|
477192
|
+
let matchedLabel;
|
|
477193
|
+
for (const k2 of keysToCheck) {
|
|
477194
|
+
const v5 = dataProps[k2];
|
|
477195
|
+
if (v5 == null)
|
|
477196
|
+
continue;
|
|
477197
|
+
const s2 = String(v5).toLowerCase();
|
|
477198
|
+
if (s2.includes(q2)) {
|
|
477199
|
+
matchedLabel = String(v5);
|
|
477200
|
+
break;
|
|
477201
|
+
}
|
|
477202
|
+
}
|
|
477203
|
+
if (!matchedLabel)
|
|
477204
|
+
continue;
|
|
477205
|
+
const geom = typeof feature2.getGeometry === "function" ? feature2.getGeometry() : geometry2;
|
|
477206
|
+
if (!geom)
|
|
477207
|
+
continue;
|
|
477208
|
+
let center2;
|
|
477209
|
+
const type = (_b3 = geom.getType) == null ? void 0 : _b3.call(geom);
|
|
477210
|
+
if (type === "Point" && typeof geom.getCoordinates === "function") {
|
|
477211
|
+
center2 = geom.getCoordinates();
|
|
477212
|
+
} else if (typeof geom.getExtent === "function") {
|
|
477213
|
+
const extent3 = geom.getExtent();
|
|
477214
|
+
if (extent3 && extent3.length >= 4) {
|
|
477215
|
+
center2 = [(extent3[0] + extent3[2]) / 2, (extent3[1] + extent3[3]) / 2];
|
|
477216
|
+
}
|
|
477217
|
+
}
|
|
477218
|
+
const id = 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}`);
|
|
477219
|
+
results.push({
|
|
477220
|
+
id,
|
|
477221
|
+
name: matchedLabel || cfg.name,
|
|
477222
|
+
address: cfg.name || "",
|
|
477223
|
+
location: center2 || [0, 0],
|
|
477224
|
+
type: "layer-feature",
|
|
477225
|
+
bounds: typeof geom.getExtent === "function" ? geom.getExtent() : void 0
|
|
477226
|
+
});
|
|
477227
|
+
count2++;
|
|
477228
|
+
}
|
|
477229
|
+
}
|
|
477230
|
+
if (this.config.maxResults && results.length > this.config.maxResults) {
|
|
477231
|
+
return results.slice(0, this.config.maxResults);
|
|
477232
|
+
}
|
|
477233
|
+
return results;
|
|
477234
|
+
} catch (error2) {
|
|
477235
|
+
console.error("图层属性搜索失败:", error2);
|
|
477236
|
+
return [];
|
|
477237
|
+
}
|
|
477238
|
+
}
|
|
476874
477239
|
/**
|
|
476875
477240
|
* 解析百度地图结果
|
|
476876
477241
|
*/
|
|
@@ -476983,7 +477348,34 @@ class MapSearchService {
|
|
|
476983
477348
|
this.config = config;
|
|
476984
477349
|
this.clearCache();
|
|
476985
477350
|
}
|
|
477351
|
+
/**
|
|
477352
|
+
* 设置图层管理器(用于图层搜索)
|
|
477353
|
+
*/
|
|
477354
|
+
setLayerManager(manager) {
|
|
477355
|
+
this.layerManager = manager ?? null;
|
|
477356
|
+
}
|
|
476986
477357
|
}
|
|
477358
|
+
const defaultSearchConfig = {
|
|
477359
|
+
enabled: true,
|
|
477360
|
+
position: "top-left",
|
|
477361
|
+
placeholder: "搜索地点...",
|
|
477362
|
+
provider: "tianditu",
|
|
477363
|
+
maxResults: 10,
|
|
477364
|
+
showHistory: true,
|
|
477365
|
+
searchDelay: 300,
|
|
477366
|
+
minSearchLength: 2,
|
|
477367
|
+
resultStyle: {
|
|
477368
|
+
markerColor: "#409eff",
|
|
477369
|
+
markerSize: 20,
|
|
477370
|
+
highlightColor: "#67c23a",
|
|
477371
|
+
zoomLevel: 16
|
|
477372
|
+
}
|
|
477373
|
+
};
|
|
477374
|
+
const searchService = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
477375
|
+
__proto__: null,
|
|
477376
|
+
MapSearchService,
|
|
477377
|
+
defaultSearchConfig
|
|
477378
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
476987
477379
|
const _hoisted_1$7 = { class: "search-input-wrapper" };
|
|
476988
477380
|
const _hoisted_2$7 = { class: "search-results" };
|
|
476989
477381
|
const _hoisted_3$7 = {
|
|
@@ -477040,7 +477432,8 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
477040
477432
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
477041
477433
|
const props = __props;
|
|
477042
477434
|
const emit = __emit;
|
|
477043
|
-
const
|
|
477435
|
+
const injectedLayerManager = inject("layerManager");
|
|
477436
|
+
const searchService2 = new MapSearchService(props.config, { layerManager: (injectedLayerManager == null ? void 0 : injectedLayerManager.value) || null });
|
|
477044
477437
|
const searchQuery = ref("");
|
|
477045
477438
|
const searchResults = ref([]);
|
|
477046
477439
|
const searchHistory = ref([]);
|
|
@@ -477142,7 +477535,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
477142
477535
|
isLoading.value = true;
|
|
477143
477536
|
showResults.value = true;
|
|
477144
477537
|
try {
|
|
477145
|
-
const results = await
|
|
477538
|
+
const results = await searchService2.search(query);
|
|
477146
477539
|
searchResults.value = results;
|
|
477147
477540
|
emit("search", query);
|
|
477148
477541
|
} catch (error2) {
|
|
@@ -477239,13 +477632,20 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
477239
477632
|
watch(
|
|
477240
477633
|
() => props.config,
|
|
477241
477634
|
(newConfig) => {
|
|
477242
|
-
|
|
477635
|
+
searchService2.updateConfig(newConfig);
|
|
477243
477636
|
searchResults.value = [];
|
|
477244
477637
|
selectedIndex.value = -1;
|
|
477245
477638
|
console.log("MapSearch配置已更新:", newConfig);
|
|
477246
477639
|
},
|
|
477247
477640
|
{ deep: true }
|
|
477248
477641
|
);
|
|
477642
|
+
watch(
|
|
477643
|
+
() => injectedLayerManager == null ? void 0 : injectedLayerManager.value,
|
|
477644
|
+
(lm) => {
|
|
477645
|
+
searchService2.setLayerManager(lm || null);
|
|
477646
|
+
},
|
|
477647
|
+
{ immediate: true }
|
|
477648
|
+
);
|
|
477249
477649
|
__expose({
|
|
477250
477650
|
updateResults,
|
|
477251
477651
|
clearResults,
|
|
@@ -481216,23 +481616,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
481216
481616
|
});
|
|
481217
481617
|
};
|
|
481218
481618
|
const onSearch = (query) => {
|
|
481219
|
-
debugger;
|
|
481220
|
-
if (mapContainerRef.value && mapContainerRef.value.handleSearch) {
|
|
481221
|
-
mapContainerRef.value.handleSearch(query);
|
|
481222
|
-
}
|
|
481223
481619
|
emit("search", query);
|
|
481224
481620
|
};
|
|
481225
481621
|
const onSearchSelect = (result) => {
|
|
481226
|
-
if (mapContainerRef.value && mapContainerRef.value.handleSearchSelect) {
|
|
481227
|
-
mapContainerRef.value.handleSearchSelect(result);
|
|
481228
|
-
}
|
|
481229
|
-
debugger;
|
|
481230
481622
|
emit("search-select", result);
|
|
481231
481623
|
};
|
|
481232
481624
|
const onSearchClear = () => {
|
|
481233
|
-
if (mapContainerRef.value && mapContainerRef.value.handleSearchClear) {
|
|
481234
|
-
mapContainerRef.value.handleSearchClear();
|
|
481235
|
-
}
|
|
481236
481625
|
emit("search-clear");
|
|
481237
481626
|
};
|
|
481238
481627
|
const onLayerChange = (layer2) => {
|
|
@@ -481861,7 +482250,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
481861
482250
|
};
|
|
481862
482251
|
}
|
|
481863
482252
|
});
|
|
481864
|
-
const CustomOpenlayer = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
482253
|
+
const CustomOpenlayer = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c8137b4e"]]);
|
|
481865
482254
|
var u8 = Uint8Array;
|
|
481866
482255
|
var u16 = Uint16Array;
|
|
481867
482256
|
var i32 = Int32Array;
|
|
@@ -490133,7 +490522,7 @@ function(t3) {
|
|
|
490133
490522
|
*/
|
|
490134
490523
|
function(t3) {
|
|
490135
490524
|
function e8() {
|
|
490136
|
-
return (n.canvg ? Promise.resolve(n.canvg) : import("./index.es-
|
|
490525
|
+
return (n.canvg ? Promise.resolve(n.canvg) : import("./index.es-7867bf7f.mjs")).catch(function(t4) {
|
|
490137
490526
|
return Promise.reject(new Error("Could not load canvg: " + t4));
|
|
490138
490527
|
}).then(function(t4) {
|
|
490139
490528
|
return t4.default ? t4.default : t4;
|