应用跳转打开苹果,百度,高德地图应用并进入导航功能。

//绘制   这里是ArcGis的代理方法



- (BOOL) callout:(AGSCallout *)callout willShowForFeature:(id<AGSFeature>)feature layer:(AGSLayer<AGSHitTestable> *)layer mapPoint:(AGSPoint *)mapPoint {
   //直接跳转应用不使用导航功能使用下方url
    NSURL * baidu_App = [NSURL URLWithString:@"baidumap://"];


    NSURL * gaode_App = [NSURL URLWithString:@"iosamap://"];


    if ([[UIApplication sharedApplication] canOpenURL:baidu_App]){



        self.mapView.callout.title = @"百度地图";


    }else if ([[UIApplication sharedApplication] canOpenURL:gaode_App]){



        self.mapView.callout.title = @"高德地图";


    }else{


        self.mapView.callout.title = @"苹果地图";


    }


    self.mapView.callout.detail =@"点击箭头跳转";



    self.mapView.callout.detailColor = [UIColor grayColor];



    self.mapView.callout.accessoryButtonHidden = NO;



    self.mapView.callout.accessoryButtonType = UIButtonTypeCustom;



    self.mapView.callout.accessoryButtonImage = [UIImage  imageNamed:@"  marker"];



    return YES;



}


- (void)didClickAccessoryButtonForCallout:(AGSCallout *)callout{


    NSLog(@"点击跳转");


    NSURL * baidu_App = [NSURL URLWithString:@"baidumap://"];


    NSURL * gaode_App = [NSURL URLWithString:@"iosamap://"];


    if ([[UIApplication sharedApplication] canOpenURL:baidu_App]){



        //跳转百度地图



        NSString *urlString = [[NSString stringWithFormat:@"baidumap://map/direction?origin=latlng:%f,%f|name:我的位置&destination=latlng:%f,%f|name:终点&mode=driving",_startPoint.y, _startPoint.x,_targetPoint.y,_targetPoint.x] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] ;



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



    }else if ([[UIApplication sharedApplication] canOpenURL:gaode_App]){



        [self testAppleMap];


    }else{


        [self testAppleMap];


    }


}


//跳转苹果地图


-(void)testAppleMap{


    NSLog(@"%f____%f------%f-----%f",_startPoint.x,_startPoint.y,_targetPoint.x,_targetPoint.y);



    CLLocationCoordinate2D coords1 = CLLocationCoordinate2DMake(_startPoint.y,_startPoint.x);



    CLLocationCoordinate2D coords2 = CLLocationCoordinate2DMake(_targetPoint.y,_targetPoint.x);



    MKMapItem *currentLocation = [[MKMapItem alloc] initWithPlacemark:[[MKPlacemark alloc] initWithCoordinate:coords1 addressDictionary:nil]];



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



    toLocation.name = @"目的地";


    NSArray *items = [NSArray arrayWithObjects:currentLocation, toLocation, nil];


    NSDictionary *options = @{ MKLaunchOptionsDirectionsModeKey:MKLaunchOptionsDirectionsModeDriving, MKLaunchOptionsMapTypeKey: [NSNumber numberWithInteger:MKMapTypeStandard], MKLaunchOptionsShowsTrafficKey:@YES }; //打开苹果自身地图应用,并呈现特定的item



    [MKMapItem openMapsWithItems:items launchOptions:options];



}


- (void)testBaidu:(NSString *)title{


   


       NSString *url2 = [[NSString stringWithFormat:@"baidumap://map/direction?origin=latlng:39.915,116.404|name:我的位置&destination=latlng:39.915,120.202|name:终点&mode=driving"] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] ;



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



        //    if ([@"使用高德地图导航" isEqualToString:title])


    //    {


    //        NSString *urlString = [[NSString stringWithFormat:@"iosamap://navi?sourceApplication=%@&backScheme=%@&poiname=%@&lat=%f&lon=%f&dev=1&style=2",@"app name", yourscheme, @"终点", _shopLat, _shopLon] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];


    //



    


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


    //    }


}
 //高德地图未实现 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值