Advertisement
wkerswell

map overlay

Nov 1st, 2012
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -(MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id<MKOverlay>)overlay{
  2.     //make a new overlay
  3.     MKPolygonView *polyView = [[MKPolygonView alloc] initWithOverlay:overlay];
  4.     //set things
  5.     polyView.lineWidth = 1;
  6.     //polyView.strokeColor = [UIColor blueColor];
  7.    
  8.     //get the image and make it fit the overlay
  9.     UIImage *image = [UIImage imageNamed:@"map.jpeg"];
  10.     MKMapRect theMapRect = [overlay boundingMapRect];
  11.    
  12.     CGSize size = CGSizeMake(theMapRect.size.width, theMapRect.size.height);
  13.    
  14.     UIGraphicsBeginImageContext(size);
  15.     [image drawInRect:CGRectMake(0, 0, size.width, size.height )];
  16.     UIImage *finalImage = UIGraphicsGetImageFromCurrentImageContext();
  17.     UIGraphicsEndImageContext();
  18.    
  19.     //assign the final image as the fill color
  20.     polyView.fillColor = [UIColor colorWithPatternImage:finalImage];
  21.     return polyView;
  22.    
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement