// 初始化地图
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 得说明文档 具体代表什么
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决评论 打赏 举报无用 23
悬赏问题
- ¥15 C#算法问题, 不知道怎么处理这个数据的转换
- ¥15 YoloV5 第三方库的版本对照问题
- ¥15 请完成下列相关问题!
- ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
- ¥15 求daily translation(DT)偏差订正方法的代码
- ¥15 js调用html页面需要隐藏某个按钮
- ¥15 ads仿真结果在圆图上是怎么读数的
- ¥20 Cotex M3的调试和程序执行方式是什么样的?
- ¥20 java项目连接sqlserver时报ssl相关错误
- ¥15 一道python难题3