Question

Is there an URL-Scheme for launch the Yandex Maps application with directions?

I can just launch the Yandex Maps application (if already installed) with few lines of code, but I didn't found documentation about URLSchemes handled by the app:

NSURL *url = [NSURL URLWithString:@"yandexmaps://maps.yandex.ru/"];

if([[UIApplication sharedApplication] canOpenURL:url]){
    [[UIApplication sharedApplication] openURL:url];
}
Was it helpful?

Solution 2

Actually, as of today this is misleading, there is a URL-scheme to get directions.

yandexmaps://build_route_on_map/?params

Example:

[[UIApplication sharedApplication] openURL:
[NSURL URLWithString:@"yandexmaps://build_route_on_map/?lat_from=59.967870&lon_from=30.242658&lat_to=59.898495&lon_to=30.299559"]];

lat_from and lon_from are optional, current position is used when they are not provided. Don't forget to check if yandex.maps app is installed

NSURL *callUrl = [NSURL URLWithString:@"yandexmaps://"];

if ([[UIApplication sharedApplication] canOpenURL:callUrl])

{
    //Yandex.Maps app is installed

}

Documentation (in Russian)

OTHER TIPS

There is another Yandex cartographic app, Yandex.Navigator, that do support directions. If such a solution is acceptable for you then you can use a scheme like this one:

yandexnavi://build_route_on_map?lat_from=55.751802&lon_from=37.586684&lat_to=55.758192&lon_to=37.642817

Visit here for details.

This is not iOS specific but I hope it helps someone looking for Yandex directions URL, as it took me too long to find this. So for a web app I used this

https://yandex.ru/maps?rtext=FROM~TO&rtt=auto

where either FROM or TO is optional, as well as the rtt parameter. So you could use

https://yandex.ru/maps?rtext=~Berlin

to guide someone from anywhere TO Berlin.

Porting a web app with Google Maps support to Yandex I was looking for an equivalent link for Google Maps directions link https://www.google.com/maps/dir/FROM/TO and finally found this on SO. The documentation link from @NKorotkov answer led me here: https://tech.yandex.ru/yandex-apps-launch/maps/doc/concepts/yandexmaps-ios-app-docpage/#buildroute

Swift 5

If you need to open Yandex Navi you can use like this;

1- You should add 'yandexnavi' to info.plist like this;

 <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>yandexnavi</string>
    </array>

2- You should check the app is installed;

UIApplication.shared.canOpenURL(URL(string: "yandexnavi://")!)

3- You should open Yandex Navi with lat & long;

let url = URL(string: "yandexnavi://build_route_on_map?lat_to=" + "\(lat)" + "&lon_to=" + "\(long)")

UIApplication.shared.open(url, options: [:], completionHandler: nil)

This works: "yandexnavi://build_route_on_map?lat_to=" + latvalu + "&lon_to=" + longvalue

Try:

yandexmaps://maps.yandex.ru/?

You can add parameters like

yandexmaps://maps.yandex.ru/?ll=37.5959049,55.7390474&z=12 Where ll -> geographic center that will be visible on the screen z-> is the zoom value

More info are here, but it is in Russian: http://clubs.ya.ru/mobilemaps/replies.xml?item_no=53530

UPDATE: As per site:

Unfortunately Yandex map app for iOS does not support navigation through URL schemes

@"yandexmaps://maps.yandex.ru/?pt={0},{1}"

You can see the tech documentation in russian from the Intents and URL Schemes section

You will see all url schemes for yandex maps, navi and metro apps.

Yandex Maps:

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"yandexmaps://"]]) {
   [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"yandexmaps://maps.yandex.ru/?ll=37.62,55.75&z=12"]];
} else {
// Открываем страницу приложения Яндекс.Карты в App Store.
   [[UIApplication sharedApplication] openURL:
    [NSURL URLWithString:@"https://itunes.apple.com/ru/app/yandex.maps/id313877526?mt=8"]];
}

Yandex Navi:

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"yandexnavi://"]]) {
   [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"yandexnavi://"]];
} else {

// Открывает страницу приложения Яндекс.Навигатор в App Store.
   [[UIApplication sharedApplication] openURL:
    [NSURL URLWithString:@"https://itunes.apple.com/ru/app/yandex.navigator/id474500851"]];
}

Yandex Metro:

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"yandexmetro://"]]) 
{
      [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"yandexmetro://?alias=moscow"]];
} 
else
{
// Открываем страницу приложения Яндекс.Метро в App Store.
   [[UIApplication sharedApplication] openURL:
    [NSURL URLWithString:@"https://itunes.apple.com/ru/app/yandex.maps/id313877526?mt=8"]];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top