2013-05-06 62 views
0

我想要获取MKMapview中的方向路线详细信息。我在下面提到了一个示例网址。同样我想但不想去下一个网址。如果你知道的话,请任何人帮忙。是否有可能在ios中?如何在MKMapview中获取路线方向的详细信息

CLLocationCoordinate2D start = { (37.785834), (-122.406417) }; 
CLLocationCoordinate2D end = { (48.922499), (-125.507813) }; 

NSString *googleMapsURLString = [NSString stringWithFormat:@"http://maps.google.com/?saddr=%1.6f,%1.6f&daddr=%1.6f,%1.6f", start.latitude, start.longitude, end.latitude, end.longitude]; 

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:googleMapsURLString]]; 

回答

0

我认为这可以帮助你从你的起点到终点获得路线..

在你Viewcontroller.m文件,请使用此代码..

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    MapView* mapView = [[[MapView alloc] initWithFrame: 
         CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)] autorelease]; 

    [self.view addSubview:mapView]; 

    Place* home = [[[Place alloc] init] autorelease]; 
    home.name = @"Home"; 
    home.description = @"Sweet home"; 
    home.latitude = 37.785834; 
    home.longitude = -122.406417; 

    Place* office = [[[Place alloc] init] autorelease]; 
    office.name = @"Office"; 
    office.description = @"Bad office"; 
    office.latitude = 48.922499; 
    office.longitude = -125.507813; 


    [mapView showRouteFrom:home to:office]; 
} 

更多细节关于这个看到这个网站的代码.. http://code.google.com/p/ashiphone/downloads/detail?name=MapWithRoutes.zip&can=2&q=

如果你的问题得到解决其良好,否则随时问..

+0

谢谢您的回复。我清楚地知道从目的地到目的地的路线。我想要从目的地到目的地的方向详细信息(摘要)(例如:1.go直行,左转,5KM后右转) – 2013-05-06 07:29:34

+0

@vishnusivabalan你检查这个链接并下载示例代码...享受.. – Shivaay 2013-05-06 07:34:51

+0

抱歉json。该代码只给出两个地方之间的方向。我需要两个方向之间的路线的细节(摘要)。如果你知道请帮助。 – 2013-05-06 09:00:50

相关问题