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
              }
          }
      
            }

 

posted @ 2021-05-28 09:21  will很忙  阅读(488)  评论(0编辑  收藏  举报