移动端跳转到高德、百度地图导航

移动端跳转到高德、百度地图导航

// 点击跳转确认按钮执行的方法
    jumpmapsure(buttontype) {
      let _this = this;
      this.mapjumptype = false; //关闭弹窗
      if (!this.nowlon || !this.nowlat) {
        return this.$toast.fail("未获取到当前位置");
      } else if (!this.endnowlon || !this.endnowlat) {
        return this.$toast.fail("未获取到地块坐标");
      }
      var s = {
        slng: this.nowlon,
        slat: this.nowlat,
        slocation: "当前位置",
        // city: ''
      }; //起点地址信息
      var e = {
        lng: this.endnowlon,
        lat: this.endnowlat,
        location: this.dkxxData.dkMc || "地块坐标",
        // city: ''
      }; //终点地址信息
      if (buttontype == "gddttype") {
        // 跳转到网页地图
        window.location.href = `androidamap://navi?sourceApplication=msite&lat=${e.lat}&lon=${e.lng}&dev=0&style=2`;
        this.openfalse("请先下载高德地图");
      } else if (buttontype == "bddttype") {
        window.location.href = `bdapp://map/direction?
				origin=latlng:${s.slat},${s.slng}|name:${s.slocation}
				&destination=latlng:${e.lat},${e.lng}|name:${e.location}
				&mode=driving&coord_type=wgs84&output=html
				&origin_region=${s.city}&destination_region=${e.city}
				&src=webapp.baidu.openAPIdemo`;
        this.openfalse("请先下载百度地图");
      }
    },
    openfalse(text) {
      //以下代码为判断app是否已经打开
      let _this = this;
      let startTime = Date.now();
      let count = 0;
      let endTime = 0;
      let t = setInterval(function () {
        count += 1;
        endTime = Date.now() - startTime;
        //如果800毫秒后还未打开,清楚定时器,直接打开浏览器端
        if (endTime > 800) {
          _this.$toast.fail(text);
          clearInterval(t);
        }
        if (count < 30) return;
        //(是否打开的判断逻辑为当前页面是否进入后台)
        if (!(document.hidden || document.webkitHidden)) {
          console.log("dia打开地图是吧");
        }
        //20为20毫秒判断一次,app是否打开
      }, 20);
      window.onblur = function () {
        clearInterval(t);
      };
    },
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值