I am loading multiple MKPolylines as overlays onto an MKMapView. I would like to be able to distinguish these some how so change things like color, line width, etc.
But, when viewForOverlay: gets called, it sees all my MKPolylines the same, which doesn't allow me to change any of them.
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay {
if ([overlay isKindOfClass:[MKPolyline class]]) {
MKPolylineView *aView = [[[MKPolylineView alloc] initWithPolyline:(MKPolyline*)overlay] autorelease];
aView.strokeColor = [[UIColor blueColor] colorWithAlphaComponent:0.7];
MKZoomScale currentZoomScale = (CGFloat)(mapView.bounds.size.width / mapView.visibleMapRect.size.width);
aView.lineWidth = MKRoadWidthAtZoomScale(currentZoomScale);
return aView;
}
// Want to color my next overlay red
return nil;
}
How can I do this? Could I somehow attach tag to each MKPolyline? Or, another, better way to do this?