iOS - Launch YandexMaps with directions URLScheme
Asked Answered
D

8

5

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];
}
Downstream answered 2/3, 2014 at 12:58 Comment(0)
F
6

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)

Foreskin answered 3/3, 2015 at 9:22 Comment(1)
build_route_on_map is used with yandexnavi:// url scheme see tech.yandex.ru/yandex-apps-launch/navigator/doc/concepts/…Cabasset
M
7

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.

Marci answered 15/5, 2014 at 23:35 Comment(0)
F
6

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)

Foreskin answered 3/3, 2015 at 9:22 Comment(1)
build_route_on_map is used with yandexnavi:// url scheme see tech.yandex.ru/yandex-apps-launch/navigator/doc/concepts/…Cabasset
D
4

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)
Drily answered 31/5, 2019 at 8:7 Comment(0)
A
3

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

Angadresma answered 5/9, 2016 at 10:13 Comment(0)
H
2

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

Headstall answered 21/12, 2017 at 14:53 Comment(0)
B
1

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

Barton answered 2/3, 2014 at 15:13 Comment(1)
I already know that it is possible pass parameters for zoom (z), center (ll) and location (pt), but I'm looking for directions parameters.Downstream
C
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"]];
}
Cabasset answered 6/9, 2018 at 16:55 Comment(0)
C
0
@"yandexmaps://maps.yandex.ru/?pt={0},{1}"
Counterattraction answered 24/10, 2017 at 19:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.