oscarimonbox
8/31/2016 - 7:40 AM

Abrir GoogleMaps con coordenadas

Abrir GoogleMaps con coordenadas

1) añadir el customurl en el plist

URL types (Array)
-Item 0 (Dictionary) (2 items)
 -URL Schemes (Array)
  -Item 0 (String) mycustomurlscheme
 -URL identifier (String) comgooglemaps

y

LSApplicationQueriesSchemes (Array)
-Item 0 (String) comgooglemaps


2) código para la llamada

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&center=%.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]]]];        }

    }