Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MapKit iPhone display Zoom Controls

Is it possible using MapKit to show a map in iPhone, like i´m doing, to display zoom controls on the map?

If not, what are the flags or methods i should use to increase and diminish the zoom, so i can created methods which will do this at the push of a button.

like image 700
bruno Avatar asked Feb 04 '26 12:02

bruno


1 Answers

There aren't any built-in controls for it.

A couple of suggestions:

  1. You can predefine some spans and store them in an array somewhere and then store your position in that array as well. Zooming in/out changes the position and gets the span.
  2. Zooming in takes the current span and divides by 2, zooming out multiplies by 2.

You change the span in the region of the mapView. So you have to:

  • Get the region of the mapView.
  • Get the span of the region.
  • Change the span to what you want.
  • Set the regions span to the new span.
  • Set the mapView's region to the new region.

Here's some code for suggestion 2:

MKCoordinateRegion region = mapView.region;
MKCoordinateSpan span;
span.latitudeDelta = region.span.latitudeDelta*2;
span.longitudeDelta = region.span.longitudeDelta*2;
region.span = span;
[mapView setRegion:region animated:TRUE];
like image 93
vakio Avatar answered Feb 06 '26 17:02

vakio



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!