⚡ 统一地图选址搜索为高德 place/text 并展示分页候选
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1727,7 +1727,7 @@ import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { Location, Rank, Refresh, Search, Setting } from '@element-plus/icons-vue';
|
||||
import dayjs from 'dayjs';
|
||||
import { isMobile } from '@/utils/validate';
|
||||
import { normalizeMapSearchResults } from '@/utils/map-search';
|
||||
import { normalizeMapSearchResults, searchAmapPlaceText } from '@/utils/map-search';
|
||||
|
||||
const defaultTransportType = '';
|
||||
const defaultCandidateTransportType = '';
|
||||
@@ -3390,31 +3390,26 @@ export default {
|
||||
ElMessage.warning('请输入地址关键词');
|
||||
return;
|
||||
}
|
||||
if (this.routeChangeMapLoading) return;
|
||||
this.routeChangeMapSearchResults = [];
|
||||
this.routeChangeMapLoading = true;
|
||||
this.loadDetailAmap()
|
||||
.then(() => this.ensureRouteChangeMapGeocoder())
|
||||
.then(
|
||||
() =>
|
||||
new Promise((resolve, reject) => {
|
||||
this.routeChangeMapGeocoder.getLocation(keyword, (status, result) => {
|
||||
if (status === 'complete') resolve(result);
|
||||
else reject(result);
|
||||
});
|
||||
})
|
||||
)
|
||||
.then(result => {
|
||||
this.routeChangeMapSearchResults = normalizeMapSearchResults(result, keyword);
|
||||
const point = this.routeChangeMapSearchResults[0]?.location;
|
||||
if (!point) {
|
||||
.then(() => searchAmapPlaceText(keyword))
|
||||
.then(pois => {
|
||||
this.routeChangeMapSearchResults = normalizeMapSearchResults(pois, keyword);
|
||||
const first = this.routeChangeMapSearchResults[0];
|
||||
if (!first?.location) {
|
||||
this.routeChangeMapStatus = '未找到匹配地址';
|
||||
ElMessage.warning('地图搜索无匹配地址');
|
||||
return;
|
||||
}
|
||||
this.pickRouteChangeMap(point, keyword);
|
||||
return this.$nextTick().then(() => {
|
||||
this.pickRouteChangeMap(first.location, first.address || first.name || keyword);
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
this.routeChangeMapStatus = '地图搜索失败';
|
||||
ElMessage.error('地图搜索失败');
|
||||
this.routeChangeMapStatus = '未找到匹配地址';
|
||||
ElMessage.warning('地图搜索无匹配地址');
|
||||
})
|
||||
.finally(() => {
|
||||
this.routeChangeMapLoading = false;
|
||||
|
||||
Reference in New Issue
Block a user