Skip to content

Instantly share code, notes, and snippets.

@tdegrunt
Forked from ebinnion/.m file
Created December 11, 2013 16:09
Show Gist options
  • Select an option

  • Save tdegrunt/7913230 to your computer and use it in GitHub Desktop.

Select an option

Save tdegrunt/7913230 to your computer and use it in GitHub Desktop.
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id<MKOverlay>)overlay
{
if ([overlay isKindOfClass:[MKPolygon class]])
{
MKPolygonView* aView = [[MKPolygonView alloc]initWithPolygon:(MKPolygon*)overlay];
aView.fillColor = [[UIColor cyanColor] colorWithAlphaComponent:0.2];
aView.strokeColor = [[UIColor blueColor] colorWithAlphaComponent:0.7];
aView.lineWidth = 3;
return aView;
}
return nil;
}
- (void)viewDidLoad
{
// Adds a polygon over the commuter parking in front of the library
CLLocationCoordinate2D libComPark[4];
libComPark[0] = CLLocationCoordinate2DMake(33.874689,-98.520148);
libComPark[1] = CLLocationCoordinate2DMake(33.87469,-98.519692);
libComPark[2] = CLLocationCoordinate2DMake(33.874314,-98.519687);
libComPark[3] = CLLocationCoordinate2DMake(33.874316,-98.520146);
MKPolygon *polLibcomPark = [MKPolygon polygonWithCoordinates:libComPark count:4];
[msuMap addOverlay:polLibcomPark];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
Declare an array that will hold the coordinates within the viewDidLoad function/method. Then fill the array with the coordinates. Then define a MKPolygon pointer that will use that array. Last, add the overlay to the map.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment