【问题标题】:iOS - Launch YandexMaps with directions URLSchemeiOS - 使用路线 URL 方案启动 Yandex 地图
【发布时间】:2014-04-03 09:13:12
【问题描述】:

是否有用于启动 Yandex 地图应用程序的 URL 方案?

我可以用几行代码启动 Yandex 地图应用程序(如果已安装),但我没有找到有关应用程序处理的 URLSchemes 的文档:

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

if([[UIApplication sharedApplication] canOpenURL:url]){
    [[UIApplication sharedApplication] openURL:url];
}

【问题讨论】:

    标签: ios maps url-scheme directions yandex


    【解决方案1】:

    还有另一个 Yandex 制图应用程序 Yandex.Navigator,确实支持方向。如果您可以接受这样的解决方案,那么您可以使用这样的方案:

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

    访问here了解详情。

    【讨论】:

      【解决方案2】:

      实际上,到目前为止,这是一种误导,有一个 URL 方案来获取路线。

      yandexmaps://build_route_on_map/?params

      例子:

      [[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 和 lon_from 是可选的,没有提供时使用当前位置。 不要忘记检查是否安装了 yandex.maps 应用程序

      NSURL *callUrl = [NSURL URLWithString:@"yandexmaps://"];
      
      if ([[UIApplication sharedApplication] canOpenURL:callUrl])
      
      {
          //Yandex.Maps app is installed
      
      }
      

      Documentation(俄语)

      【讨论】:

      【解决方案3】:

      这不是 iOS 特定的,但我希望它可以帮助寻找 Yandex 路线 URL 的人,因为我花了很长时间才找到它。所以对于一个网络应用,我使用了这个

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

      其中 FROM 或 TO 以及 rtt 参数是可选的。所以你可以使用

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

      从任何地方引导某人到柏林。

      将支持谷歌地图的网络应用程序移植到 Yandex 我一直在寻找谷歌地图方向链接https://www.google.com/maps/dir/FROM/TO 的等效链接,最后在 SO 上找到了这个。 @NKorotkov 回答的文档链接将我带到了这里:https://tech.yandex.ru/yandex-apps-launch/maps/doc/concepts/yandexmaps-ios-app-docpage/#buildroute

      【讨论】:

        【解决方案4】:

        斯威夫特 5

        如果需要打开 Yandex Navi 可以这样使用;

        1- 你应该像这样将 'yandexnavi' 添加到 info.plist;

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

        2- 您应该检查应用程序是否已安装;

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

        3- 你应该用 lat & long 打开 Yandex Navi;

        let url = URL(string: "yandexnavi://build_route_on_map?lat_to=" + "\(lat)" + "&lon_to=" + "\(long)")
        
        UIApplication.shared.open(url, options: [:], completionHandler: nil)
        

        【讨论】:

          【解决方案5】:

          这可行:"yandexnavi://build_route_on_map?lat_to=" + latvalu + "&amp;lon_to=" + longvalue

          【讨论】:

            【解决方案6】:

            试试:

            yandexmaps://maps.yandex.ru/?

            你可以添加类似的参数

            yandexmaps://maps.yandex.ru/?ll=37.5959049,55.7390474&z=12 where ll -> 将在屏幕上可见的地理中心 z-> 是缩放值

            更多信息在这里,但它是俄语:http://clubs.ya.ru/mobilemaps/replies.xml?item_no=53530

            更新: 根据网站:

            很遗憾,iOS 版 Yandex 地图应用程序不支持导航 通过 URL 方案

            【讨论】:

            • 我已经知道可以传递缩放 (z)、中心 (ll) 和位置 (pt) 的参数,但我正在寻找方向参数。
            【解决方案7】:
            @"yandexmaps://maps.yandex.ru/?pt={0},{1}"
            

            【讨论】:

              【解决方案8】:

              您可以在Intents and URL Schemes 部分查看俄语技术文档

              您将看到 yandex 地图、导航和 Metro 应用程序的所有 url 方案。

              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"]];
              }
              

              【讨论】:

                猜你喜欢
                • 1970-01-01
                • 2012-02-20
                • 2013-03-06
                • 2012-10-25
                • 1970-01-01
                • 2018-04-11
                • 2015-12-17
                相关资源
                最近更新 更多