oscarimonbox
1/4/2017 - 11:45 AM

Abrir GoogleMaps (app o web) con un marker

Abrir GoogleMaps (app o web) con un marker

First open Info.plist as Source Code (Righ Click on file Info.plis, then select Source Code) and add this:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>googlechromes</string>
    <string>comgooglemaps</string>
</array>

if (UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!)) {
        UIApplication.shared.open(URL(string:"comgooglemaps://?center=\(self.location.coordinate.latitude),\(self.location.coordinate.longitude)&zoom=14&views=traffic&q=\(self.location.coordinate.latitude),\(self.location.coordinate.longitude)")!, options: [:], completionHandler: nil)
    } else {
        print("Can't use comgooglemaps://")
    }
}
-(void) openGoogleMaps {

    
    NSString *location = [NSString stringWithFormat:@"%@,%@",self.lostDog.latitude,self.lostDog.longitude];
    
    if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"comgooglemaps:"]]) {
        NSString *urlString = [NSString stringWithFormat:@"comgooglemaps://?q=%@&center=%@&zoom=%d",location,location,ZOOM_LEVEL];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
    } else {

        NSString *string = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@&center=%@&zoom=%d",location,location,ZOOM_LEVEL];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:string]];
    }
    
}