Question

How can I launch the default maps app for iOS6 and pass it a custom location?

For example:

[[MKMapItem setLocation:MyLocation] openInMapsWithLaunchOptions:nil];

I followed the example here, but was unable to figure it out. How can I launch the Google Maps iPhone application from within my own native application?

Was it helpful?

Solution

Here is the code to open the Maps native application with a custom location:

double latitude = 35.0;
double longitude = 1.0;
MKPlacemark *placemark = [[[MKPlacemark alloc] initWithCoordinate:CLLocationCoordinate2DMake(latitude, longitude) addressDictionary:nil] autorelease];
MKMapItem *mapItem = [[[MKMapItem alloc] initWithPlacemark:placemark] autorelease];
[mapItem setName:@"Name of your location"];
[mapItem openInMapsWithLaunchOptions:nil];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top