[objc] view plaincopy
1. BOOL hasBaiduMap = NO;
2. BOOL hasGaodeMap = NO;
3.
4. if ([[UIApplication sharedApplication]canOpenURL:[NSURL URLWithString:@"baidumap://map/"]]){
5. hasBaiduMap = YES;
6. }
7. if ([[UIApplication sharedApplication]canOpenURL:[NSURL URLWithString:@"iosamap://"]]){
8. hasGaodeMap = YES;
9. }
10.
11.
12. if ([@"使用百度地图导航" isEqualToString:title])
13. {
14. 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] ;
15.
16. [[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlString]];
17. }
18. else if ([@"使用高德地图导航" isEqualToString:title])
19. {
20. NSString *urlString = [[NSString stringWithFormat:@"iosamap://navi?sourceApplication=%@&backScheme=%@&poiname=%@&lat=%f&lon=%f&dev=1&style=2",@"app name", yourscheme, @"终点", _shopLat, _shopLon] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
21.
22. [[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlString]];
1. BOOL hasBaiduMap = NO;
2. BOOL hasGaodeMap = NO;
3.
4. if ([[UIApplication sharedApplication]canOpenURL:[NSURL URLWithString:@"baidumap://map/"]]){
5. hasBaiduMap = YES;
6. }
7. if ([[UIApplication sharedApplication]canOpenURL:[NSURL URLWithString:@"iosamap://"]]){
8. hasGaodeMap = YES;
9. }
10.
11.
12. if ([@"使用百度地图导航" isEqualToString:title])
13. {
14. 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] ;
15.
16. [[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlString]];
17. }
18. else if ([@"使用高德地图导航" isEqualToString:title])
19. {
20. NSString *urlString = [[NSString stringWithFormat:@"iosamap://navi?sourceApplication=%@&backScheme=%@&poiname=%@&lat=%f&lon=%f&dev=1&style=2",@"app name", yourscheme, @"终点", _shopLat, _shopLon] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
21.
22. [[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlString]];
23. }