0
我想获取mapkit中两点之间的路线! ? 我做了一些谷歌的工作ñ发现这一点:-http://spitzkoff.com/craig/ P = 108查看地图中两点之间的路线+ iphone + Mapkit
我用这个来显示地图和引脚: -
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationController.navigationBarHidden=NO;
[email protected]"Map";
CLLocationCoordinate2D location;
location.latitude=[latLabel doubleValue];
location.longitude=[longLabel doubleValue];
MKCoordinateRegion region;// = MKCoordinateRegionMakeWithDistance(CLLocationCoordinate2DMake((location.latitude)/2.0, (location.longitude)/2.0), 1000.0, 1000.0);
region.center=location;
region.span.latitudeDelta =0.1;
region.span.longitudeDelta =0.1;
addAnnotation=[[AddressAnnotation alloc] initWithCoordinate:location];
NSLog(@"city=mapview=>%@",City);
NSLog(@"adress=mapview=>%@",Address);
addAnnotation.title=City;
addAnnotation.subtitle=Address;
[mapView addAnnotation:addAnnotation];
[mapView setRegion:region animated:YES];
}
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(AddressAnnotation *) annotation
{
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
annView.pinColor=MKPinAnnotationColorRed;
annView.draggable=TRUE;
annView.animatesDrop=TRUE;
annView.canShowCallout=YES;
annView.calloutOffset=CGPointMake(-5,5);
annView.draggable=TRUE;
return annView;
}
和注释类来显示名称和地址。但我应该如何添加更多以显示两点之间的路线。
请帮帮我。
在此先感谢
嗨,谢谢你的解决方案!它对我很好,有一点细节......它崩溃了:P。在这一行上:CLLocation * location =(CLLocation *)[NSKeyedUnarchiver unarchiveObjectWithData:[routes objectAtIndex:i]]; 。错误日志显示“[CLLocation bytes]:发送到实例的无法识别的选择器”。你有什么想法可能是错的?我得到谷歌的步骤列表,并有47个解码点在我的数组,但这unarchiveObjectWithData调用使应用程序崩溃。请让我知道你是否知道为什么。再次感谢您的解决方案。问候,乔治 – George
@乔治的unarchiving是可能存在的,因为我必须早先存档数据。如果你直接使用,你不会需要。 –