Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start navigation automatically with Google Maps and Apple Maps URL Schemes

Is there a way to start navigation automatically when launching Google Maps or Apple Maps with a URL Scheme on iOS?

I see several optional parameters for both but none to start navigation without user input.

like image 914
JuJoDi Avatar asked Sep 25 '14 13:09

JuJoDi


People also ask

How do I prioritize Google Maps to Apple Maps?

Scroll down to the bottom of the menu and tap Settings. On the Settings screen, tap the Default apps option. Under the Navigate from your location and the Navigate between location sections, tap to select Google Maps.

How do I get Google Maps to open links in the app iPhone?

Scroll down to the bottom of the menu and tap Settings. Tap Default apps. Under Navigate from your location, tap Google Maps, then under Navigate between locations, tap Google Maps again.

Does Apple Maps have a URL?

Parameters. There are multiple parameters you can add to the Apple Maps URLs and the https://maps.apple.com/ URL.


1 Answers

Here's how I did it for your reference, but for apple, I haven't found a way to start the navigation through url scheme.

+ (void)navigateToLocation:(CLLocation*)_navLocation {
    if ([[UIApplication sharedApplication] canOpenURL:
         [NSURL URLWithString:@"comgooglemaps://"]]) {
        NSString *string = [NSString stringWithFormat:@"comgooglemaps://?daddr=%f,%f&directionsmode=driving",_navLocation.coordinate.latitude,_navLocation.coordinate.longitude];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:string]];
    } else {
        NSString *string = [NSString stringWithFormat:@"http://maps.apple.com/?ll=%f,%f",_navLocation.coordinate.latitude,_navLocation.coordinate.longitude];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:string]];
    }
}
like image 161
Alan Feng Avatar answered Sep 25 '22 02:09

Alan Feng