MKMapView reset back to world view
Asked Answered
D

4

11

How do I reset an MKMapView back to the world view zoom level?

Davidadavidde answered 20/1, 2011 at 15:59 Comment(0)
T
14

Try this:

MKCoordinateRegion region = MKCoordinateRegionMake(mapView.centerCoordinate, MKCoordinateSpanMake(180, 360));
[mapView setRegion:region animated:YES]; 

This will set a new region for the map view using the current center coordinate, and the maximum possible span (180 degrees of latitude, 360 degrees of longitude).

Talamantes answered 20/1, 2011 at 16:22 Comment(0)
H
38

The map rect for the world is stored as a constant named MKMapRectWorld.

MKCoordinateRegion worldRegion = MKCoordinateRegionForMapRect(MKMapRectWorld);
map.region = worldRegion;

One other way is to set the zoom level of the map. Although the MapKit framework does not support zoom levels as Google Maps API does, you can use this category extension written by Troy Brant.

Set the center coordinate to 0, 0 with zoom level 0 to get the same result.

[map setCenterCoordinate:CLLocationCoordinate2DMake(0, 0) zoomLevel:0 animated:0];
Hypotonic answered 20/1, 2011 at 16:41 Comment(0)
T
14

Try this:

MKCoordinateRegion region = MKCoordinateRegionMake(mapView.centerCoordinate, MKCoordinateSpanMake(180, 360));
[mapView setRegion:region animated:YES]; 

This will set a new region for the map view using the current center coordinate, and the maximum possible span (180 degrees of latitude, 360 degrees of longitude).

Talamantes answered 20/1, 2011 at 16:22 Comment(0)
Q
4

For those hoping to do this in Swift:

let region = MKCoordinateRegion(.world)
mapView.setRegion(region, animated: true)
Quad answered 6/12, 2018 at 1:40 Comment(0)
C
0

MKMapView can not zoom out to show the whole world. No matter what you are using, MKMapRectWorld, zoom level 0, or MKCoordinateSpanMake(180, 360).

Chancemedley answered 15/7, 2016 at 3:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.