Alex Coplan
Alex Coplan

Reputation: 13361

Smaller MapKit Zoom Interval iPhone

I'm trying to zoom to a specific region. The problem I'm having is that as far as I can tell, programatically, you can only set to fixed zoom levels. I've made a test app to demonstrate this. I'm using fixed centre coordinates, then just altering the size in metres. In the testing I've done between 1000 and 4000 the zoom levels are aprrox: <1000<1940, 1940<3865, 3865<4000+. These are the only three zoom levels that it will let you go to from 1000-4000. The problem I'm having is the zoom level I want is somewhere between 1940 and 3865, simply because below 1940, my annotations don't fit on, and greater than 3865, the imagery looks very poor compared to that at the smaller zoom, and what's really frustrating is that I can set it just right, with the annotations fitting and the imagery looking good by zooming in the app, but not by setting it programatically.

Does anyone know of a more accurate way of setting this? (I've tried using my same test app on long/lat spans - has the same boundaries).

Thanks in advance

Upvotes: 2

Views: 253

Answers (3)

Bushra Shahid
Bushra Shahid

Reputation: 3579

Yeah thats a problem but you can try and find the values that suit your need. The numbers may not be exactly the same as you want. You need to figure it out by looking at the map. I had to do the same today and i did this:

  1. implemented the mapView:regionDidChangeAnimated: logged the current region of the map. I got 0.26... and 0.24... as span but even if i put those values, i didnt get the same zoom level.

  2. Since i got more zoomed out than i wanted, I started reducing these values and ended up using 0.2 and 0.18.

The only solution that currently comes to mind is trial and error. You can also get the values for zoom level which you want by manual pinch. Then set region programmatically using those values. If map is more zoomed out try reducing the latitude and longitude delta proportionally. If its zoomed it try increasing them proportionally.

I hope this helps you.

Upvotes: 0

shawkinaw
shawkinaw

Reputation: 3180

In principle you're supposed to be able to set an arbitrary zoom level with setVisibleMapRect:animated: and setRegion:animated:. However, there seems to be a bug in MapKit which "rounds up" to the next full zoom level, as you've noticed ... quite annoying behavior. I reported it to Apple some time ago and it remains open according to the bug reporting system. I'm sorry to report that I was unable to find any workarounds.

Upvotes: 0

Ortwin Gentz
Ortwin Gentz

Reputation: 54111

MapKit only allows to set integral zoom levels. File an enhancement request for non-integral zoom levels.

Upvotes: 2

Related Questions