0

因此,我将我的应用程序设置为在按下按钮时搜索用户的位置。

-(IBAction)getLocation {
mapview.showsUserLocation = YES;}

然后我在使用这个加载地图视图时也设置了一个地图注释到某个位置

- (void)viewDidLoad{
     [super viewDidLoad];
// Do any additional setup after loading the view.

     [mapview setMapType:MKMapTypeStandard];
     [mapview setZoomEnabled:YES];
     [mapview setScrollEnabled:YES];

     MKCoordinateRegion region = { {0.0, 0.0 }, {0.0, 0.0 } };
     region.center.latitude = 123;
     region.center.longitude = 123;
     region.span.longitudeDelta = 0.01f;
     region.span.latitudeDelta = 0.01f;
     [mapview setRegion:region animated:YES];

     NewClass *ann = [[NewClass alloc] init];
     ann.title = @"Place to go to";
     ann.subtitle = @"subtitle";
     ann.coordinate = region.center;
     [mapview addAnnotation:ann];

}

是否可以使用 MapKit 在我的注释中添加“到这里的路线”按钮?任何帮助都是极好的!谢谢!

4

1 回答 1

2

要添加标注配件,您必须按照 Anna Karenina 的说明进行操作。

要绘制路线本身,您必须首先获取路线,有很多优秀的 API 可以为您提供两个给定点之间的路线,甚至允许您设置参数,例如您想要包含的路线类型。Google Directions API 在这方面给人留下了深刻的印象。你应该检查一下。

Then you have to draw the route itself with MKPolyline. You can check a toy app i put together a few months ago to show how to do this.

于 2012-10-13T14:57:25.173 回答