CLLocationCoordinate2D endCoor = CLLocationCoordinate2DMake(startCoor.latitude, startCoor.longitude);
MKMapItem *currentLocation = [MKMapItem mapItemForCurrentLocation];
MKMapItem *toLocation = [[MKMapItem alloc] initWithPlacemark:[[MKPlacemark alloc] initWithCoordinate:endCoor addressDictionary:nil]];
toLocation.name = @"to name";
[MKMapItem openMapsWithItems:@[currentLocation, toLocation] launchOptions:@{MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving,MKLaunchOptionsShowsTrafficKey: [NSNumber numberWithBool:YES]}];
本文展示了一个使用Swift和UIKit在iOS设备上实现从当前位置到指定目的地导航的应用示例。通过MKMapItem和MKPlacemark等组件,实现了路径规划并显示交通状况。
400

被折叠的 条评论
为什么被折叠?



