Ecco il metodo per aprire il sito web di Google Maps o Google Maps con un pennarello su di esso.
- (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]]]]; }
}
}
In questo caso, latitudine e longitudine sono NSNumbers ma è possibile utilizzare le normali doppie vars.
Spero che questo aiuto a nessuno;)
uso ** ** q invece di ** ** centro [[UIApplication sharedApplication] openURL:? [NSURL URLWithString: @ "comgooglemaps: // q = 35,6653 , 139.6959 e zoom = 16 & vista = traffico & modo mappa = standard "]]; – Pratik