Skip to content

Instantly share code, notes, and snippets.

@evanlong
Created February 3, 2011 00:57
Show Gist options
  • Save evanlong/808845 to your computer and use it in GitHub Desktop.
Save evanlong/808845 to your computer and use it in GitHub Desktop.
Phantom lines appear on either the zero latitude or longitude axis if a point's latitude or longitudes settings are zero. Since both are zero in this case it will appear on both. This only occurs if the line width for the polyline is <= 1.
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
CLLocationCoordinate2D points[2];
points[0].latitude = 0;
points[0].longitude = 0;
points[1].latitude = -6;
points[1].longitude = 5;
MKPolyline* polyline = [MKPolyline polylineWithCoordinates:points count:2];
[mapView addOverlay:polyline];
[mapView setRegion:MKCoordinateRegionMake(CLLocationCoordinate2DMake(0, 0), MKCoordinateSpanMake(10, 10))];
}
- (MKOverlayView*)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay
{
MKPolylineView* polylineView = [[MKPolylineView alloc] initWithPolyline:overlay];
polylineView.lineWidth = 1;
polylineView.strokeColor = [UIColor redColor];
return [polylineView autorelease];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment