我试图从我的应用程序启动Google地图应用程序。在地图应用程序中,我要设置目的地,并且用户决定使用他的当前位置或输入地址。任何人都可以指导我如何继续这个。我绝对不知道这件事。从我的应用程序启动Google地图应用程序iphone
感谢
我试图从我的应用程序启动Google地图应用程序。在地图应用程序中,我要设置目的地,并且用户决定使用他的当前位置或输入地址。任何人都可以指导我如何继续这个。我绝对不知道这件事。从我的应用程序启动Google地图应用程序iphone
感谢
要加载,您可以使用
mapView.showsUserLocation = YES;
找到你需要使用谷歌API如下位置的当前位置。
-(CLLocationCoordinate2D)findTheLocation{
NSString *url = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv",[addressField.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:url] encoding:NSUTF8StringEncoding error:NULL];
NSArray *addressItems = [locationString componentsSeparatedByString:@","];
NSLog(@"Address URL : %@", locationString);
double latitude;
double longitude;
if ([addressItems count] >=4 && [[addressItems objectAtIndex:0] isEqualToString:@"200"]) {
latitude = [[addressItems objectAtIndex:2] doubleValue];
longitude = [[addressItems objectAtIndex:3] doubleValue];
}
else {
NSLog(@"Address error.....");
}
CLLocationCoordinate2D coord;
coord.latitude = latitude;
coord.longitude = longitude;
return coord;
}
上面的函数将返回地址的坐标。你可以在地图上显示这个协调。 我希望这会帮助你。
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://maps.google.com/maps?q=INSERT_YOUR_QUERY_HERE"]]
你能告诉我我们如何查询网址?对不起。我完全不知道谷歌地图 – pa12
非常感谢。但我试图从我的应用程序启动谷歌地图应用程序,并设置最终目的地。你能告诉我如何调用谷歌地图应用程序? – pa12
以下教程将为您提供答案。 [链接](http://www.edumobile.org/iphone/iphone-programming-tutorials/mapkit-example-in-iphone/) 您可以将您的目标坐标设置为'region.center' – Chinthaka