ios - determine current zoomscale for mapview -
how can calculate current zoomscale mkmapview?
use following code:
#define mercator_radius 85445659.44705395 #define max_google_levels 20 - (double)getzoomlevel { cllocationdegrees longitudedelta = self.mapview.region.span.longitudedelta; cgfloat mapwidthinpixels = self.mapview.bounds.size.width; double zoomscale = longitudedelta * mercator_radius * m_pi / (180.0 * mapwidthinpixels); double zoomer = max_google_levels - log2( zoomscale ); if ( zoomer < 0 ) zoomer = 0; // zoomer = round(zoomer); return zoomer; }
the return value of getzoomlevel
method current zoom level of mapview
property.
Comments
Post a Comment