跳转百度地图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
}
}
网友评论