xcode 具有特定位置的 MKMapItem

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12692924/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 15:51:53  来源:igfitidea点击:

MKMapItem with specific Location

objective-ciphonexcodemkmapitem

提问by Nils

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

如何启动适用于 iOS6 的默认地图应用程序并向其传递自定义位置?

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?

我按照这里的例子,但无法弄清楚。如何从我自己的本机应用程序中启动 Google Maps iPhone 应用程序?

回答by Eneko Alonso

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

以下是使用自定义位置打开 Maps 本机应用程序的代码:

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