Reputation: 138
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?
Upvotes: 1
Views: 1988
Reputation: 740
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: [:])
}
Upvotes: 0
Reputation: 966
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
}
Upvotes: 2