使用特定的经纬度打开本地iOS地图应用程序

时间:2018-08-13 03:11:19

标签: ios objective-c dictionary

如何通过在Objective C中的特定纬度和经度处添加图钉来打开本机ios地图应用程序。

1 个答案:

答案 0 :(得分:0)

对于Swift 3和Swift 4

let apiKey = "https://www.google.com/maps/dir/" + userCurrentLocation.coordinate.latitude + "," + userCurrentLocation.coordinate.longitude + "/" + nextCurrentLocation.coordinate.latitude + "," + nextCurrentLocation.coordinate.longitude

var url = URL(string: apikey)
UIApplication.shared.open(openUrl!, options: [:]) { (res:Bool) in

            }

用于目标c

 NSString *apikey = [NSString stringWithFormat:@"https://www.google.co.in/maps/dir/%f,%f/%f,%f",userCurrentLocation.coordinate.latitude,userCurrentLocation.coordinate.longitude,nextCurrentLocation.coordinate.latitude,nextCurrentLocation.coordinate.longitude;

NSURL *url = [NSURL URLWithString:apikey];

[[UIApplication sharedApplication] openURL:url];