2

我想通过单击按钮从我的应用程序中打开本机地图应用程序。我该怎么做?

4

3 回答 3

3
NSString *mapUrl= [NSString stringWithFormat:@"https://maps.google.com/maps?ll=%f,%f",Latitude ,Longitude];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:mapUrl]];
于 2012-12-27T05:58:58.860 回答
1

看看下面的代码,它会满足你的需要。

NSString *title = @"title";
float latitude = 35.4634;
float longitude = 9.43425;
int zoom = 13;
NSString *stringURL = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@@%1.6f,%1.6f&z=%d", title, latitude, longitude, zoom];
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

干杯!

于 2012-12-27T06:00:32.040 回答
1
NSString *title = @"any title";
float latitude = 75.4634;
float longitude = 69.43425;
int zoom = 13;
NSString *stringURL = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@@%1.6f,%1.6f&  z=%d", title, latitude, longitude, zoom];
NSURL *url = [NSURL URLWithString:stringURL];   
[[UIApplication sharedApplication] openURL:url];
于 2012-12-27T05:55:25.417 回答