// 初始化地图
init() {
AMapLoader.load({
key: "20e*****************fef3bcd2", // 申请好的Web端开发者Key
version: "2.0", // 指定要加载的 JSAPI 的版本
plugins: ["AMap.Geolocation", "AMap.Geocoder", "AMap.Marker"], // 需要使用的的插件列表
})
.then((AMap) => {
this.map = new AMap.Map("map", {
zoom: 13, //缩放比例
center: [120.306376, 31.588048],
viewMode: "2D",
terrain: true, //开启地形图
mapStyle: "amap://styles/dark",
});
})
.catch((e) => {
console.log(e, "地图加载失败");
});
},
//点击地图
clickLocation() {
this.map.on("click", this.clickMap);
},
clickMap(e) {
let arr = [e.lnglat.lng, e.lnglat.lat];
console.log(arr);
if (this.mark) {
this.map.removeControl(this.mark);
}
this.mark = new AMap.Marker({
position: arr,
});
this.geocoder = new AMap.Geocoder({
city: "全国",
radius: 500,
extensions: "all",
});
this.map.addControl(this.mark);
try {
this.geocoder.getAddress(arr, function (status, result) {
console.log(status, result);
});
} catch (error) {
console.log(error, "错误");
}
},

vue开发高德地图点击地图获取到了经纬度但是用逆地理编码获取信息失败返回INVALID_USER_SCODE
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- 崽崽的谷雨 2021-12-17 11:00关注
这个的得看 api 得说明文档 具体代表什么
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决评论 打赏 举报无用 26