MKAnnotationView – Lock custom annotation view to pin on location updates

I created a project based on your CalloutMapAnnotationView demonstrating a IB based solution. Arrow keys animate motion of the location annotation and it’s callout annotation. The callout now also automatically resizes based on the supplied contentView, and the view is loaded from a separate nib. Good luck! https://github.com/jacobjennings/JJMapCallout

Detecting a point in a MKPolygon broke with iOS7 (CGPathContainsPoint)

For some reason (possibly a bug), the path property returns NULL in the current release of iOS 7. A workaround is to construct your own CGPathRef from the points of the polygon. With this method, you don’t need a reference to the MKPolygonView or the MKPolygonRenderer. For example: CGMutablePathRef mpr = CGPathCreateMutable(); MKMapPoint *polygonPoints = … Read more

iOS6 MKMapView using a ton of memory, to the point of crashing the app, anyone else notice this?

After a lot of playing around and testing different ideas, some of which were mentioned here, the final solution that worked for me was as follows. Instead of creating new MKMapView’s as needed in the app, I added an mkMapView property to my AppDelegate and only created it when needed. Once it has been created, … Read more

How to customize the callout bubble for MKAnnotationView?

There is an even easier solution. Create a custom UIView (for your callout). Then create a subclass of MKAnnotationView and override setSelected as follows: – (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; if(selected) { //Add your custom view to self… } else { //Remove your custom view… } } Boom, job done.

How to determine if an annotation is inside of MKPolygonView (iOS)

The following converts the coordinate to a CGPoint in the polygon view and uses CGPathContainsPoint to test if that point is in the path (which may be non-rectangular): CLLocationCoordinate2D mapCoordinate = …; //user location or annot coord MKMapPoint mapPoint = MKMapPointForCoordinate(mapCoordinate); MKPolygonView *polygonView = (MKPolygonView *)[mapView viewForOverlay:polygonOverlay]; CGPoint polygonViewPoint = [polygonView pointForMapPoint:mapPoint]; BOOL mapCoordinateIsInPolygon = … Read more

MKMapView: Instead of Annotation Pin, a custom view

When you want to use your own image for an annotation view, you should create an MKAnnotationView instead of an MKPinAnnotationView. MKPinAnnotationView is a subclass of MKAnnotationView so it has an image property but it generally overrides that and draws a pin image (that’s what it’s for). So change the code to: -(MKAnnotationView *)mapView:(MKMapView *)mV … Read more