Launch the Google maps app from the iPhone app.

I am trying to run google maps from my iPhone application.

The launching part is working fine, but since the iPhone 3.1 update (I think it was around this time) I get an enlarged map of the USA and Canada, and not increase my current location. Initially, everything worked fine, but once around the update the situation stopped working correctly.

Here is the line I used. This works on the phone of my partners with iOS 3.0 and our iPod with iOS 2.2.1, but on my phone with iOS 3.1 a map of Canada and the USA with a reduced map is shown.

NSString *name = @"clothing"; NSString *latlong = [[NSString alloc] initWithFormat:@"%@,%@", latitudeString, longitudeString]; NSString *url = [NSString stringWithFormat: @"http://maps.google.com/maps?q=%@&mrt=yp&ll=%@", [name stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding], [latlong stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]]; [latlong release]; 

Any help is appreciated.

Thanks in advance.

+4
source share
1 answer

This is the code that I use in one of my applications , and it works great with 3.1. The options for Google maps are described here .

 CLLocationCoordinate2D stationLocation = ... NSString *urlString = [[NSString alloc] initWithFormat:@"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f&dirflg=d", curLocation.latitude, curLocation.longitude, stationLocation.latitude, stationLocation.longitude]; NSURL *aURL = [NSURL URLWithString:urlString]; [urlString release]; [[UIApplication sharedApplication] openURL:aURL]; 
+3
source

All Articles