iOS 判断并使用 百度地图 高德地图 导航(使用URI,不集成sdk)

BOOL hasBaiduMap = NO;
        BOOL hasGaodeMap = NO;
        
        if ([[UIApplication sharedApplication]canOpenURL:[NSURL URLWithString:@"baidumap://map/"]]){
            hasBaiduMap = YES;
        }
        if ([[UIApplication sharedApplication]canOpenURL:[NSURL URLWithString:@"iosamap://"]]){
            hasGaodeMap = YES;
        }
	

	if ([@"使用百度地图导航" isEqualToString:title])
        {
            NSString *urlString = [[NSString stringWithFormat:@"baidumap://map/direction?origin=latlng:%f,%f|name:我的位置&destination=latlng:%f,%f|name:终点&mode=driving",currentLat, currentLon,_shopLat,_shopLon] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] ;
            
            [[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlString]];
        }
        else 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]];
        }


 

你可能感兴趣的:(iOS 判断并使用 百度地图 高德地图 导航(使用URI,不集成sdk))