我目前正在开发一个带有地图视图的应用程序,它会打开Apple Maps并发送起始和终止位置的经度和纬度信息,以便用户可以借助Apple Maps进行导航。我的问题是:是否可能使Apple Maps应用程序自动运行导航功能?现在,它会打开Apple Maps应用程序,并在起始位置和终止位置上标注正确的坐标,但我必须点击导航功能才能让Apple Maps呈现从起点到终点的导航路线。
以下是从我的应用程序中打开Apple Maps的代码:
以下是从我的应用程序中打开Apple Maps的代码:
// 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");
}