vue 高德地图JSAPI 根据经纬度获取地址
·
1,"AMap.Geocoder" 插件
AMapLoader.load({
key: "", // 申请好的Web端开发者Key,首次调用 load 时必填
version: "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
plugins: ["AMap.Scale", "AMap.Geocoder" ], //需要使用的的插件列表,如比例尺'AMap.Scale'支
持添加多个如:['...','...']
})
2,创建AMap.Geocoder实例,调用getAddress,具体参数参考官网
result 即为地址
const geocoder = new AMap.Geocoder({
city: '全国',
radius: 500 //范围,默认:500
})
geocoder.getAddress(markerPosition.value, async (status, result) => {
// console.log(status, result)
if (status === 'complete' && result.info === 'OK') {
// result为对应的地理位置详细信息
console.log('address=========', result.regeocode.formattedAddress);
basicInfo.value.locationDetail = result.regeocode.formattedAddress
await workOrderApi.updateWorkerOrderById({ id: Number(eventId), locationDetail: result.regeocode.formattedAddress })
}
})
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)