我正在使用以下代码进行iOS 6的地图转弯导航,
Class mapItemClass = [MKMapItem class];
if (mapItemClass && [mapItemClass respondsToSelector:@selector(openMapsWithItems:launchOptions:)])
{
// Create an MKMapItem to pass to the Maps app
CLLocationCoordinate2D coordinate =
CLLocationCoordinate2DMake(16.775, -3.009);
MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:coordinate
addressDictionary:nil];
MKMapItem *mapItem = [[MKMapItem alloc] initWithPlacemark:placemark];
[mapItem setName:@"My Place"];
// Pass the map item to the Maps app
[mapItem openInMapsWithLaunchOptions:nil];
}
它将我重定向到地图应用程序,所以,我需要,我需要在我的应用程序界面中打开它,以便用户可以保留在应用程序中而不退出应用程序界面。
请提出一些建议来控制这一点。
答案 0 :(得分:1)
答案 1 :(得分:0)
正如rckoenes所说,如果您不想启动外部应用程序,则必须自己实现。
如果您计划执行简单版本的精细导航,则可以通过Google Maps Directions API获取相关数据: https://developers.google.com/maps/documentation/directions/
从JSON(或xml)响应中,您可以获得每个步骤和航点的驾驶指示和位置数据。此处还提供了标签“overview_polyline”下的字符串。如果您正在使用Google Maps IOS SDK,则可以使用此字符串作为GMSPath直接在地图上绘制路线。 自编导航应用程序的主要挑战是构建一个强大的逻辑,用于跟踪用户并准确地提供逐向指令,以及异常处理(例如,在隧道中丢失信号......)。但只是在视觉上显示路线和指示应该相对容易。