How to disable user interaction on MKMapView?

eric picture eric · Mar 14, 2013 · Viewed 18.1k times · Source

How do you disable user interaction to an entire Map (MKMapView) in iOS? I just want to disable zooming, tapping, etc and show a static map. [self.mapView setUserInteractionEnabled:NO] didn't work. Found no working solutions via Google or other answers here on Stack (pls link if you find a working answer..). Targeting iOS 5. There should be an easier way to do this.

Answer

Rob picture Rob · Mar 14, 2013

The key is to disable zooms and scrolls.

In Objective-C:

self.mapView.zoomEnabled = false;
self.mapView.scrollEnabled = false;
self.mapView.userInteractionEnabled = false;

Or Swift:

mapView.isZoomEnabled = false
mapView.isScrollEnabled = false
mapView.isUserInteractionEnabled = false

By the way, if you want a static map, you might consider using MKMapSnapshotter instead. This creates an image representation of a map. If you have annotations or overlays, you have to render them manually, but, depending upon your use-case, map snapshots might do the job.