Xcode地图屏幕并获得路线问题

时间:2018-10-14 19:22:19

标签: ios swift dictionary screen

此主题可能以前已经打开过,但是导航无法正常运行,请帮助

我在导航无法打开的地方犯了一个错误

enter image description here enter image description here

@IBAction func clickAppleMaps(_ sender: UIButton) {
    let url = "http://maps.apple.com/maps?daddr=\(latitude),\(longitude)"

    if #available(iOS 10, *) {
        UIApplication.shared.open(URL(string:url)!)
    }else{
        UIApplication.shared.openURL(URL(string:url)!)
    }
}

@IBAction func clickGoogleMaps(_ sender: UIButton) {

    if (UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!)){

        if #available(iOS 10, *) {

            UIApplication.shared.open(NSURL(string:
                "comgooglemaps://?saddr=&daddr=\(Float(latitude)),\(Float(longitude))&directionsmode=driving")! as URL)
        } else {
            UIApplication.shared.openURL(NSURL(string:
                "comgooglemaps://?saddr=&daddr=\(Float(latitude)),\(Float(longitude))&directionsmode=driving")! as URL)
        }
    } else{
        NSLog("Can't use com.google.maps://");
    }
}

0 个答案:

没有答案