Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MKMapItem with specific Location

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?

like image 400
Nils Avatar asked Oct 02 '12 15:10

Nils


1 Answers

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];
like image 142
Eneko Alonso Avatar answered Nov 10 '22 05:11

Eneko Alonso