Search code examples
objective-cmkmapviewmapkittilescustom-overlay

How to remove or hide background in MKMapView when using custom tiles


Having tried many methods I still haven't found a good and full-proof way of preventing the usual "maps" from being shown behind custom map tiles that I am using. Ultimately I want my app to have a map page consisting only of a custom map.

I am really looking for a solution that is pure iOS and doesn't require any 3rd party software but it would appear difficult.

I have tried 3 methods already:

Number 1, hiding the background map via it's view:

NSArray *views = [[[self.mapView subviews] objectAtIndex:0] subviews];
[[views objectAtIndex:0] setHidden:YES];
  • this however doesn't work on a certain new operating system coming out very soon! The whole screen goes blank. The Apple Developer Forum hasn't provided a solution either

Number 2, Using another blank overlay (e.g. MKCircle) to cover the background map. This works however when scrolling or zooming out quickly, sometimes the overlay flickers off and you can briefly see the background map behind so not ideal.

Number 3, and this is what I have been working on for a few days now is to simply prevent the user from zooming out. Most documented methods tend to use regionDidChangeAnimated or regionWillChangeAnimated, however these do not seem to suddenly stop the map zooming out when pinching - they wait until the pinch movement has finished before taking effect so again it means the background map can be viewed briefly.

So now I am stumped, unless of course I have missed something with these other two methods.

So any help would be much appreciated!


Solution

  • You can't do this in current releases without a third-party library like MapBox. However, the future OS release that you speak of lets you do this.