【问题标题】:how to draw route between two location in apple map. by openURL如何在苹果地图中的两个位置之间绘制路线。通过 openURL
【发布时间】:2018-01-26 12:27:34
【问题描述】:

在我的应用程序中,我正在获取该位置的源地址和目标地址。现在通过使用经纬度我想在这两个位置之间绘制路线,我想在苹果地图中打开它。 现在我正在使用这个

 let url = URL(string: "http://maps.apple.com/maps?daddr=\(destlat),\(destlong)&dirflg=d")!

        print(url)
        if #available(iOS 10.0, *) {
            UIApplication.shared.open(url, options: [:], completionHandler: nil)
        }
        else
        {
            UIApplication.shared.openURL(url)
        }

但这仅向我显示两个位置并显示“路线不可用

那我该如何解决呢?

【问题讨论】:

    标签: ios swift location apple-maps


    【解决方案1】:

    试试这个。

    let urlString = "http://maps.apple.com/maps?saddr=\(latStart),\(lngStart)&daddr=\(latEnd),\(lngEnd)&dirflg=d"
    UIApplication.shared.open(URL(string: urlString)!, options: [:], completionHandler: nil)
    
    1. 传递 latStart,lngStart 作为您的当前位置
    2. latEndlngEnd 作为您的 目的地位置

    3. 更多信息显示此链接。 https://developer.apple.com/library/content/featuredarticles/iPhoneURLScheme_Reference/MapLinks/MapLinks.html

    【讨论】:

      猜你喜欢
      • 2017-06-27
      • 2021-04-05
      • 2013-07-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-16
      • 2013-12-11
      相关资源
      最近更新 更多