美文网首页
swift 调起三方app

swift 调起三方app

作者: 舟_e9ce | 来源:发表于2021-08-13 15:46 被阅读0次

跳转百度地图url https://lbsyun.baidu.com/index.php?title=uri/api/ios
跳转高德地图url https://lbs.amap.com/api/amap-mobile/guide/ios/ios-uri-information

GlobalTools.Dlog("高德地图")
                let urlString : String = "iosamap://navi?sourceApplication=导航功能&backScheme=djlsj&lat=\(self.orgVipLocationModel.latitude)&lon=\(self.orgVipLocationModel.longitude)&dev=0&style=2"
                if self.openMap(urlString) == false {
                    LKHUD.flash(.label("您还没有安装高德地图"), delay: kTime)
                }

GlobalTools.Dlog("百度地图")
                let urlString = "baidumap://map/direction?origin={{我的位置}}&destination=latlng:\(self.orgVipLocationModel.latitude),\(self.orgVipLocationModel.longitude)|name=中国&mode=walking&coord_type=gcj02"
                if self.openBaiduMap(urlString) == false {
                    LKHUD.flash(.label("您还没有安装百度地图"), delay: kTime)
                }

func openMap(_ urlString : String) -> Bool {
        if UIApplication.shared.canOpenURL(URL(string: "iosamap://")!) {
            let str = urlString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
            let url = URL(string: str!)
            UIApplication.shared.openURL(url!)
            return true
        } else {
            return false
        }
    }
    
    func openBaiduMap(_ urlString : String) -> Bool {
        if UIApplication.shared.canOpenURL(URL(string: "baidumap://")!) {
            let str = urlString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
            let url = URL(string: str!)
            UIApplication.shared.openURL(url!)
            return true
        } else {
            return false
        }
    }

相关文章

网友评论

      本文标题:swift 调起三方app

      本文链接:https://www.haomeiwen.com/subject/yzzdbltx.html