1

I have latitude and longitude information for source and destination, I want to send this information to yandex maps and yandex maps should show directions. How can I do this in Swift 3?

BadCode
  • 131
  • 13

2 Answers2

2

You should use Yandex's URL-Scheme (yandexmaps://build_route_on_map/?params)

Example in swift 3:

let url = URL(string: "yandexmaps://build_route_on_map/?lat_from=XXXXX&lon_from=XXXXX&lat_to=XXXXX&lon_to=XXXXX")!
if #available(iOS 10.0, *) {
    UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
    UIApplication.shared.openURL(url)
}

Remember to check if the app can be opened.

if UIApplication.shared.canOpenURL(url) {
    // Open the URL here
}
Alex Tarragó
  • 956
  • 8
  • 16
0

you can open the web with this :

 if let url = URL(string: "https://yandex.ru/maps/?ll=\(latitude),\(longitude)&z=12&l=map") {
            UIApplication.shared.open(url, options: [:])
        }
Ryan110
  • 710
  • 4
  • 19