I couldn’t find this information today when I needed, so I thought I’d share. If it’s in the Google maps documentation, then I missed it.
If you want to zoom a map to fit a particular distance as tightly as possible, you need to know the scale of each of the 19 levels. In metres per pixel, I worked them out to be as follows:
zoom m/px 19 0.19 18 0.37 17 0.74 16 1.48 15 3 14 6 13 12 12 24 11 48 10 95 9 190 8 378 7 752 6 1,485 5 2,909 4 5,540 3 10,064 2 16,355 1 21,282
So if you needed to calculate the zoom level to fit an area of a given radius you could use a function like this:
function radiusToZoom( r ){ var w = myMapInstance.getSize().width; var d = r * 2; var zooms = [,21282,16355,10064,5540,2909,1485,752,378,190,95,48,24,12,6,3,1.48,0.74,0.37,0.19]; var z = 20, m; while( zooms[--z] ){ m = zooms[z] * w; if( d < m ){ break; } } return z; }
As of my understanding the resolution metres per pixel depends on the latitude and cannot be determined in common.
works just fine, thanks
Are you sure about this numbers?