Objective c 地图套件:追踪路线
我有一个带有当前位置的MapKit和一个MkPointAnnotation。我需要追踪这些点之间的路线Objective c 地图套件:追踪路线,objective-c,xcode,mapkit,Objective C,Xcode,Mapkit,我有一个带有当前位置的MapKit和一个MkPointAnnotation。我需要追踪这些点之间的路线 - (void)viewDidLoad { [super viewDidLoad]; //esconder navBar [[self navigationController] setNavigationBarHidden:YES animated:NO]; mapView.showsUserLocation = YES; UIBarButtonI
- (void)viewDidLoad
{
[super viewDidLoad];
//esconder navBar
[[self navigationController] setNavigationBarHidden:YES animated:NO];
mapView.showsUserLocation = YES;
UIBarButtonItem *zoomButton = [[UIBarButtonItem alloc]
initWithTitle: @"Onde Estou?"
style:UIBarButtonItemStylePlain
target: self
action:@selector(zoomIn:)];
self.navigationItem.rightBarButtonItem = zoomButton;
UIBarButtonItem *typeButton = [[UIBarButtonItem alloc]
initWithTitle: @"Tipo"
style:UIBarButtonItemStylePlain
target: self
action:@selector(changeMapType:)];
self.navigationItem.leftBarButtonItem = typeButton;
double lat = -21.21258;
double lng = -47.816802;
CLLocationCoordinate2D Coordinate;
Coordinate.latitude = lat;
Coordinate.longitude = lng;
MKPointAnnotation *annotationPoint = [[MKPointAnnotation alloc] init];
annotationPoint.coordinate = Coordinate;
annotationPoint.title = @"Ribeirão Shopping";
annotationPoint.subtitle = @"Ribeirão Preto - SP";
[self.mapView addAnnotation:annotationPoint];
MKCoordinateRegion newRegion;
newRegion.center.latitude = lat;
newRegion.center.longitude = lng;
[self.mapView setRegion:newRegion animated:YES];
mapView.mapType = MKMapTypeStandard;
}
这在本机API中是不可能的,您可以通过JSON使用由提供的HTTP服务使用mkdirectionRequeest和mkdriectResponse。MKDirectionResponse具有MKRoute,可帮助您绘制线条
可以在此处找到文档()MKDirections API是在iOS6中添加的。