我在地图上放了两个别针:
- (void)viewDidLoad {
[super viewDidLoad];
CLLocationCoordinate2D cord1 = {.latitude = 44.508473, .longitude = 11.375828};
CLLocationCoordinate2D cord2 = {.latitude = 44.508871, .longitude = 11.375854};
[self.mapView setRegion:MKCoordinateRegionMake(cord1, MKCoordinateSpanMake(.005, .005)) animated:YES];
[self.mapView setRegion:MKCoordinateRegionMake(cord2, MKCoordinateSpanMake(.005, .005)) animated:YES];
AddressAnnotation * annotazione = [[AddressAnnotation alloc] init];
AddressAnnotation * annotazione2 = [[AddressAnnotation alloc] init];
[annotazione setCoordinate:cord1];
[annotazione2 setCoordinate:cord2];
[self.mapView addAnnotation:annotazione];
[self.mapView addAnnotation:annotazione2];
}
有没有办法将引脚与线连接?谢谢!
答案 0 :(得分:2)
MKPolyline
使用方法polylineWithCoordinates:count:
,它采用了许多坐标。您已经拥有了所需的两个坐标(cord1
和cord2
)来创建折线。将叠加层添加到地图中并实施mapView:viewForOverlay:
以返回叠加层视图。
答案 1 :(得分:1)
在iOS 4.x中,Apple增加了对地图叠加的支持。可能有助于阅读更多有关MKPolyline& amp; MKPolylineView类和MKViewViewDelegate协议中定义的mapView:viewForOverlay:方法。所有这些都可以在Map Kit框架参考中找到。