⚡ 统一地图选址搜索为高德 place/text 并展示分页候选
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -323,7 +323,7 @@ import { addressTypeOptions } from '@/option/base/common-address';
|
||||
import { config, excelOption, option } from '@/option/business/common-route';
|
||||
import { getToken } from '@/utils/auth';
|
||||
import { openImportDialog } from '@/utils/import-excel';
|
||||
import { normalizeMapSearchResults } from '@/utils/map-search';
|
||||
import { normalizeMapSearchResults, searchAmapPlaceText } from '@/utils/map-search';
|
||||
import { downloadXls } from '@/utils/util';
|
||||
import { isMobile } from '@/utils/validate';
|
||||
import { List, Search } from '@element-plus/icons-vue';
|
||||
@@ -610,25 +610,29 @@ export default {
|
||||
this.$message.warning('请输入地址关键词');
|
||||
return;
|
||||
}
|
||||
if (this.routeMapLoading) return;
|
||||
this.routeMapSearchResults = [];
|
||||
this.routeMapLoading = true;
|
||||
this.loadAmap()
|
||||
.then(() => {
|
||||
this.routeMapLoading = true;
|
||||
return this.ensureRouteAmapGeocoder();
|
||||
})
|
||||
.then(() => this.runAmapGeocode('location', keyword))
|
||||
.then(result => {
|
||||
this.routeMapSearchResults = normalizeMapSearchResults(result, keyword);
|
||||
const point = this.resolveMapPoint(result);
|
||||
if (!point) {
|
||||
.then(() => searchAmapPlaceText(keyword))
|
||||
.then(pois => {
|
||||
this.routeMapSearchResults = normalizeMapSearchResults(pois, keyword);
|
||||
const first = this.routeMapSearchResults[0];
|
||||
if (!first?.location) {
|
||||
this.routeMapStatus = '未找到匹配地址';
|
||||
this.$message.warning('地图搜索无匹配地址');
|
||||
return;
|
||||
}
|
||||
this.pickRouteMapPoint(point, keyword);
|
||||
return this.$nextTick().then(() => {
|
||||
if (typeof this.routeAmap?.resize === 'function') {
|
||||
this.routeAmap.resize();
|
||||
}
|
||||
this.pickRouteMapPoint(first.location, first.address || first.name || keyword);
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
this.routeMapStatus = '地图搜索失败';
|
||||
this.$message.error('地图搜索失败,请稍后重试');
|
||||
this.routeMapStatus = '未找到匹配地址';
|
||||
this.$message.warning('地图搜索无匹配地址');
|
||||
})
|
||||
.finally(() => {
|
||||
this.routeMapLoading = false;
|
||||
|
||||
Reference in New Issue
Block a user