I added an overlay to my MKMapView using the addOverlay: method. The overlay was performed using MKPolyline and ironed using MKPolylineView. The color of the stroke is blue, with an alpha value of 0.7.
When the image initially loads, the overlay is drawn correctly, but the surrounding overlay areas are also blue ... When I click and zoom out, the blue area is still there, but it adjusts to my new zoom level. It's hard to describe ... but basically I have a small “normal map” rectangle captured inside a larger rectangle that is blue.
It will disappear when I zoom out to view the whole country, and when I go back, everything is fine.
I think this may be due to the fact that I am not correctly executing the MKOverlayProtocol?
If anyone has ideas, please give them your way ...
EDIT:
Here is the code that creates the MKPolyline and delegate method.
-(MKPolyline *)bluePolyline
{
CLLocationCoordinate2D bluePoints[16];
bluePoints[0] = CLLocationCoordinate2DMake(27.526483, -97.882454);
bluePoints[1] = CLLocationCoordinate2DMake(27.526407, -97.887883);
bluePoints[2] = CLLocationCoordinate2DMake(27.527244, -97.887905);
bluePoints[3] = CLLocationCoordinate2DMake(27.527282, -97.887304);
bluePoints[4] = CLLocationCoordinate2DMake(27.527577, -97.887304);
bluePoints[5] = CLLocationCoordinate2DMake(27.527596, -97.885727);
bluePoints[6] = CLLocationCoordinate2DMake(27.530194, -97.88577);
bluePoints[7] = CLLocationCoordinate2DMake(27.530213, -97.883892);
bluePoints[8] = CLLocationCoordinate2DMake(27.530279,-97.881907);
bluePoints[9] = CLLocationCoordinate2DMake(27.530337,-97.880201);
bluePoints[10] = CLLocationCoordinate2DMake(27.530356,-97.877959);
bluePoints[11] = CLLocationCoordinate2DMake(27.52753,-97.877884);
bluePoints[12] = CLLocationCoordinate2DMake(27.527492,-97.878367);
bluePoints[13] = CLLocationCoordinate2DMake(27.527397,-97.878817);
bluePoints[14] = CLLocationCoordinate2DMake(27.527349,-97.882454);
bluePoints[15] = CLLocationCoordinate2DMake(27.526483, -97.882453);
if(bluePolyline == nil)
{
bluePolyline = [MKPolyline polylineWithCoordinates:bluePoints count:16];
}
bluePolyline.title = @"Blue Route";
_bluePolyline = bluePolyline;
return _bluePolyline;
}
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay
{
MKPolylineView *aView = [[MKPolylineView alloc] initWithPolyline:(MKPolyline *)overlay];
aView.strokeColor = [[UIColor blueColor] colorWithAlphaComponent:0.6];
aView.lineWidth = 10;
return aView;
}