zoukankan      html  css  js  c++  java
  • iOS调用第三方导航和线路规划

    线路规划:

    https://blog.csdn.net/qq_19979539/article/details/51938995

    百度地图:baidumap:

    高德地图:iosamap:

    腾讯地图:qqmap:

    谷歌地图:comgooglemapsurl:

    系统地图就不用这么麻烦了,直接这样就好:

    CLLocationCoordinate2D endCoor =坐标;        

    MKMapItem *currentLocation = [MKMapItem mapItemForCurrentLocation];

     MKMapItem *toLocation = [[MKMapItem alloc] initWithPlacemark:[[MKPlacemark alloc] initWithCoordinate:endCoor addressDictionary:nil]];

    toLocation.name = [NSString stringWithFormat:@"到 %@", 目的地];

     [MKMapItem openMapsWithItems:@[currentLocation, toLocation]

                           launchOptions:@{MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving,MKLaunchOptionsShowsTrafficKey: [NSNumber numberWithBool:YES]}];

    其他地图的打开如下:

    百度地图:

    NSString *stringURL = [NSString stringWithFormat:@"baidumap://map/direction?origin=%f,%f&destination=%f,%f&mode=driving",user.userLocCoord2D.latitude, user.userLocCoord2D.longitude,

                                   目的地.latitude, 目的地.longitude];

    [[UIApplication sharedApplication] openURL:url]


    高德地图:

    NSString *urlString = [[NSString stringWithFormat:@"iosamap://path?sourceApplication=%@&backScheme=%@&sname=%@&dname=%@&dev=0&m=0&t=0&sid=BGVIS1&did=BGVIS2&dlat=%lf&dlon=%lf",@"APP名称", @"iosamap", @"我的位置",目的地,endCoor.latitude, endCoor.longitude] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    [[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlString]];

    腾讯地图:

    NSString *urlString =[[NSString stringWithFormat:@"qqmap://map/routeplan?type=drive&from=我的位置&to=%@&tocoord=%lf,%lf&policy=1&referer=tengxun",目的地,endCoor.latitude,endCoor.longitude] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

     [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];

    谷歌地图:

    NSString *urlString = [[NSString stringWithFormat:@"comgooglemapsurl://www.google.com/maps/preview/@%lf,%lf,6z",endCoor.latitude, endCoor.longitude] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

     [[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlString]];
    ---------------------
    作者:尘清_iOS
    来源:CSDN
    原文:https://blog.csdn.net/qq_19979539/article/details/51938995

    目的地导航:

    https://www.cnblogs.com/jyking/p/4939637.html

    苹果:

    1.

    NSString *urlString = [[NSString stringWithFormat:@"http://maps.apple.com/?daddr=%f,%f&saddr=slat,slng",coordinate.latitude, coordinate.longitude] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]

    2.

    MKMapItem *currentLocation = [MKMapItem mapItemForCurrentLocation];

    MKMapItem *toLocation = [[MKMapItem alloc] initWithPlacemark:[[MKPlacemark alloc] initWithCoordinate:coordinate addressDictionary:nil]];
    [MKMapItem openMapsWithItems:@[currentLocation, toLocation] 
                   launchOptions:@{MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving,
                                   MKLaunchOptionsShowsTrafficKey: [NSNumber numberWithBool:YES]}];
    百度:
     
    NSString *urlString = [[NSString stringWithFormat:@"baidumap://map/direction?origin={{我的位置}}&destination=latlng:%f,%f|name=目的地&mode=driving&coord_type=gcj02",coordinate.latitude, coordinate.longitude] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    要注意几点:

    1. origin={{我的位置}}

    这个是不能被修改的 不然无法把出发位置设置为当前位置

    2. destination=latlng:%f,%f|name=目的地

    name=XXXX name这个字段不能省略 否则导航会失败 而后面的文字则可以随便填

    3. coord_type=gcj02

    coord_type允许的值为bd09ll、gcj02、wgs84 如果你APP的地图SDK用的是百度地图SDK 请填bd09ll 否则 就填gcj02 wgs84

    高德:
     
    NSString *urlString = [[NSString stringWithFormat:@"iosamap://navi?sourceApplication=%@&backScheme=%@&lat=%f&lon=%f&dev=0&style=2",appName,urlScheme,coordinate.latitude, coordinate.longitude] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    要注意几点:

    1. sourceApplication=%@&backScheme=%@

    sourceApplication代表你自己APP的名称 会在之后跳回的时候显示出来 所以必须填写 backScheme是你APP的URL Scheme 不填是跳不回来的哟

    2. dev=0

    这里填0就行了,跟上面的gcj02一个意思 1代表wgs84 也用不上

    谷歌:

    NSString *urlString = [[NSString stringWithFormat:@"comgooglemaps://?x-source=%@&x-success=%@&saddr=&daddr=%f,%f&directionsmode=driving",appName,urlScheme,coordinate.latitude, coordinate.longitude] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

     
  • 相关阅读:
    收集的各种学习链接,方便查找
    用python调试Appium和雷电模拟器连接时出现Original error: Could not find 'adb.exe' in PATH
    App自动化测试之Appium环境安装(涉及雷电模拟器和真机)
    元素定位工具ChroPath
    Python+Selenium学习笔记19
    Python+Selenium学习笔记18
    Python+Selenium学习笔记17
    Python+Selenium学习笔记16
    Python+Selenium学习笔记14
    Python+Selenium学习笔记15
  • 原文地址:https://www.cnblogs.com/yuxiaoyiyou/p/10062314.html
Copyright © 2011-2022 走看看