MKMapItem with specific Location

天涯浪子 提交于 2019-11-29 08:16:58

问题


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?


回答1:


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];


来源:https://stackoverflow.com/questions/12692924/mkmapitem-with-specific-location

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!