首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MapKit:跟踪路由

MapKit:跟踪路由
EN

Stack Overflow用户
提问于 2012-05-24 22:18:54
回答 2查看 660关注 0票数 1

我有一个当前位置的MapKit和一个MkPointAnnotation。我需要追踪这些点之间的路线。

代码语言:javascript
复制
- (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;


}
EN

回答 2

Stack Overflow用户

发布于 2012-08-17 04:01:22

这在原生API中是不可能的,您可以通过JSON使用Google Directions提供的HTTP服务。

票数 0
EN

Stack Overflow用户

发布于 2016-01-28 09:35:01

使用MKDirectionReqeuest和MKDriectionResponse。MKDirectionResponse提供了MKRoute,它将帮助您绘制线条。

文档可以在这里找到(https://developer.apple.com/library/ios/documentation/MapKit/Reference/MKDirectionsRequest_class/)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10739325

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档