【发布时间】:2013-09-10 07:09:43
【问题描述】:
我目前正在开发一个带有地图视图的应用程序,该应用程序可以打开 Apple 地图并发送经度和纬度,因此是开始和停止位置。因此,用户可以在 Apple 地图的帮助下进行导航。我的问题是:是否可以让 Apple Maps 应用程序自动运行导航功能?就像现在一样,它会打开 Apple Maps 应用程序,并在开始位置和停止位置上有正确的坐标和注释,但我必须单击导航功能才能让 Apple Maps 显示从开始到停止的导航路线。
这是从我自己的应用程序中打开 Apple 地图的代码:
// NAVIGATION ACTION SHEET
if (buttonIndex == 0) {
double toLatDouble = [to_lat doubleValue];
double toLongDouble = [to_long doubleValue];
CLLocationCoordinate2D location = CLLocationCoordinate2DMake(toLatDouble,toLongDouble);
// Apple Maps, using the MKMapItem class
MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:location addressDictionary:nil];
MKMapItem *item = [[MKMapItem alloc] initWithPlacemark:placemark];
item.name = self.toLocation;
[item openInMapsWithLaunchOptions:nil];
}
else if (buttonIndex == 1){
double fromLatDouble = [from_lat doubleValue];
double fromLongDouble = [from_long doubleValue];
CLLocationCoordinate2D location = CLLocationCoordinate2DMake(fromLatDouble,fromLongDouble);
// Apple Maps, using the MKMapItem class
MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:location addressDictionary:nil];
MKMapItem *item = [[MKMapItem alloc] initWithPlacemark:placemark];
item.name = self.toLocation;
[item openInMapsWithLaunchOptions:nil];
}else {
// Cancel
NSLog(@"User canceled navigation actionSheet");
}
【问题讨论】:
标签: objective-c navigation gps apple-maps