vue-openlayers-plugin 1.0.41 → 1.0.43
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-e3f12e06.mjs → index-ead1b915.mjs} +546 -6
- package/lib/{index.es-a81be151.mjs → index.es-342b25b8.mjs} +1 -1
- package/lib/index.esm.js +1 -1
- package/lib/index.umd.js +545 -201
- package/lib/style.css +114 -116
- package/package.json +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 +4 -0
- package/types/src/components/CustomOpenlayer/services/searchService.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/types/index.d.ts +1 -1
- package/types/src/components/CustomOpenlayer/types/index.d.ts.map +1 -1
- package/types/src/components/CustomOpenlayer/utils/tiandituSearchApi.d.ts +5 -1
- package/types/src/components/CustomOpenlayer/utils/tiandituSearchApi.d.ts.map +1 -1
- package/lib/tiandituSearchApi-1b9df1b1.mjs +0 -201
|
@@ -466578,8 +466578,8 @@ class MapManager {
|
|
|
466578
466578
|
if (!this.searchMarkerManager || !this.map)
|
|
466579
466579
|
return [];
|
|
466580
466580
|
try {
|
|
466581
|
-
const { tiandituSearchApi } = await
|
|
466582
|
-
const results = await
|
|
466581
|
+
const { tiandituSearchApi: tiandituSearchApi2 } = await Promise.resolve().then(() => tiandituSearchApi$1);
|
|
466582
|
+
const results = await tiandituSearchApi2.search(query);
|
|
466583
466583
|
if (results.length > 0) {
|
|
466584
466584
|
const result = results[0];
|
|
466585
466585
|
const coordinate = [parseFloat(result.lon), parseFloat(result.lat)];
|
|
@@ -473774,6 +473774,539 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
473774
473774
|
}
|
|
473775
473775
|
});
|
|
473776
473776
|
const MapToolbar = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-f8ee8458"]]);
|
|
473777
|
+
const TIANDITU_CONFIG = {
|
|
473778
|
+
baseUrl: "https://api.tianditu.gov.cn/v2/search",
|
|
473779
|
+
key: "9a7244dd5d1a1299a52946a3d0f8ff68"
|
|
473780
|
+
};
|
|
473781
|
+
class TiandituSearchApi {
|
|
473782
|
+
constructor(apiKey) {
|
|
473783
|
+
__publicField(this, "apiKey");
|
|
473784
|
+
__publicField(this, "baseUrl");
|
|
473785
|
+
this.apiKey = apiKey || TIANDITU_CONFIG.key;
|
|
473786
|
+
this.baseUrl = TIANDITU_CONFIG.baseUrl;
|
|
473787
|
+
}
|
|
473788
|
+
/**
|
|
473789
|
+
* 搜索地址或POI
|
|
473790
|
+
* @param query 搜索关键词
|
|
473791
|
+
* @param options 搜索选项
|
|
473792
|
+
*/
|
|
473793
|
+
async search(query, options = {}) {
|
|
473794
|
+
try {
|
|
473795
|
+
const { maxResults = 10, region = "全国", type = "all" } = options;
|
|
473796
|
+
const queryString = {
|
|
473797
|
+
keyWord: query,
|
|
473798
|
+
level: 12,
|
|
473799
|
+
mapBound: "116.02524,39.83833,116.65592,39.99185",
|
|
473800
|
+
queryType: 1,
|
|
473801
|
+
start: 0,
|
|
473802
|
+
count: maxResults
|
|
473803
|
+
};
|
|
473804
|
+
const requestParams = {
|
|
473805
|
+
postStr: JSON.stringify(queryString),
|
|
473806
|
+
type: "query",
|
|
473807
|
+
tk: this.apiKey
|
|
473808
|
+
};
|
|
473809
|
+
const params2 = this.convertObjectToQueryString(requestParams);
|
|
473810
|
+
const response = await fetch(`${this.baseUrl}?${params2}`);
|
|
473811
|
+
if (!response.ok) {
|
|
473812
|
+
throw new Error(`天地图API请求失败: ${response.status}`);
|
|
473813
|
+
}
|
|
473814
|
+
const data = await response.json();
|
|
473815
|
+
if (response.status != "200") {
|
|
473816
|
+
throw new Error(`天地图API返回错误: ${data.status}`);
|
|
473817
|
+
}
|
|
473818
|
+
debugger;
|
|
473819
|
+
return this.transformResults(data, type);
|
|
473820
|
+
} catch (error2) {
|
|
473821
|
+
console.error("天地图搜索失败:", error2);
|
|
473822
|
+
throw error2;
|
|
473823
|
+
}
|
|
473824
|
+
}
|
|
473825
|
+
/**
|
|
473826
|
+
* 将JSON数据转换为查询字符串的函数
|
|
473827
|
+
*/
|
|
473828
|
+
convertObjectToQueryString(obj) {
|
|
473829
|
+
const queryString = Object.keys(obj).map((key) => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join("&");
|
|
473830
|
+
return queryString;
|
|
473831
|
+
}
|
|
473832
|
+
/**
|
|
473833
|
+
* 转换天地图搜索结果为标准格式
|
|
473834
|
+
*/
|
|
473835
|
+
transformResults(data, type) {
|
|
473836
|
+
const results = [];
|
|
473837
|
+
if (data.pois && (type === "all" || type === "poi")) {
|
|
473838
|
+
data.pois.forEach((poi, index2) => {
|
|
473839
|
+
const [lon2, lat2] = poi.lonlat.split(",").map(Number);
|
|
473840
|
+
results.push({
|
|
473841
|
+
id: `tianditu-poi-${index2}`,
|
|
473842
|
+
name: poi.name,
|
|
473843
|
+
address: poi.address || poi.eaddress || "",
|
|
473844
|
+
location: [lon2, lat2],
|
|
473845
|
+
type: this.getPOIType(poi.tag, poi.poiType),
|
|
473846
|
+
confidence: 0.9,
|
|
473847
|
+
city: poi.city,
|
|
473848
|
+
province: poi.province,
|
|
473849
|
+
district: poi.district
|
|
473850
|
+
});
|
|
473851
|
+
});
|
|
473852
|
+
}
|
|
473853
|
+
if (data.suggests && (type === "all" || type === "suggest")) {
|
|
473854
|
+
data.suggests.forEach((suggest, index2) => {
|
|
473855
|
+
const [lon2, lat2] = suggest.lonlat.split(",").map(Number);
|
|
473856
|
+
results.push({
|
|
473857
|
+
id: `tianditu-suggest-${index2}`,
|
|
473858
|
+
name: suggest.name,
|
|
473859
|
+
address: suggest.address || "",
|
|
473860
|
+
location: [lon2, lat2],
|
|
473861
|
+
type: this.getPOIType(suggest.tag),
|
|
473862
|
+
confidence: 0.8
|
|
473863
|
+
});
|
|
473864
|
+
});
|
|
473865
|
+
}
|
|
473866
|
+
return results;
|
|
473867
|
+
}
|
|
473868
|
+
/**
|
|
473869
|
+
* 根据标签或POI类型获取POI类型
|
|
473870
|
+
*/
|
|
473871
|
+
getPOIType(tag2, poiType) {
|
|
473872
|
+
if (poiType) {
|
|
473873
|
+
const typeMap2 = {
|
|
473874
|
+
"101": "地点",
|
|
473875
|
+
"102": "商业",
|
|
473876
|
+
"103": "餐饮",
|
|
473877
|
+
"104": "住宿",
|
|
473878
|
+
"105": "医疗",
|
|
473879
|
+
"106": "教育",
|
|
473880
|
+
"107": "金融",
|
|
473881
|
+
"108": "交通",
|
|
473882
|
+
"109": "旅游",
|
|
473883
|
+
"110": "休闲",
|
|
473884
|
+
"111": "体育"
|
|
473885
|
+
};
|
|
473886
|
+
return typeMap2[poiType] || "地点";
|
|
473887
|
+
}
|
|
473888
|
+
if (!tag2)
|
|
473889
|
+
return "地点";
|
|
473890
|
+
const typeMap = {
|
|
473891
|
+
住宅区: "住宅",
|
|
473892
|
+
商务住宅: "住宅",
|
|
473893
|
+
购物: "商业",
|
|
473894
|
+
购物中心: "商业",
|
|
473895
|
+
餐饮: "餐饮",
|
|
473896
|
+
美食: "餐饮",
|
|
473897
|
+
酒店: "住宿",
|
|
473898
|
+
宾馆: "住宿",
|
|
473899
|
+
医院: "医疗",
|
|
473900
|
+
诊所: "医疗",
|
|
473901
|
+
学校: "教育",
|
|
473902
|
+
大学: "教育",
|
|
473903
|
+
银行: "金融",
|
|
473904
|
+
ATM: "金融",
|
|
473905
|
+
加油站: "交通",
|
|
473906
|
+
停车场: "交通",
|
|
473907
|
+
地铁站: "交通",
|
|
473908
|
+
公交站: "交通",
|
|
473909
|
+
景点: "旅游",
|
|
473910
|
+
公园: "休闲",
|
|
473911
|
+
体育场: "体育"
|
|
473912
|
+
};
|
|
473913
|
+
for (const [key, value] of Object.entries(typeMap)) {
|
|
473914
|
+
if (tag2.includes(key)) {
|
|
473915
|
+
return value;
|
|
473916
|
+
}
|
|
473917
|
+
}
|
|
473918
|
+
return "地点";
|
|
473919
|
+
}
|
|
473920
|
+
/**
|
|
473921
|
+
* 根据级别获取行政区划类型
|
|
473922
|
+
*/
|
|
473923
|
+
getAdminType(level2) {
|
|
473924
|
+
const levelMap = {
|
|
473925
|
+
"1": "国家",
|
|
473926
|
+
"2": "省份",
|
|
473927
|
+
"3": "城市",
|
|
473928
|
+
"4": "区县",
|
|
473929
|
+
"5": "乡镇",
|
|
473930
|
+
"6": "村庄"
|
|
473931
|
+
};
|
|
473932
|
+
return levelMap[level2] || "行政区";
|
|
473933
|
+
}
|
|
473934
|
+
/**
|
|
473935
|
+
* 获取建议搜索词
|
|
473936
|
+
* @param query 输入关键词
|
|
473937
|
+
*/
|
|
473938
|
+
async getSuggestions(query, maxResults = 5) {
|
|
473939
|
+
try {
|
|
473940
|
+
const results = await this.search(query, {
|
|
473941
|
+
maxResults,
|
|
473942
|
+
type: "suggest"
|
|
473943
|
+
});
|
|
473944
|
+
return results.map((result) => result.name);
|
|
473945
|
+
} catch (error2) {
|
|
473946
|
+
console.error("获取搜索建议失败:", error2);
|
|
473947
|
+
return [];
|
|
473948
|
+
}
|
|
473949
|
+
}
|
|
473950
|
+
/**
|
|
473951
|
+
* 逆地理编码 - 根据坐标获取地址
|
|
473952
|
+
* @param coordinates 经纬度坐标 [lon, lat]
|
|
473953
|
+
*/
|
|
473954
|
+
async reverseGeocode(coordinates2) {
|
|
473955
|
+
var _a3;
|
|
473956
|
+
try {
|
|
473957
|
+
const [lon2, lat2] = coordinates2;
|
|
473958
|
+
const params2 = new URLSearchParams({
|
|
473959
|
+
lon: lon2.toString(),
|
|
473960
|
+
lat: lat2.toString(),
|
|
473961
|
+
ver: "1",
|
|
473962
|
+
tk: this.apiKey
|
|
473963
|
+
});
|
|
473964
|
+
const response = await fetch(`https://api.tianditu.gov.cn/geocoder?${params2.toString()}`);
|
|
473965
|
+
if (!response.ok) {
|
|
473966
|
+
throw new Error(`逆地理编码请求失败: ${response.status}`);
|
|
473967
|
+
}
|
|
473968
|
+
const data = await response.json();
|
|
473969
|
+
if (data.status === "0" && data.result) {
|
|
473970
|
+
return data.result.formatted_address || ((_a3 = data.result.addressComponent) == null ? void 0 : _a3.address) || "未知地址";
|
|
473971
|
+
}
|
|
473972
|
+
throw new Error("逆地理编码失败");
|
|
473973
|
+
} catch (error2) {
|
|
473974
|
+
console.error("逆地理编码失败:", error2);
|
|
473975
|
+
return "未知地址";
|
|
473976
|
+
}
|
|
473977
|
+
}
|
|
473978
|
+
}
|
|
473979
|
+
const tiandituSearchApi = new TiandituSearchApi();
|
|
473980
|
+
const tiandituSearchApi$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
473981
|
+
__proto__: null,
|
|
473982
|
+
TiandituSearchApi,
|
|
473983
|
+
tiandituSearchApi
|
|
473984
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
473985
|
+
class MapSearchService {
|
|
473986
|
+
// 5分钟缓存
|
|
473987
|
+
constructor(config) {
|
|
473988
|
+
__publicField(this, "config");
|
|
473989
|
+
__publicField(this, "cache", /* @__PURE__ */ new Map());
|
|
473990
|
+
__publicField(this, "cacheExpiry", /* @__PURE__ */ new Map());
|
|
473991
|
+
__publicField(this, "CACHE_DURATION", 5 * 60 * 1e3);
|
|
473992
|
+
this.config = config;
|
|
473993
|
+
}
|
|
473994
|
+
/**
|
|
473995
|
+
* 搜索地址
|
|
473996
|
+
*/
|
|
473997
|
+
async search(query) {
|
|
473998
|
+
if (!query || query.length < (this.config.minSearchLength || 2)) {
|
|
473999
|
+
return [];
|
|
474000
|
+
}
|
|
474001
|
+
const cached = this.getFromCache(query);
|
|
474002
|
+
if (cached) {
|
|
474003
|
+
return cached;
|
|
474004
|
+
}
|
|
474005
|
+
let results = [];
|
|
474006
|
+
try {
|
|
474007
|
+
switch (this.config.provider) {
|
|
474008
|
+
case "baidu":
|
|
474009
|
+
results = await this.searchBaidu(query);
|
|
474010
|
+
break;
|
|
474011
|
+
case "amap":
|
|
474012
|
+
results = await this.searchAmap(query);
|
|
474013
|
+
break;
|
|
474014
|
+
case "google":
|
|
474015
|
+
results = await this.searchGoogle(query);
|
|
474016
|
+
break;
|
|
474017
|
+
case "tianditu":
|
|
474018
|
+
results = await this.searchTianditu(query);
|
|
474019
|
+
break;
|
|
474020
|
+
case "custom":
|
|
474021
|
+
results = await this.searchCustom(query);
|
|
474022
|
+
break;
|
|
474023
|
+
default:
|
|
474024
|
+
results = await this.searchTianditu(query);
|
|
474025
|
+
}
|
|
474026
|
+
if (this.config.maxResults) {
|
|
474027
|
+
results = results.slice(0, this.config.maxResults);
|
|
474028
|
+
}
|
|
474029
|
+
this.setCache(query, results);
|
|
474030
|
+
return results;
|
|
474031
|
+
} catch (error2) {
|
|
474032
|
+
console.error("搜索失败:", error2);
|
|
474033
|
+
return [];
|
|
474034
|
+
}
|
|
474035
|
+
}
|
|
474036
|
+
/**
|
|
474037
|
+
* 百度地图搜索
|
|
474038
|
+
*/
|
|
474039
|
+
async searchBaidu(query) {
|
|
474040
|
+
if (!this.config.apiKey) {
|
|
474041
|
+
throw new Error("百度地图API密钥未配置");
|
|
474042
|
+
}
|
|
474043
|
+
const url = "https://api.map.baidu.com/place/v2/search";
|
|
474044
|
+
const params2 = new URLSearchParams({
|
|
474045
|
+
query,
|
|
474046
|
+
region: "全国",
|
|
474047
|
+
output: "json",
|
|
474048
|
+
ak: this.config.apiKey,
|
|
474049
|
+
page_size: String(this.config.maxResults || 10),
|
|
474050
|
+
page_num: "0"
|
|
474051
|
+
});
|
|
474052
|
+
try {
|
|
474053
|
+
const response = await fetch(`${url}?${params2}`, {
|
|
474054
|
+
method: "GET",
|
|
474055
|
+
headers: {
|
|
474056
|
+
"Content-Type": "application/json"
|
|
474057
|
+
}
|
|
474058
|
+
});
|
|
474059
|
+
if (!response.ok) {
|
|
474060
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
474061
|
+
}
|
|
474062
|
+
const data = await response.json();
|
|
474063
|
+
if (data.status !== 0) {
|
|
474064
|
+
throw new Error(`百度API错误: ${data.message || data.status}`);
|
|
474065
|
+
}
|
|
474066
|
+
return this.parseBaiduResults(data.results || []);
|
|
474067
|
+
} catch (error2) {
|
|
474068
|
+
console.error("百度地图搜索失败:", error2);
|
|
474069
|
+
throw error2;
|
|
474070
|
+
}
|
|
474071
|
+
}
|
|
474072
|
+
/**
|
|
474073
|
+
* 高德地图搜索
|
|
474074
|
+
*/
|
|
474075
|
+
async searchAmap(query) {
|
|
474076
|
+
if (!this.config.apiKey) {
|
|
474077
|
+
throw new Error("高德地图API密钥未配置");
|
|
474078
|
+
}
|
|
474079
|
+
const url = "https://restapi.amap.com/v3/place/text";
|
|
474080
|
+
const params2 = new URLSearchParams({
|
|
474081
|
+
keywords: query,
|
|
474082
|
+
key: this.config.apiKey,
|
|
474083
|
+
output: "json",
|
|
474084
|
+
offset: String(this.config.maxResults || 10),
|
|
474085
|
+
page: "1",
|
|
474086
|
+
extensions: "all"
|
|
474087
|
+
});
|
|
474088
|
+
try {
|
|
474089
|
+
const response = await fetch(`${url}?${params2}`, {
|
|
474090
|
+
method: "GET",
|
|
474091
|
+
headers: {
|
|
474092
|
+
"Content-Type": "application/json"
|
|
474093
|
+
}
|
|
474094
|
+
});
|
|
474095
|
+
if (!response.ok) {
|
|
474096
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
474097
|
+
}
|
|
474098
|
+
const data = await response.json();
|
|
474099
|
+
if (data.status !== "1") {
|
|
474100
|
+
throw new Error(`高德API错误: ${data.info || data.status}`);
|
|
474101
|
+
}
|
|
474102
|
+
return this.parseAmapResults(data.pois || []);
|
|
474103
|
+
} catch (error2) {
|
|
474104
|
+
console.error("高德地图搜索失败:", error2);
|
|
474105
|
+
throw error2;
|
|
474106
|
+
}
|
|
474107
|
+
}
|
|
474108
|
+
/**
|
|
474109
|
+
* Google地图搜索
|
|
474110
|
+
*/
|
|
474111
|
+
async searchGoogle(query) {
|
|
474112
|
+
if (!this.config.apiKey) {
|
|
474113
|
+
throw new Error("Google Maps API密钥未配置");
|
|
474114
|
+
}
|
|
474115
|
+
const url = "https://maps.googleapis.com/maps/api/place/textsearch/json";
|
|
474116
|
+
const params2 = new URLSearchParams({
|
|
474117
|
+
query,
|
|
474118
|
+
key: this.config.apiKey,
|
|
474119
|
+
language: "zh-CN",
|
|
474120
|
+
region: "cn"
|
|
474121
|
+
});
|
|
474122
|
+
try {
|
|
474123
|
+
const response = await fetch(`${url}?${params2}`, {
|
|
474124
|
+
method: "GET",
|
|
474125
|
+
headers: {
|
|
474126
|
+
"Content-Type": "application/json"
|
|
474127
|
+
}
|
|
474128
|
+
});
|
|
474129
|
+
if (!response.ok) {
|
|
474130
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
474131
|
+
}
|
|
474132
|
+
const data = await response.json();
|
|
474133
|
+
if (data.status !== "OK") {
|
|
474134
|
+
throw new Error(`Google API错误: ${data.error_message || data.status}`);
|
|
474135
|
+
}
|
|
474136
|
+
return this.parseGoogleResults(data.results || []);
|
|
474137
|
+
} catch (error2) {
|
|
474138
|
+
console.error("Google地图搜索失败:", error2);
|
|
474139
|
+
throw error2;
|
|
474140
|
+
}
|
|
474141
|
+
}
|
|
474142
|
+
/**
|
|
474143
|
+
* 天地图搜索
|
|
474144
|
+
*/
|
|
474145
|
+
async searchTianditu(query) {
|
|
474146
|
+
try {
|
|
474147
|
+
const results = await tiandituSearchApi.search(query, {
|
|
474148
|
+
maxResults: this.config.maxResults || 10,
|
|
474149
|
+
region: "全国",
|
|
474150
|
+
type: "all"
|
|
474151
|
+
});
|
|
474152
|
+
return results;
|
|
474153
|
+
} catch (error2) {
|
|
474154
|
+
console.error("天地图搜索失败:", error2);
|
|
474155
|
+
throw error2;
|
|
474156
|
+
}
|
|
474157
|
+
}
|
|
474158
|
+
/**
|
|
474159
|
+
* 自定义API搜索
|
|
474160
|
+
*/
|
|
474161
|
+
async searchCustom(query) {
|
|
474162
|
+
if (!this.config.customApi) {
|
|
474163
|
+
throw new Error("自定义API配置未设置");
|
|
474164
|
+
}
|
|
474165
|
+
const { url, method = "GET", headers = {}, params: params2 = {}, responseParser } = this.config.customApi;
|
|
474166
|
+
try {
|
|
474167
|
+
const requestParams = { ...params2, query };
|
|
474168
|
+
let requestUrl = url;
|
|
474169
|
+
let requestBody;
|
|
474170
|
+
if (method === "GET") {
|
|
474171
|
+
const urlParams = new URLSearchParams(requestParams);
|
|
474172
|
+
requestUrl = `${url}?${urlParams}`;
|
|
474173
|
+
} else {
|
|
474174
|
+
requestBody = JSON.stringify(requestParams);
|
|
474175
|
+
}
|
|
474176
|
+
const response = await fetch(requestUrl, {
|
|
474177
|
+
method,
|
|
474178
|
+
headers: {
|
|
474179
|
+
"Content-Type": "application/json",
|
|
474180
|
+
...headers
|
|
474181
|
+
},
|
|
474182
|
+
body: requestBody
|
|
474183
|
+
});
|
|
474184
|
+
if (!response.ok) {
|
|
474185
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
474186
|
+
}
|
|
474187
|
+
const data = await response.json();
|
|
474188
|
+
if (responseParser) {
|
|
474189
|
+
return responseParser(data);
|
|
474190
|
+
}
|
|
474191
|
+
return this.parseCustomResults(data);
|
|
474192
|
+
} catch (error2) {
|
|
474193
|
+
console.error("自定义API搜索失败:", error2);
|
|
474194
|
+
throw error2;
|
|
474195
|
+
}
|
|
474196
|
+
}
|
|
474197
|
+
/**
|
|
474198
|
+
* 解析百度地图结果
|
|
474199
|
+
*/
|
|
474200
|
+
parseBaiduResults(results) {
|
|
474201
|
+
return results.map((item, index2) => {
|
|
474202
|
+
var _a3, _b3, _c2, _d;
|
|
474203
|
+
return {
|
|
474204
|
+
id: `baidu_${item.uid || index2}`,
|
|
474205
|
+
name: item.name || "",
|
|
474206
|
+
address: item.address || "",
|
|
474207
|
+
location: [((_a3 = item.location) == null ? void 0 : _a3.lng) || 0, ((_b3 = item.location) == null ? void 0 : _b3.lat) || 0],
|
|
474208
|
+
type: ((_c2 = item.detail_info) == null ? void 0 : _c2.tag) || item.area || "",
|
|
474209
|
+
district: item.district || "",
|
|
474210
|
+
city: item.city || "",
|
|
474211
|
+
province: item.province || "",
|
|
474212
|
+
confidence: ((_d = item.detail_info) == null ? void 0 : _d.overall_rating) ? item.detail_info.overall_rating / 5 : void 0
|
|
474213
|
+
};
|
|
474214
|
+
});
|
|
474215
|
+
}
|
|
474216
|
+
/**
|
|
474217
|
+
* 解析高德地图结果
|
|
474218
|
+
*/
|
|
474219
|
+
parseAmapResults(results) {
|
|
474220
|
+
return results.map((item, index2) => {
|
|
474221
|
+
const location2 = item.location ? item.location.split(",").map(Number) : [0, 0];
|
|
474222
|
+
return {
|
|
474223
|
+
id: `amap_${item.id || index2}`,
|
|
474224
|
+
name: item.name || "",
|
|
474225
|
+
address: item.address || "",
|
|
474226
|
+
location: [location2[0], location2[1]],
|
|
474227
|
+
type: item.type || "",
|
|
474228
|
+
district: item.adname || "",
|
|
474229
|
+
city: item.cityname || "",
|
|
474230
|
+
province: item.pname || "",
|
|
474231
|
+
adcode: item.adcode || "",
|
|
474232
|
+
confidence: item.weight ? parseFloat(item.weight) / 100 : void 0
|
|
474233
|
+
};
|
|
474234
|
+
});
|
|
474235
|
+
}
|
|
474236
|
+
/**
|
|
474237
|
+
* 解析Google地图结果
|
|
474238
|
+
*/
|
|
474239
|
+
parseGoogleResults(results) {
|
|
474240
|
+
return results.map((item, index2) => {
|
|
474241
|
+
var _a3, _b3, _c2, _d, _e2;
|
|
474242
|
+
return {
|
|
474243
|
+
id: `google_${item.place_id || index2}`,
|
|
474244
|
+
name: item.name || "",
|
|
474245
|
+
address: item.formatted_address || "",
|
|
474246
|
+
location: [
|
|
474247
|
+
((_b3 = (_a3 = item.geometry) == null ? void 0 : _a3.location) == null ? void 0 : _b3.lng) || 0,
|
|
474248
|
+
((_d = (_c2 = item.geometry) == null ? void 0 : _c2.location) == null ? void 0 : _d.lat) || 0
|
|
474249
|
+
],
|
|
474250
|
+
type: ((_e2 = item.types) == null ? void 0 : _e2[0]) || "",
|
|
474251
|
+
confidence: item.rating ? item.rating / 5 : void 0
|
|
474252
|
+
};
|
|
474253
|
+
});
|
|
474254
|
+
}
|
|
474255
|
+
/**
|
|
474256
|
+
* 解析自定义API结果
|
|
474257
|
+
*/
|
|
474258
|
+
parseCustomResults(data) {
|
|
474259
|
+
if (Array.isArray(data)) {
|
|
474260
|
+
return data;
|
|
474261
|
+
}
|
|
474262
|
+
if (data.results && Array.isArray(data.results)) {
|
|
474263
|
+
return data.results;
|
|
474264
|
+
}
|
|
474265
|
+
if (data.data && Array.isArray(data.data)) {
|
|
474266
|
+
return data.data;
|
|
474267
|
+
}
|
|
474268
|
+
return [];
|
|
474269
|
+
}
|
|
474270
|
+
/**
|
|
474271
|
+
* 获取缓存
|
|
474272
|
+
*/
|
|
474273
|
+
getFromCache(query) {
|
|
474274
|
+
const cached = this.cache.get(query);
|
|
474275
|
+
const expiry = this.cacheExpiry.get(query);
|
|
474276
|
+
if (cached && expiry && Date.now() < expiry) {
|
|
474277
|
+
return cached;
|
|
474278
|
+
}
|
|
474279
|
+
this.cache.delete(query);
|
|
474280
|
+
this.cacheExpiry.delete(query);
|
|
474281
|
+
return null;
|
|
474282
|
+
}
|
|
474283
|
+
/**
|
|
474284
|
+
* 设置缓存
|
|
474285
|
+
*/
|
|
474286
|
+
setCache(query, results) {
|
|
474287
|
+
this.cache.set(query, results);
|
|
474288
|
+
this.cacheExpiry.set(query, Date.now() + this.CACHE_DURATION);
|
|
474289
|
+
if (this.cache.size > 100) {
|
|
474290
|
+
const firstKey = this.cache.keys().next().value;
|
|
474291
|
+
this.cache.delete(firstKey);
|
|
474292
|
+
this.cacheExpiry.delete(firstKey);
|
|
474293
|
+
}
|
|
474294
|
+
}
|
|
474295
|
+
/**
|
|
474296
|
+
* 清理缓存
|
|
474297
|
+
*/
|
|
474298
|
+
clearCache() {
|
|
474299
|
+
this.cache.clear();
|
|
474300
|
+
this.cacheExpiry.clear();
|
|
474301
|
+
}
|
|
474302
|
+
/**
|
|
474303
|
+
* 更新配置
|
|
474304
|
+
*/
|
|
474305
|
+
updateConfig(config) {
|
|
474306
|
+
this.config = config;
|
|
474307
|
+
this.clearCache();
|
|
474308
|
+
}
|
|
474309
|
+
}
|
|
473777
474310
|
const _hoisted_1$a = { class: "search-input-wrapper" };
|
|
473778
474311
|
const _hoisted_2$a = { class: "search-results" };
|
|
473779
474312
|
const _hoisted_3$a = {
|
|
@@ -473817,7 +474350,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
473817
474350
|
enabled: true,
|
|
473818
474351
|
position: "top-left",
|
|
473819
474352
|
placeholder: "搜索地点...",
|
|
473820
|
-
provider: "
|
|
474353
|
+
provider: "tianditu",
|
|
473821
474354
|
maxResults: 10,
|
|
473822
474355
|
showHistory: true,
|
|
473823
474356
|
searchDelay: 300,
|
|
@@ -473828,6 +474361,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
473828
474361
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
473829
474362
|
const props = __props;
|
|
473830
474363
|
const emit = __emit;
|
|
474364
|
+
const searchService = new MapSearchService(props.config);
|
|
473831
474365
|
const searchQuery = ref("");
|
|
473832
474366
|
const searchResults = ref([]);
|
|
473833
474367
|
const searchHistory = ref([]);
|
|
@@ -473929,6 +474463,9 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
473929
474463
|
isLoading.value = true;
|
|
473930
474464
|
showResults.value = true;
|
|
473931
474465
|
try {
|
|
474466
|
+
debugger;
|
|
474467
|
+
const results = await searchService.search(query);
|
|
474468
|
+
searchResults.value = results;
|
|
473932
474469
|
emit("search", query);
|
|
473933
474470
|
} catch (error2) {
|
|
473934
474471
|
console.error("搜索失败:", error2);
|
|
@@ -473942,6 +474479,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
473942
474479
|
showResults.value = false;
|
|
473943
474480
|
selectedIndex.value = -1;
|
|
473944
474481
|
addToHistory(result);
|
|
474482
|
+
debugger;
|
|
473945
474483
|
emit("select", result);
|
|
473946
474484
|
};
|
|
473947
474485
|
const selectHistoryItem = (item) => {
|
|
@@ -474211,7 +474749,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
474211
474749
|
};
|
|
474212
474750
|
}
|
|
474213
474751
|
});
|
|
474214
|
-
const MapSearch = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-
|
|
474752
|
+
const MapSearch = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-8babff5c"]]);
|
|
474215
474753
|
const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
474216
474754
|
__name: "index",
|
|
474217
474755
|
props: {
|
|
@@ -479429,6 +479967,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
479429
479967
|
});
|
|
479430
479968
|
};
|
|
479431
479969
|
const onSearch = (query) => {
|
|
479970
|
+
debugger;
|
|
479432
479971
|
if (mapContainerRef.value && mapContainerRef.value.handleSearch) {
|
|
479433
479972
|
mapContainerRef.value.handleSearch(query);
|
|
479434
479973
|
}
|
|
@@ -479438,6 +479977,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
479438
479977
|
if (mapContainerRef.value && mapContainerRef.value.handleSearchSelect) {
|
|
479439
479978
|
mapContainerRef.value.handleSearchSelect(result);
|
|
479440
479979
|
}
|
|
479980
|
+
debugger;
|
|
479441
479981
|
emit("search-select", result);
|
|
479442
479982
|
};
|
|
479443
479983
|
const onSearchClear = () => {
|
|
@@ -480048,7 +480588,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
480048
480588
|
};
|
|
480049
480589
|
}
|
|
480050
480590
|
});
|
|
480051
|
-
const CustomOpenlayer = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
480591
|
+
const CustomOpenlayer = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-b6c093eb"]]);
|
|
480052
480592
|
var u8 = Uint8Array;
|
|
480053
480593
|
var u16 = Uint16Array;
|
|
480054
480594
|
var i32 = Int32Array;
|
|
@@ -488320,7 +488860,7 @@ function(t3) {
|
|
|
488320
488860
|
*/
|
|
488321
488861
|
function(t3) {
|
|
488322
488862
|
function e8() {
|
|
488323
|
-
return (n.canvg ? Promise.resolve(n.canvg) : import("./index.es-
|
|
488863
|
+
return (n.canvg ? Promise.resolve(n.canvg) : import("./index.es-342b25b8.mjs")).catch(function(t4) {
|
|
488324
488864
|
return Promise.reject(new Error("Could not load canvg: " + t4));
|
|
488325
488865
|
}).then(function(t4) {
|
|
488326
488866
|
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-
|
|
1
|
+
import { c as commonjsGlobal, R as RGBColor, r as requestAnimationFrame, _ as _asyncToGenerator, a as _, p as processCanvasRGBA, b as _defineProperty } from "./index-ead1b915.mjs";
|
|
2
2
|
import "vue";
|
|
3
3
|
import "ol";
|
|
4
4
|
var check = function(it) {
|
package/lib/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z, B, d, C, D, a2, a3, u, y, I, H, Z, $, L, J, K, a4, h, M, a0, a1, X, Y, U, W, Q, S, P, A, F, G, N, O, 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, I, H, Z, $, L, J, K, a4, h, M, a0, a1, X, Y, U, W, Q, S, P, A, F, G, N, O, e, T, E, V, x, j, o, t, f, k, g, w, q, m, n, a5, i, s, l, v } from "./index-ead1b915.mjs";
|
|
2
2
|
import "vue";
|
|
3
3
|
import "ol";
|
|
4
4
|
export {
|