Question

I want my app to redirect the user to the Maps apps on the iPhone. Search query is fine, it shows the user Current Location and nearby hospitals (hopital in french, it's not a typo), but it doesn't zoom in. I read that the zoom goes from 1 to 19, but even at 18, I still see the entire North America...

    NSString *urlString = @"http://maps.google.com/maps?q=hopital&t=m&z=18";
    UIApplication *app = [UIApplication sharedApplication];
    [app openURL:[NSURL URLWithString:urlString]];

I have been reading quite a lot and can't find out why this parameter seems to be ignored.

Any idea? Thanks in advance...

Was it helpful?

Solution

After more searches (for other aspects of the app) and some try/error guesses, I have found an answer which, hopefully, will be helpful to someone else.

This string:

    NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps?sll=%f,%f&z=14&q=hopital", userCoordinate.latitude, userCoordinate.longitude];

displays the map with a nice zoom, the user's location is centered in the screen and shows relevant searches around. (userCoordinate is a CLLocationCoordinate2D location that contains the user's location.)

Note that with the parameter sll (instead of just ll) displays the same map area but doesn't display the search results. The word (in this case "hopital") is pre-populated in the search box.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top