Ở đây bạn có phương pháp để mở trang web Google Maps hoặc các ứng dụng với một điểm đánh dấu trên đó Google Maps.
- (void) onPositionPressed:(UITapGestureRecognizer*)sender{
NSNumber * latitude = [sender.view associativeObjectForKey:@"latitude"];
NSNumber * longitude = [sender.view associativeObjectForKey:@"longitude"];
if(latitude && longitude){
//Abrimos Google Maps...
if ([[UIApplication sharedApplication] canOpenURL:
[NSURL URLWithString:@"comgooglemaps://"]]) {
[[UIApplication sharedApplication] openURL:
[NSURL URLWithString:[NSString stringWithFormat:@"comgooglemaps://?q=%.6f,%.6f¢er=%.6f,%.6f&zoom=15&views=traffic", [latitude doubleValue], [longitude doubleValue], [latitude doubleValue], [longitude doubleValue]]]];
} else {
[[UIApplication sharedApplication] openURL:
[NSURL URLWithString:[NSString stringWithFormat:@"https://maps.google.com/maps?&z=15&q=%.6f+%.6f&ll=%.6f+%.6f", [latitude doubleValue], [longitude doubleValue], [latitude doubleValue], [longitude doubleValue]]]]; }
}
}
Trong trường hợp này, vĩ độ và kinh độ là NSNumbers nhưng bạn có thể sử dụng bình thường đôi vars.
Tôi hy vọng sự giúp đỡ bất cứ ai này;)
sử dụng ** q ** thay vì ** trung tâm ** [[UIApplication sharedApplication] openURL: [NSURL URLWithString: @ "comgooglemaps: // q = 35,6653 , 139.6959 & zoom = 16 & lượt xem = traffic & mapmode = standard "]]; – Pratik