一.根据高德地图文档的链接跳转

该方法我使用时,IOS一直没法跳转,希望有大神可以解惑,所以我是使用的第二种方法跳转的,见后

 /* 判断是ios还是安卓 */
  handleGoto(marker) {
      let UserLocation = marker.position;
      var u = navigator.userAgent,
        app = navigator.appVersion;
      var isAndroid = u.indexOf("Android") > -1 || u.indexOf("Linux") > -1; //android终端或者uc浏览器
      var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
      console.log(isiOS);
      let poiname = marker.name;//终点地址名称
      if (isAndroid) {
        let url =
          "androidamap://navi?sourceApplication=amap&poiname=" +
          poiname +
          "&lat=" +
          UserLocation[1] +
          "&lon=" +
          UserLocation[0] +
          "&dev=1&style=2";
        window.open(url);
      }
      if (isiOS) {
        console.log("是否进入IOS跳转");
         let url =
          "iosamap://viewMap?sourceApplication=amap&poiname=" +
          poiname +
          "&lat=" +
          UserLocation[1] +
          "&lon=" +
          UserLocation[0] +
          "&dev=0";
        window.open(url);
      }
}

2.跳转链接

不需要区分安卓和IOS系统,直接跳转,position分别接收经纬度,name接收终点名称

 window.open(`http://uri.amap.com/marker?position=${UserLocation[0]},${UserLocation[1]}&name=${poiname}&coordinate=gaode&callnative=1`);
Logo

前往低代码交流专区

更多推荐