3

I want to have a link to a Google Map on our company mobile website. The problem is, if I make a link, it takes you to the Google Maps website. It needs to open up the app.

I have found out that if you start the url with "comgooglemaps://" it will open google maps. However, this poses the problem that if a iOS user does not have Google Maps installed the link will not work.

Is there a way to open Google Maps if it is installed, but open the browser if not (I don't believe you can open Apple Maps from a website due to the nature of their API)

Thanks

EDIT: Just a heads up, this is being done on a website, not an app. So it needs to be done through HTML, Javascript, PHP etc. NOT a programing language.

collin
  • 55
  • 1
  • 6

4 Answers4

1

Have a look at the Apple Maps Links page.

Basically you link to maps.apple.com and it redirects to Google Maps if needed. Here's an example from the page:

http://maps.apple.com/?daddr=San+Francisco,+CA&saddr=cupertino

With latitude, longitude and zoom:

http://maps.apple.com/?ll=53.01,6.01&z=15

nevan king
  • 112,709
  • 45
  • 203
  • 241
0

Check this Link

You can use this method with url scheme for google map app. (comgooglemaps://blahblah)

[[UIApplication sharedApplication] canOpenURL:(NSURL*)foo]

It will return BOOL value.

Oh Seung Kwon
  • 431
  • 3
  • 11
0

Try this to move google map and set route

NSString* addr = nil;
     addr = [NSString stringWithFormat:@"http://maps.google.com/maps?daddr=%1.6f,%1.6f&saddr=Posizione attuale", destinationLat,destinationLong];

NSURL* url = [[NSURL alloc] initWithString:[addr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:url];
DURGESH
  • 2,373
  • 1
  • 15
  • 13
0

Try this code

if ([[UIApplication sharedApplication] canOpenURL:
         [NSURL URLWithString:@"comgooglemaps://"]]) {
        NSString * url = [NSString stringWithFormat:@"%@%@,%@",@"http://maps.google.com/maps?q=",@"75.14524",@"12.1521"];
        [[UIApplication sharedApplication] openURL:
         [NSURL URLWithString:url]];

    }