/** 在指定经纬度添加线 */
- (void)addPolyline{
CLLocationCoordinate2D lineCoords[2] = {{30.662221,104.041367}, {30.762221,104.041367}};
MKPolyline *path = [MKPolyline polylineWithCoordinates:lineCoords count:2];
[_mapView addOverlay:path];
}
/** 描述线的样式,并绘制线 */
- (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id <MKOverlay>)overlay{
if (![overlay isKindOfClass:[MKPolyline class]]) {
return nil;
}
MKPolyline *polyline = (MKPolyline *)overlay;
// MKOverlayPathRenderer *pathRend = [[MKOverlayPathRenderer alloc] initWithOverlay:polyline];
MKPolylineRenderer *renderer = [[MKPolylineRenderer alloc] initWithPolyline:polyline];
renderer.strokeColor = [UIColor redColor];
renderer.lineWidth = 1.0;
return renderer;
}