1
votes

I figured out how to calculate the current zoom level of the map from http://troybrant.net/blog/2010/01/set-the-zoom-level-of-an-mkmapview/ (the first comment on that blog), but it gives me a value between 0 and 20, whereas region.span has values like 0.1f, 0.01f etc.

I want to calculate the current zoom level and then if a user does a "long tap", then an annotation has to be dropped. I have done everything except that I have hardcoded following:

region.span.longitudeDelta = 0.2f;
region.span.latitudeDelta = 0.2f;

So instead of 0.2f, I would like to put a number which I get from Zoom Level (between 0-20). So is there any way to do this conversion?

Is it done like this?

(Current Zoom Level Output/Maximum Zoom Level);
1
longtitudeDelta is not a fraction of the total zoom amount. It is the number of degrees for latitude you can see from the far left of the view to the far right. Delta = difference between the two sides.Craig

1 Answers

0
votes

I googled your exact question and the second result was pointing back to StackOverflow here: MKMapView Zoom and Region which has a very well detailed answer. The short version is: try using [mapview region].span.latitudeDelta and longitudeDelta.

ref: http://developer.apple.com/library/ios/DOCUMENTATION/MapKit/Reference/MKMapView_Class/MKMapView/MKMapView.html#//apple_ref/occ/instp/MKMapView/region and: http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MapKitDataTypesReference/Reference/reference.html