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.
@@ -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
- styleOptions.text = this.createText(config.text);
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
- return new VectorSource$2({
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
- return styleManager.createStyleFunction(this.styleConfig);
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
  * 转换旧的样式配置为新格式
@@ -468798,7 +468922,7 @@ class MapManager {
468798
468922
  ...this.config.eventManager
468799
468923
  };
468800
468924
  this.eventManager = new EventManager(this.map, this.layerManager, eventManagerConfig);
468801
- const defaultSearchConfig = {
468925
+ const defaultSearchConfig2 = {
468802
468926
  enabled: true,
468803
468927
  position: "top-left",
468804
468928
  placeholder: "搜索地点...",
@@ -468814,7 +468938,7 @@ class MapManager {
468814
468938
  zoomLevel: 16
468815
468939
  }
468816
468940
  };
468817
- this.searchMarkerManager = new SearchMarkerManager(this.map, defaultSearchConfig);
468941
+ this.searchMarkerManager = new SearchMarkerManager(this.map, defaultSearchConfig2);
468818
468942
  this.featureHighlightManager = new FeatureHighlightManager(this.map);
468819
468943
  this.markerAdapter = new MarkerDrawingAdapter(this.map);
468820
468944
  this.drawingManager = new DrawingManager({ map: this.map });
@@ -469260,23 +469384,30 @@ class MapManager {
469260
469384
  * 搜索位置
469261
469385
  */
469262
469386
  async searchLocation(query) {
469387
+ var _a3, _b3;
469263
469388
  if (!this.searchMarkerManager || !this.map)
469264
469389
  return [];
469265
469390
  try {
469266
- const { tiandituSearchApi: tiandituSearchApi2 } = await Promise.resolve().then(() => tiandituSearchApi$1);
469267
- const results = await tiandituSearchApi2.search(query);
469268
- if (results.length > 0) {
469269
- const result = results[0];
469270
- const coordinate = [parseFloat(result.lon), parseFloat(result.lat)];
469271
- this.searchMarkerManager.addSearchMarkers([{ coordinate, name: result.name }]);
469272
- const view = this.map.getView();
469273
- const projection2 = view.getProjection().getCode();
469274
- const targetCoordinate = projection2 === "EPSG:4326" || projection2 === "EPSG:4490" ? coordinate : fromLonLat$1(coordinate);
469275
- view.animate({
469276
- center: targetCoordinate,
469277
- zoom: 16,
469278
- duration: 1e3
469279
- });
469391
+ const { MapSearchService: MapSearchService2, defaultSearchConfig: defaultSearchConfig2 } = await Promise.resolve().then(() => searchService);
469392
+ const searchConfig = ((_b3 = (_a3 = this.config) == null ? void 0 : _a3.controls) == null ? void 0 : _b3.search) ? { ...defaultSearchConfig2, ...this.config.controls.search } : defaultSearchConfig2;
469393
+ if (searchConfig.enabled === false) {
469394
+ return [];
469395
+ }
469396
+ if (searchConfig.provider === "layer") {
469397
+ const layerResults = await this.searchLayersByAttribute(query, searchConfig);
469398
+ if (layerResults && layerResults.length > 0) {
469399
+ this.searchMarkerManager.updateConfig(searchConfig);
469400
+ this.searchMarkerManager.addSearchMarkers(layerResults);
469401
+ this.searchMarkerManager.locateToResult(layerResults[0]);
469402
+ }
469403
+ return layerResults;
469404
+ }
469405
+ const searchService$1 = new MapSearchService2(searchConfig);
469406
+ const results = await searchService$1.search(query);
469407
+ if (results && results.length > 0) {
469408
+ this.searchMarkerManager.updateConfig(searchConfig);
469409
+ this.searchMarkerManager.addSearchMarkers(results);
469410
+ this.searchMarkerManager.locateToResult(results[0]);
469280
469411
  }
469281
469412
  return results;
469282
469413
  } catch (error2) {
@@ -469284,6 +469415,101 @@ class MapManager {
469284
469415
  throw error2;
469285
469416
  }
469286
469417
  }
469418
+ /**
469419
+ * 在已加载的矢量图层中按属性搜索
469420
+ */
469421
+ async searchLayersByAttribute(query, searchConfig) {
469422
+ var _a3, _b3, _c2, _d, _e2, _f;
469423
+ try {
469424
+ if (!this.layerManager || !this.map || !query || query.trim().length < (searchConfig.minSearchLength || 2)) {
469425
+ return [];
469426
+ }
469427
+ const q2 = query.trim().toLowerCase();
469428
+ const results = [];
469429
+ const mapProj = this.map.getView().getProjection();
469430
+ const layerSearch = searchConfig.layerSearch || {};
469431
+ const onlyVisible = layerSearch.onlyVisible ?? true;
469432
+ const targetLayerIds = Array.isArray(layerSearch.layers) ? new Set(layerSearch.layers) : null;
469433
+ const attrKeys = Array.isArray(layerSearch.attributeKeys) ? layerSearch.attributeKeys : void 0;
469434
+ const perLayerLimit = layerSearch.maxPerLayer ?? searchConfig.maxResults ?? 10;
469435
+ const allConfigs = this.layerManager.getAllLayerConfigs();
469436
+ const targetConfigs = allConfigs.filter((cfg) => {
469437
+ if (targetLayerIds && !targetLayerIds.has(cfg.id))
469438
+ return false;
469439
+ if (onlyVisible && cfg.visible === false)
469440
+ return false;
469441
+ const t3 = (cfg.type || "").toLowerCase();
469442
+ return t3 === "vector" || t3 === "geojson" || t3 === "wfs";
469443
+ });
469444
+ for (const cfg of targetConfigs) {
469445
+ const handler = this.layerManager.getLayerHandler(cfg.id);
469446
+ if (!handler)
469447
+ continue;
469448
+ const layer2 = (_a3 = handler.getLayer) == null ? void 0 : _a3.call(handler);
469449
+ if (!layer2 || typeof layer2.getSource !== "function")
469450
+ continue;
469451
+ const source = layer2.getSource();
469452
+ if (!source || typeof source.getFeatures !== "function")
469453
+ continue;
469454
+ const features2 = source.getFeatures() || [];
469455
+ let count2 = 0;
469456
+ for (const feature2 of features2) {
469457
+ if (perLayerLimit && count2 >= perLayerLimit)
469458
+ break;
469459
+ const props = typeof feature2.getProperties === "function" ? feature2.getProperties() : {};
469460
+ const { geometry: geometry2, ...dataProps } = props || {};
469461
+ const keysToCheck = attrKeys && attrKeys.length > 0 ? attrKeys : Object.keys(dataProps).filter((k2) => {
469462
+ const v5 = dataProps[k2];
469463
+ return typeof v5 === "string" || typeof v5 === "number";
469464
+ });
469465
+ let matchedLabel;
469466
+ for (const k2 of keysToCheck) {
469467
+ const v5 = dataProps[k2];
469468
+ if (v5 == null)
469469
+ continue;
469470
+ const s2 = String(v5).toLowerCase();
469471
+ if (s2.includes(q2)) {
469472
+ matchedLabel = String(v5);
469473
+ break;
469474
+ }
469475
+ }
469476
+ if (!matchedLabel)
469477
+ continue;
469478
+ const geom = typeof feature2.getGeometry === "function" ? feature2.getGeometry() : null;
469479
+ if (!geom)
469480
+ continue;
469481
+ let center2;
469482
+ const type = (_b3 = geom.getType) == null ? void 0 : _b3.call(geom);
469483
+ if (type === "Point" && typeof geom.getCoordinates === "function") {
469484
+ center2 = geom.getCoordinates();
469485
+ } else {
469486
+ const extent3 = (_c2 = geom.getExtent) == null ? void 0 : _c2.call(geom);
469487
+ if (!extent3 || extent3.length < 4)
469488
+ continue;
469489
+ center2 = [(extent3[0] + extent3[2]) / 2, (extent3[1] + extent3[3]) / 2];
469490
+ }
469491
+ const [lng, lat2] = toLonLat$1(center2, mapProj);
469492
+ 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}`);
469493
+ results.push({
469494
+ id,
469495
+ name: matchedLabel || cfg.name,
469496
+ address: cfg.name || "",
469497
+ location: [lng, lat2],
469498
+ type: "layer-feature",
469499
+ bounds: (_f = geom.getExtent) == null ? void 0 : _f.call(geom)
469500
+ });
469501
+ count2++;
469502
+ }
469503
+ }
469504
+ if (searchConfig.maxResults && results.length > searchConfig.maxResults) {
469505
+ return results.slice(0, searchConfig.maxResults);
469506
+ }
469507
+ return results;
469508
+ } catch (err2) {
469509
+ console.error("图层属性搜索失败:", err2);
469510
+ return [];
469511
+ }
469512
+ }
469287
469513
  /**
469288
469514
  * 清除搜索标记
469289
469515
  */
@@ -469433,6 +469659,10 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
469433
469659
  });
469434
469660
  };
469435
469661
  const updateMapConfig = (config) => {
469662
+ if (mapManager.value) {
469663
+ mapManager.value.updateConfig(config);
469664
+ return;
469665
+ }
469436
469666
  if (!map2.value)
469437
469667
  return;
469438
469668
  const view = map2.value.getView();
@@ -469455,6 +469685,27 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
469455
469685
  width: typeof props.width === "number" ? `${props.width}px` : props.width,
469456
469686
  height: typeof props.height === "number" ? `${props.height}px` : props.height
469457
469687
  }));
469688
+ const handleSearch = async (query) => {
469689
+ if (!mapManager.value)
469690
+ return;
469691
+ try {
469692
+ await mapManager.value.searchLocation(query);
469693
+ } catch (error2) {
469694
+ console.error("处理搜索失败:", error2);
469695
+ }
469696
+ };
469697
+ const handleSearchSelect = (result) => {
469698
+ var _a3;
469699
+ const manager = (_a3 = mapManager.value) == null ? void 0 : _a3.getSearchMarkerManager();
469700
+ if (manager) {
469701
+ manager.locateToResult(result);
469702
+ }
469703
+ };
469704
+ const handleSearchClear = () => {
469705
+ if (mapManager.value) {
469706
+ mapManager.value.clearSearchMarkers();
469707
+ }
469708
+ };
469458
469709
  __expose({
469459
469710
  getMap: () => map2.value,
469460
469711
  getMapManager: () => mapManager.value,
@@ -469474,7 +469725,11 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
469474
469725
  var _a3;
469475
469726
  return (_a3 = mapManager.value) == null ? void 0 : _a3.getEventManager();
469476
469727
  },
469477
- updateMapConfig
469728
+ updateMapConfig,
469729
+ // 搜索相关方法
469730
+ handleSearch,
469731
+ handleSearchSelect,
469732
+ handleSearchClear
469478
469733
  });
469479
469734
  return (_ctx, _cache) => {
469480
469735
  const _directive_loading = resolveDirective("loading");
@@ -469495,7 +469750,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
469495
469750
  };
469496
469751
  }
469497
469752
  });
469498
- const MapContainer = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["__scopeId", "data-v-66697410"]]);
469753
+ const MapContainer = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["__scopeId", "data-v-9ef2c9f4"]]);
469499
469754
  const _hoisted_1$k = ["href"];
469500
469755
  const _sfc_main$l = /* @__PURE__ */ defineComponent({
469501
469756
  __name: "index",
@@ -476654,19 +476909,16 @@ class TiandituSearchApi {
476654
476909
  }
476655
476910
  }
476656
476911
  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
476912
  class MapSearchService {
476663
- // 5分钟缓存
476664
- constructor(config) {
476913
+ constructor(config, deps) {
476665
476914
  __publicField(this, "config");
476666
476915
  __publicField(this, "cache", /* @__PURE__ */ new Map());
476667
476916
  __publicField(this, "cacheExpiry", /* @__PURE__ */ new Map());
476668
476917
  __publicField(this, "CACHE_DURATION", 5 * 60 * 1e3);
476918
+ // 5分钟缓存
476919
+ __publicField(this, "layerManager", null);
476669
476920
  this.config = config;
476921
+ this.layerManager = (deps == null ? void 0 : deps.layerManager) ?? null;
476670
476922
  }
476671
476923
  /**
476672
476924
  * 搜索地址
@@ -476697,6 +476949,9 @@ class MapSearchService {
476697
476949
  case "custom":
476698
476950
  results = await this.searchCustom(query);
476699
476951
  break;
476952
+ case "layer":
476953
+ results = await this.searchLayer(query);
476954
+ break;
476700
476955
  default:
476701
476956
  results = await this.searchTianditu(query);
476702
476957
  }
@@ -476871,6 +477126,106 @@ class MapSearchService {
476871
477126
  throw error2;
476872
477127
  }
476873
477128
  }
477129
+ /**
477130
+ * 图层属性搜索(本地矢量要素,纯列表,不进行地图操作)
477131
+ */
477132
+ async searchLayer(query) {
477133
+ var _a3, _b3, _c2, _d;
477134
+ try {
477135
+ if (!this.layerManager) {
477136
+ return [];
477137
+ }
477138
+ const minLen = this.config.minSearchLength || 2;
477139
+ if (!query || query.trim().length < minLen) {
477140
+ return [];
477141
+ }
477142
+ const q2 = query.trim().toLowerCase();
477143
+ const results = [];
477144
+ const layerSearch = this.config.layerSearch || {};
477145
+ const onlyVisible = layerSearch.onlyVisible ?? true;
477146
+ const targetLayerIds = Array.isArray(layerSearch.layers) ? new Set(layerSearch.layers) : null;
477147
+ const attrKeys = Array.isArray(layerSearch.attributeKeys) ? layerSearch.attributeKeys : void 0;
477148
+ const perLayerLimit = layerSearch.maxPerLayer ?? this.config.maxResults ?? 10;
477149
+ const allConfigs = this.layerManager.getAllLayerConfigs();
477150
+ const targetConfigs = allConfigs.filter((cfg) => {
477151
+ if (targetLayerIds && !targetLayerIds.has(cfg.id))
477152
+ return false;
477153
+ if (onlyVisible && cfg.visible === false)
477154
+ return false;
477155
+ const t3 = (cfg.type || "").toLowerCase();
477156
+ return t3 === "vector" || t3 === "geojson" || t3 === "wfs";
477157
+ });
477158
+ for (const cfg of targetConfigs) {
477159
+ const handler = this.layerManager.getLayerHandler(cfg.id);
477160
+ if (!handler)
477161
+ continue;
477162
+ const layer2 = (_a3 = handler.getLayer) == null ? void 0 : _a3.call(handler);
477163
+ if (!layer2 || typeof layer2.getSource !== "function")
477164
+ continue;
477165
+ const source = layer2.getSource();
477166
+ if (!source || typeof source.getFeatures !== "function")
477167
+ continue;
477168
+ const features2 = source.getFeatures() || [];
477169
+ let count2 = 0;
477170
+ for (const feature2 of features2) {
477171
+ if (perLayerLimit && count2 >= perLayerLimit)
477172
+ break;
477173
+ const props = typeof feature2.getProperties === "function" ? feature2.getProperties() : {};
477174
+ const { geometry: geometry2, ...dataProps } = props || {};
477175
+ if (!geometry2 && typeof feature2.getGeometry === "function") {
477176
+ dataProps.geometry = feature2.getGeometry();
477177
+ }
477178
+ const keysToCheck = attrKeys && attrKeys.length > 0 ? attrKeys : Object.keys(dataProps).filter((k2) => {
477179
+ const v5 = dataProps[k2];
477180
+ return typeof v5 === "string" || typeof v5 === "number";
477181
+ });
477182
+ let matchedLabel;
477183
+ for (const k2 of keysToCheck) {
477184
+ const v5 = dataProps[k2];
477185
+ if (v5 == null)
477186
+ continue;
477187
+ const s2 = String(v5).toLowerCase();
477188
+ if (s2.includes(q2)) {
477189
+ matchedLabel = String(v5);
477190
+ break;
477191
+ }
477192
+ }
477193
+ if (!matchedLabel)
477194
+ continue;
477195
+ const geom = typeof feature2.getGeometry === "function" ? feature2.getGeometry() : geometry2;
477196
+ if (!geom)
477197
+ continue;
477198
+ let center2;
477199
+ const type = (_b3 = geom.getType) == null ? void 0 : _b3.call(geom);
477200
+ if (type === "Point" && typeof geom.getCoordinates === "function") {
477201
+ center2 = geom.getCoordinates();
477202
+ } else if (typeof geom.getExtent === "function") {
477203
+ const extent3 = geom.getExtent();
477204
+ if (extent3 && extent3.length >= 4) {
477205
+ center2 = [(extent3[0] + extent3[2]) / 2, (extent3[1] + extent3[3]) / 2];
477206
+ }
477207
+ }
477208
+ 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}`);
477209
+ results.push({
477210
+ id,
477211
+ name: matchedLabel || cfg.name,
477212
+ address: cfg.name || "",
477213
+ location: center2 || [0, 0],
477214
+ type: "layer-feature",
477215
+ bounds: typeof geom.getExtent === "function" ? geom.getExtent() : void 0
477216
+ });
477217
+ count2++;
477218
+ }
477219
+ }
477220
+ if (this.config.maxResults && results.length > this.config.maxResults) {
477221
+ return results.slice(0, this.config.maxResults);
477222
+ }
477223
+ return results;
477224
+ } catch (error2) {
477225
+ console.error("图层属性搜索失败:", error2);
477226
+ return [];
477227
+ }
477228
+ }
476874
477229
  /**
476875
477230
  * 解析百度地图结果
476876
477231
  */
@@ -476983,7 +477338,34 @@ class MapSearchService {
476983
477338
  this.config = config;
476984
477339
  this.clearCache();
476985
477340
  }
477341
+ /**
477342
+ * 设置图层管理器(用于图层搜索)
477343
+ */
477344
+ setLayerManager(manager) {
477345
+ this.layerManager = manager ?? null;
477346
+ }
476986
477347
  }
477348
+ const defaultSearchConfig = {
477349
+ enabled: true,
477350
+ position: "top-left",
477351
+ placeholder: "搜索地点...",
477352
+ provider: "tianditu",
477353
+ maxResults: 10,
477354
+ showHistory: true,
477355
+ searchDelay: 300,
477356
+ minSearchLength: 2,
477357
+ resultStyle: {
477358
+ markerColor: "#409eff",
477359
+ markerSize: 20,
477360
+ highlightColor: "#67c23a",
477361
+ zoomLevel: 16
477362
+ }
477363
+ };
477364
+ const searchService = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
477365
+ __proto__: null,
477366
+ MapSearchService,
477367
+ defaultSearchConfig
477368
+ }, Symbol.toStringTag, { value: "Module" }));
476987
477369
  const _hoisted_1$7 = { class: "search-input-wrapper" };
476988
477370
  const _hoisted_2$7 = { class: "search-results" };
476989
477371
  const _hoisted_3$7 = {
@@ -477040,7 +477422,8 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
477040
477422
  setup(__props, { expose: __expose, emit: __emit }) {
477041
477423
  const props = __props;
477042
477424
  const emit = __emit;
477043
- const searchService = new MapSearchService(props.config);
477425
+ const injectedLayerManager = inject("layerManager");
477426
+ const searchService2 = new MapSearchService(props.config, { layerManager: (injectedLayerManager == null ? void 0 : injectedLayerManager.value) || null });
477044
477427
  const searchQuery = ref("");
477045
477428
  const searchResults = ref([]);
477046
477429
  const searchHistory = ref([]);
@@ -477142,7 +477525,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
477142
477525
  isLoading.value = true;
477143
477526
  showResults.value = true;
477144
477527
  try {
477145
- const results = await searchService.search(query);
477528
+ const results = await searchService2.search(query);
477146
477529
  searchResults.value = results;
477147
477530
  emit("search", query);
477148
477531
  } catch (error2) {
@@ -477239,13 +477622,20 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
477239
477622
  watch(
477240
477623
  () => props.config,
477241
477624
  (newConfig) => {
477242
- searchService.updateConfig(newConfig);
477625
+ searchService2.updateConfig(newConfig);
477243
477626
  searchResults.value = [];
477244
477627
  selectedIndex.value = -1;
477245
477628
  console.log("MapSearch配置已更新:", newConfig);
477246
477629
  },
477247
477630
  { deep: true }
477248
477631
  );
477632
+ watch(
477633
+ () => injectedLayerManager == null ? void 0 : injectedLayerManager.value,
477634
+ (lm) => {
477635
+ searchService2.setLayerManager(lm || null);
477636
+ },
477637
+ { immediate: true }
477638
+ );
477249
477639
  __expose({
477250
477640
  updateResults,
477251
477641
  clearResults,
@@ -481216,23 +481606,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
481216
481606
  });
481217
481607
  };
481218
481608
  const onSearch = (query) => {
481219
- debugger;
481220
- if (mapContainerRef.value && mapContainerRef.value.handleSearch) {
481221
- mapContainerRef.value.handleSearch(query);
481222
- }
481223
481609
  emit("search", query);
481224
481610
  };
481225
481611
  const onSearchSelect = (result) => {
481226
- if (mapContainerRef.value && mapContainerRef.value.handleSearchSelect) {
481227
- mapContainerRef.value.handleSearchSelect(result);
481228
- }
481229
- debugger;
481230
481612
  emit("search-select", result);
481231
481613
  };
481232
481614
  const onSearchClear = () => {
481233
- if (mapContainerRef.value && mapContainerRef.value.handleSearchClear) {
481234
- mapContainerRef.value.handleSearchClear();
481235
- }
481236
481615
  emit("search-clear");
481237
481616
  };
481238
481617
  const onLayerChange = (layer2) => {
@@ -481861,7 +482240,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
481861
482240
  };
481862
482241
  }
481863
482242
  });
481864
- const CustomOpenlayer = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-913ddcb9"]]);
482243
+ const CustomOpenlayer = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c8137b4e"]]);
481865
482244
  var u8 = Uint8Array;
481866
482245
  var u16 = Uint16Array;
481867
482246
  var i32 = Int32Array;
@@ -490133,7 +490512,7 @@ function(t3) {
490133
490512
  */
490134
490513
  function(t3) {
490135
490514
  function e8() {
490136
- return (n.canvg ? Promise.resolve(n.canvg) : import("./index.es-a3c51163.mjs")).catch(function(t4) {
490515
+ return (n.canvg ? Promise.resolve(n.canvg) : import("./index.es-86beb4f4.mjs")).catch(function(t4) {
490137
490516
  return Promise.reject(new Error("Could not load canvg: " + t4));
490138
490517
  }).then(function(t4) {
490139
490518
  return t4.default ? t4.default : t4;
@@ -1,4 +1,4 @@
1
- import { c as commonjsGlobal, R as RGBColor, r as requestAnimationFrame, _ as _asyncToGenerator, a as _, p as processCanvasRGBA, b as _defineProperty } from "./index-2dac53c6.mjs";
1
+ import { c as commonjsGlobal, R as RGBColor, r as requestAnimationFrame, _ as _asyncToGenerator, a as _, p as processCanvasRGBA, b as _defineProperty } from "./index-dd9c537c.mjs";
2
2
  import "vue";
3
3
  import "ol";
4
4
  var check = function(it) {