weixin_54363108 2021-12-17 10:48 采纳率: 84.2%
浏览 2370
已结题

vue开发高德地图点击地图获取到了经纬度但是用逆地理编码获取信息失败返回INVALID_USER_SCODE

// 初始化地图
    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, "错误");
      }
    },

  • 写回答

2条回答 默认 最新

  • 崽崽的谷雨 2021-12-17 11:00
    关注

    这个的得看 api 得说明文档 具体代表什么

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 1月5日
  • 已采纳回答 12月28日
  • 修改了问题 12月17日
  • 创建了问题 12月17日

悬赏问题

  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示