Google Maps scale – cheat sheet

In my efforts to learn JavaScript I ran on issue of scale Google Maps. Task is: choose right zoom level to put two known points on map. Right zoom – most close, which covers both points.

So I’ve wrote simple script which calculates how many lat/lng degrees are for 100 pixels of map. Following table for JS is result:

scale = [ 
 [ 60, 44.30560592914925],
 [ 60, 37.13873332588254],
 [ 35.15625, 21.828820746605853],
 [ 17.578125, 10.888547634349166],
 [ 8.7890625, 5.398562387546125],
 [ 4.39453125, 2.6935387402696023],
 [ 2.1972656249999996, 1.3457977980886113],
 [ 1.0986328125, 0.6727757526374205],
 [ 0.5493164062499994, 0.3363724297735935],
 [ 0.2746582031250006, 0.16818428240381778],
 [ 0.13732910156250058, 0.08409030611670865],
 [ 0.0686645507812506, 0.042045122852320205],
 [ 0.03433227539062559, 0.021022657242566467],
 [ 0.0171661376953125, 0.010511328149314991],
 [ 0.008583068847655658, 0.005255664015663797],
 [ 0.004291534423829309, 0.002627830444325241],
 [ 0.0021457672119146545, 0.00131391561027705],
 [ 0.001072883605956439, 0.0006569578050221736] 
  ];

How to use? So let’s assume You have map of size 500×400 points. So in zoom level 12 it will cover scale[12][0]*5 degrees horizontally (longitude) and scale[12][1]*4 degrees vertically (latitude). Feel free to use it in own apps.

Join the Conversation

1 Comment

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.