以编程方式启动没有方向或地点标记的 Apple Maps
Programmatically launch Apple Maps without directions or a place mark
看完这篇post,Programmatically open Maps app in iOS 6
使用下面的代码,我启动了 Apple 地图,但我只想打开 Apple 地图,而不是向它发送地址、地点标记或方向。
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(44.180383, -75.229618);
MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:coordinate
addressDictionary:nil];
MKMapItem *mapItem = [[MKMapItem alloc] initWithPlacemark:placemark];
[mapItem setName:@"Home"];
// Pass the map item to the Maps app
[mapItem openInMapsWithLaunchOptions:nil];
如有任何帮助,我们将不胜感激。
使用苹果URL方案
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://maps.apple.com"]];
更多信息请参考 apples maps URL sceme 文档:https://developer.apple.com/library/ios/featuredarticles/iPhoneURLScheme_Reference/MapLinks/MapLinks.html
在您的应用程序中使用以下代码只打开 Apple 地图
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://maps.apple.com/?q="]];
看完这篇post,Programmatically open Maps app in iOS 6
使用下面的代码,我启动了 Apple 地图,但我只想打开 Apple 地图,而不是向它发送地址、地点标记或方向。
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(44.180383, -75.229618);
MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:coordinate
addressDictionary:nil];
MKMapItem *mapItem = [[MKMapItem alloc] initWithPlacemark:placemark];
[mapItem setName:@"Home"];
// Pass the map item to the Maps app
[mapItem openInMapsWithLaunchOptions:nil];
如有任何帮助,我们将不胜感激。
使用苹果URL方案
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://maps.apple.com"]];
更多信息请参考 apples maps URL sceme 文档:https://developer.apple.com/library/ios/featuredarticles/iPhoneURLScheme_Reference/MapLinks/MapLinks.html
在您的应用程序中使用以下代码只打开 Apple 地图
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://maps.apple.com/?q="]];