8

In MKMapView in some zoom lvl all map tiles are blank. I try solution with max zoom. For now I use it like this:

 func mapView(mapView: MKMapView, regionDidChangeAnimated animated: Bool) {
        userSpan = mapView.region.span
        if mapView.zoomLevel() > maxZoomLvl
        {
            mapView.setCenterCoordinate(mapView.centerCoordinate, zoomLevel: maxZoomLvl, animated: true)
        }
    }

But when user zoom to max lvl it zoom back with animation. But I need some solution like in native apple map application: just block in max zoom without ability to zoom deep and without zoom back. Expected result:

  1. Avoid bland tiles in max zoom and zoom back bounce (like it work now with current solution)
  2. Map should stop zooming if there no tiles (Like native apple map app) OR map should scale last visible tiles(like google maps app)
Community
  • 1
  • 1
UnRewa
  • 2,462
  • 2
  • 29
  • 31

1 Answers1

0

You can do this using mapView.camera which is an MKMapCamera object.

From the docs -

var altitude: CLLocationDistance

The altitude above the ground, measured in meters.

Just need to find a good value for altitude. From this answer, Is there way to limit MKMapView maximum zoom level?

It seems like following might help you-

- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
// enforce maximum zoom level
if (_mapView.camera.altitude < 120.00 && !_modifyingMap) {
    _modifyingMap = YES; // prevents strange infinite loop case

    _mapView.camera.altitude = 120.00;

    _modifyingMap = NO;
}
}
Community
  • 1
  • 1
Tarun Tyagi
  • 9,364
  • 2
  • 17
  • 30
  • When you release fingers zoom jump back... I think I shouldn't use regionDidChangeAnimated because it will be zoom back in any solution – UnRewa Oct 24 '16 at 09:29