Custom MKPinAnnotation callout bubble similar to default callout bubble

I have developed a custom callout bubble that is nearly identical to the system callout bubble, but gives more flexibility over the height and content. It should be fairly trivial to adjust the appearance to suit your needs. See my post on the Asynchrony Solutions blog for example code and the steps required to implement … Read more

iOS – How to limit the MapView to a specific region?

After trying different ways of limited MKMapView I’ve concluded that using mapDidChange, and resetting if you’re center point goes outside of the boundaries works best, with animated: YES Here’s how I do it (Using the New Zealand lat/Long span/center). – (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated{ if ((mapView.region.span.latitudeDelta > 15.589921 ) || (mapView.region.span.longitudeDelta > 175.836914) ) { CLLocationCoordinate2D … Read more

How to define the order of overlapping MKAnnotationViews?

Ok, so for solution use method from MKMapViewDelegate – (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views In this method you should rearrange AnnotationView after it was added to mapKit View. So, code may looks like this: – (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views { for (MKAnnotationView * annView in views) { TopBottomAnnotation * ann = (TopBottomAnnotation *) [annView annotation]; if … Read more

How to add a button to the MKPointAnnotation?

You are doing it right.You just need to have these methods implemented for adding button along with title and subtitle iOS 8 and Xcode 6 import UIKit import MapKit import CoreLocation class MapKitViewController: UIViewController, MKMapViewDelegate { let locationManager = CLLocationManager() @IBOutlet weak var nmapView: MKMapView! override func viewDidLoad() { super.viewDidLoad() locationManager.requestWhenInUseAuthorization() locationManager.startUpdatingLocation() let location = … Read more

MKPinAnnotationView: Are there more than three colors available?

some more 😉 And the original ones : And the code: – (MKAnnotationView*)mapView:(MKMapView*)mapView viewForAnnotation:(id <MKAnnotation>)annotation { MKPinAnnotationView* anView =[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@”test”]; anView.pinColor=MKPinAnnotationColorPurple; UIImage* image = nil; // 2.0 is for retina. Use 3.0 for iPhone6+, 1.0 for “classic” res. UIGraphicsBeginImageContextWithOptions(anView.frame.size, NO, 2.0); [anView.layer renderInContext: UIGraphicsGetCurrentContext()]; image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); NSData* imgData = UIImagePNGRepresentation(image); NSString* … Read more

MKMapView Zoom and Region

First of all, MKMapView does not use/have a predefined set of zoom levels like Google Maps does. Instead, the visible area of a MKMapView is described using MKCoordinateRegion, which consists of two values: center (the center point of the region), and span (the size of the visible area around center). The center point should be … Read more

Customize MKAnnotation Callout View?

It should first be noted that the simplest changes to the callout are enabled by simply adjusting the properties of the system provided callout, but customizing the right and left accessories (via rightCalloutAccessoryView and leftCalloutAccessoryView). You can do that configuration in viewForAnnotation. Since iOS 9, we have access to the detailCalloutAccessoryView which, replaces the subtitle … Read more