vue中跳转到第三方导航定位

vue中跳转到第三方导航定位

 

 

 

onConfirm(val,index){
                let longitude=this.lon,
                latitude=this.lat
          let name =this.name;
          let url = "";
          const u = navigator.userAgent;
          const isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
          const isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') >-1;
          if(isAndroid){
              switch (index) {
                  //下面是拼接url,不同系统以及不同地图都有不同的拼接字段
                  case 2:
                      //注意referer=xxx的xxx替换成你在腾讯地图开发平台申请的key
                      url = `qqmap://map/geocoder?coord=${latitude},${longitude}&referer=xxxxxxx`;
                      break;
                  case 1:
                      url = `baidumap://map/marker?location=${latitude},${longitude}&title=${name}&coord_type=gcj02&src=andr.baidu.openAPIdemo`;
                      break;
                  case 0:
                      url = `androidamap://viewMap?sourceApplication=appname&poiname=${name}&lat=${latitude}&lon=${longitude}&dev=0`;
                      break;
                  default:
                      break;
              }
              if (url != "") {
                  window.location.href = url
              }
          }else if(isiOS){
              switch (index) {
                  case 2:
                      url = `qqmap://map/geocoder?coord=${latitude},${longitude}&referer=xxxxxxxx`;
                      break;
                  case 1:
                      url = `baidumap://map/marker?location=${latitude},${longitude}&title=${name}&content=${name}&src=ios.baidu.openAPIdemo&coord_type=gcj02`;
                      break;
                  case 0:
                      url = `iosamap://viewMap?sourceApplication=applicationName&poiname=${name}&lat=${latitude}&lon=${longitude}&dev=0`;
                      break;
                  default:
                      break;
              }
              if (url != "") {
                  window.location.href = url
              }
          }
      
            }

 

上一篇:uni-app打开第三方地图


下一篇:uni-app微信小程序打开APP地图方法