uniapp 地图跳转到第三方导航软件 直接打包成apk

javascript 复制代码
// 判断是否存在导航软件
      judgeHasExistNavignation() {
        let navAppParam = [{
            pname: 'com.baidu.BaiduMap',
            action: 'baidumap://'
          }, // 百度
          {
            pname: 'com.autonavi.minimap',
            action: 'iosamap://'
          }, // 高德
          {
            pname: 'com.tencent.map',
            action: 'tencentmap://'
          }, // 腾讯
        ];
        return navAppParam.some(param => {
          return plus.runtime.isApplicationExist(param);
        })
      },
      // 获取用户当前定位
      getPosition() {
        let that = this;
        return new Promise(resolve => {
          uni.getLocation({
            type: 'gcj02',
            geocode: true, //设置该参数为true可直接获取经纬度及城市信息
            success: function(res) {
              let {
                latitude,
                longitude
              } = res
              that.curSysPosition.latitude = latitude;
              that.curSysPosition.longitude = longitude;
              resolve();
            }
          });
        })
      },
      //  打开第三方地图  info对象是目的地的经纬度数据
      // this.info:{
      //   x:
      //   y:
      // }
      async handleOpenNavigation() {
        const lat = this.info.y; //纬度
        const lng = this.info.x; //经度
        const address = '目的地';
        if (!this.judgeHasExistNavignation()) {
          return this.$showToast("该设备上不存在第三方导航APP");
        }
        await this.getPosition();
        let {
          latitude,
          longitude
        } = this.curSysPosition;
        let tLngLat = new plus.maps.Point(lng, lat); // 目的地
        let oLngLat = new plus.maps.Point(longitude, latitude); // 起始地
        plus.maps.openSysMap(tLngLat, address, oLngLat);
      },
      // 地图导航
      toNearbyStore() {
        var url = '';
        const address = '去到这里';
        //地址
        const latitude = this.info.y; //纬度
        const longitude = this.info.x; //精度
        url = 'geo:' + latitude + ',' + longitude + '?q=' + encodeURIComponent(address);
        if (uni.getSystemInfoSync().platform == 'android') {
          plus.runtime.openURL(url);
        } else {
          plus.nativeUI.actionSheet({
            title: "选择地图应用",
            cancel: "取消",
            buttons: [{
              title: "Apple地图"
            }, {
              title: "百度地图"
            }, {
              title: "高德地图"
            }, {
              title: "google地图"
            }]
          }, function(e) {
            console.log("e.index: " + e.index);
            switch (e.index) {
              case 1:
                url =
                  `http://maps.apple.com/?q=${encodeURIComponent(address)}&ll=${latitude},${longitude}&spn=0.008766,0.019441`
                break;
              case 2:
                url = `baidumap://map/marker?location=${latitude},${longitude}&title=DCloud&src=Hello%20uni-app`;
                break;
              case 3:
                url =
                  `iosamap://viewMap?sourceApplication=Hello%20uni-app&poiname=DCloud&lat=${latitude}&lon=${longitude}&dev=0`;
                break;
              case 4:
                url = `comgooglemaps://?q=${encodeURIComponent(address)}&center=${latitude},${longitude}`;
                break;
                plus.runtime.openURL(url, function(e) {
                  plus.nativeUI.alert("未安装此地图");
                });
            }
          })
        }
      },
相关推荐
结网的兔子2 天前
【前端开发】Web端迁移至 uni-app 及鸿蒙扩展方案对比
前端·uni-app·harmonyos
2501_915909062 天前
iOS 应用反调试技详解术 检测调试器的原理与防护实践
android·ios·小程序·https·uni-app·iphone·webview
AI多Agent协作实战派2 天前
AI多Agent协作系统实战(二十八):顶栏统一战争——从1个页面异常到31个页面全量对齐
数据库·人工智能·uni-app
00后程序员张2 天前
iOS加固技术路线全面解析:Bitcode模式、源码模式与汇编模式对比及爱加密优势
android·汇编·ios·小程序·uni-app·cocoa·iphone
2501_916008893 天前
iOS IPA文件反编译与打包操作方法,拆包分析防护和加固打包
android·macos·ios·小程序·uni-app·cocoa·iphone
name好难取诶3 天前
通过对云基座和离线基座的对比,帮助开发者理解如何在不同场景下选择合适的打包方案。 什么是“基座” 在 UniApp 中,基座(也称“ ...
开发语言·uni-app·php
2501_915921433 天前
iOS手游安全反外挂解决方案:基于Xcode的加固混淆特色详解
android·安全·ios·小程序·uni-app·iphone·xcode
2501_916007473 天前
iOS App分发教程 App Store、TestFlight 与 Ad Hoc 的配置与上传方法
android·ios·小程序·https·uni-app·iphone·webview
qq_316837753 天前
uniapp 打包APP 使用 Galacean Effects 的特效
uni-app
古韵4 天前
你的 uni-app 分页,一个 hook 搞定竞态和加载
javascript·vue.js·uni-app