// 初始化地图
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条回答
相关推荐 更多相似问题
点击登录
提问题
悬赏问题
- ¥15 vs创建SQL Server数据库时出现“系统找不到指定的路径”
- ¥15 网页超时时间设置失效
- ¥15 有关绿色信贷毕业论文的问题
- ¥30 关于#机器人#的问题,如何解决?
- ¥15 求MATLAB函数ScalarLayerDisplay的代码
- ¥15 安卓如何自动执行检测到的NFC标签,无需再点确认
- ¥15 pyHM库mouse模块的ValueError错误
- ¥15 python opencv 摄像头 传感器
- ¥30 eMMC&Android&C&Linux
- ¥15 uniapp ios恢复购买