iOS 跳转到地图后导航(高德地图,百度地图,腾讯地图,苹果手机原生的地图)

本文介绍了如何在iOS应用中实现跳转到高德地图、百度地图、腾讯地图以及苹果原生地图进行导航的功能。通过在info.plist配置,添加代理,以及编写检查和调用相应地图应用的代码,实现从应用内部发起导航到指定地点。
摘要由CSDN通过智能技术生成

1.现在info.plist里面如下图所示添加


2.在下图输入框中输入地名,然后点击前往目的地会出现如下图所示。(如果你不知道地方名如何转化为经纬度请看我的另一篇博客:http://blog.csdn.net/chenyongkai1/article/details/51891135)


3.添加下面的代理

UIActionSheetDelegate,CLLocationManagerDelegate


4.下面是最核心代码

先调用下面的方法

- (void)showMapNavigationViewWithtargetLatitude:(double)targetLatitude targetLongitute:(double)targetLongitute toName:(NSString *)name;



4.调用完最核心的代码后下面的所有的主干方法都在在上面的方法执行后都会运行一次。

(NSArray *)checkHasOwnApp{

    NSArray *mapSchemeArr =@[@"iosamap://navi",@"baidumap://map/",@"qqmap://"];

    

    NSMutableArray *appListArr = [[NSMutableArrayalloc] initWithObjects:@"苹果地图",nil];

    

    for (int i =0; i < [mapSchemeArr count]; i++) {

        if ([[UIApplicationsharedApplication] canOpenURL:[NSURLURLWithString:[NSStringstringWithFormat:@"%@",[mapSchemeArrobjectAtIndex:i]]]]) {

            if (i ==0) {

                [appListArr addObject:@"高德地图"];

            }elseif (i == 1){

                [appListArr addObject:@"百度地图"];

            }elseif (i == 2){

                [appListArr addObject:@"腾讯地图"];

            }elseif (i == 3){

                

            }

        }

    }

    

    return appListArr;

}

- (void)showMapNavigationViewFormcurrentLatitude:(double)currentLatitude currentLongitute:(double)currentLongitute TotargetLatitude:(double)targetLatitude targetLongitute:(double)targetLongitute toName:(NSString *)name{

    _currentLatitude = currentLatitude;

    _currentLongitute = currentLongitute;

    _targetLatitude = targetLatitude;

    _targetLongitute = targetLongitute;

    _name = name;

    NSArray *appListArr = [JXMapNavigationViewcheckHasOwnApp];

    NSString *sheetTitle = [NSStringstringWithFormat:@"导航到 %@",name];

    UIActionSheet *sheet;

    if ([appListArrcount] == 1) {

        sheet = [[UIActionSheet

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值