⚡ 统一地图选址搜索为高德 place/text 并展示分页候选
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -270,7 +270,7 @@ import { createOption } from '@/option/base/common-address';
|
||||
import { mapGetters } from 'vuex';
|
||||
import { downloadXls } from '@/utils/util';
|
||||
import { getToken } from '@/utils/auth';
|
||||
import { normalizeMapSearchResults } from '@/utils/map-search';
|
||||
import { normalizeMapSearchResults, searchAmapPlaceText } from '@/utils/map-search';
|
||||
import { isMobile } from '@/utils/validate';
|
||||
import NProgress from 'nprogress';
|
||||
import 'nprogress/nprogress.css';
|
||||
@@ -1112,31 +1112,32 @@ export default {
|
||||
this.$message.warning('请输入地址关键词');
|
||||
return;
|
||||
}
|
||||
if (this.mapLoading) return;
|
||||
this.mapSearchResults = [];
|
||||
this.mapLoading = true;
|
||||
this.loadAmap()
|
||||
.then(() => {
|
||||
this.mapLoading = true;
|
||||
this.ensureAmapGeocoder()
|
||||
.then(() => this.runAmapGeocode('location', keyword))
|
||||
.then(result => {
|
||||
this.mapSearchResults = normalizeMapSearchResults(result, keyword);
|
||||
const point = this.resolveMapPoint(result);
|
||||
if (!point) {
|
||||
this.mapStatus = '未找到匹配地址';
|
||||
this.$message.warning('地图搜索无匹配地址');
|
||||
return;
|
||||
}
|
||||
this.pickMapPoint(point, keyword);
|
||||
})
|
||||
.catch(() => {
|
||||
this.mapStatus = '地图搜索失败';
|
||||
this.$message.error('地图搜索失败,请稍后重试');
|
||||
})
|
||||
.finally(() => {
|
||||
this.mapLoading = false;
|
||||
});
|
||||
.then(() => searchAmapPlaceText(keyword))
|
||||
.then(pois => {
|
||||
this.mapSearchResults = normalizeMapSearchResults(pois, keyword);
|
||||
const first = this.mapSearchResults[0];
|
||||
if (!first?.location) {
|
||||
this.mapStatus = '未找到匹配地址';
|
||||
this.$message.warning('地图搜索无匹配地址');
|
||||
return;
|
||||
}
|
||||
return this.$nextTick().then(() => {
|
||||
if (typeof this.amap?.resize === 'function') {
|
||||
this.amap.resize();
|
||||
}
|
||||
this.pickMapPoint(first.location, first.address || first.name || keyword);
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
this.$message.error('高德地图组件加载失败,请稍后重试或重新打开弹窗');
|
||||
this.mapStatus = '未找到匹配地址';
|
||||
this.$message.warning('地图搜索无匹配地址');
|
||||
})
|
||||
.finally(() => {
|
||||
this.mapLoading = false;
|
||||
});
|
||||
},
|
||||
selectMapSearchResult(item) {
|
||||
|
||||
Reference in New Issue
Block a user