提交 e1ce86bb 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

feat(h5 map): chooseLocation 支持高德地图

上级 7fc60a74
...@@ -107,7 +107,7 @@ function useList(state: State) { ...@@ -107,7 +107,7 @@ function useList(state: State) {
list.push({ list.push({
name: item.title, name: item.title,
address: item.address, address: item.address,
distance: item._distance, distance: item._distance || item.distance,
latitude: item.location.lat, latitude: item.location.lat,
longitude: item.location.lng, longitude: item.location.lng,
}) })
...@@ -186,6 +186,47 @@ function useList(state: State) { ...@@ -186,6 +186,47 @@ function useList(state: State) {
listState.loading = false listState.loading = false
} }
) )
} else if (mapInfo.type === MapType.AMAP) {
window.AMap.plugin('AMap.PlaceSearch', function () {
var autoOptions = {
city: '全国',
pageSize: 10,
pageIndex: listState.pageIndex,
}
var placeSearch = new (window.AMap as any).PlaceSearch(autoOptions)
if (state.searching) {
placeSearch.searchNearBy(
state.keyword,
[state.longitude, state.latitude],
50000,
function (status: string, result: any) {
if (status === 'error') {
console.error(result)
} else if (status === 'no_data') {
listState.hasNextPage = false
} else {
pushData(result.poiList.pois)
}
}
)
} else {
placeSearch.searchNearBy(
'',
[state.longitude, state.latitude],
5000,
function (status: string, result: any) {
if (status === 'error') {
console.error(result)
} else if (status === 'no_data') {
listState.hasNextPage = false
} else {
pushData(result.poiList.pois)
}
}
)
}
listState.loading = false
})
} }
} }
function loadMore() { function loadMore() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册