The size of circles on Google Maps

On the ramblings site you can see how to create Google Maps straight from Excel, including adding circle overlays. By default, the code generated to plot these circles looks like this.

  if (sz) {
      var circle =  {
         strokeColor: color,
         strokeOpacity: 0.8,
         strokeWeight: 1,
         fillColor: color,
         fillOpacity: 0.20,
         map: gMap,
         center: p,
         radius: parseFloat(sz), 

Where sz and color are variables that have been inherited from columns in your input Excel data.

Calculating an appropriate size for circles. 
Normally you’ll be generating a size value for each data item based on some property like population or whatever your map is supposed to be representing, and overlaid circles would vary in size relative to your data values. At first glance it seems easy enough.

However, the impression of the size of a circle comes from its area , but what google maps needs is a radius. Thinking back to basic math, the area of a circle is calculated as

PI() * POWER(r,2)

So clearly you can’t use a simple linear formula to generate your size data.

Calculating a relative radius
The radius of a circle is calculated from the area by this formula


so to be able to get the effect you want, you should apply this formula to your linear data (a) to generate a relative radius for each data item.

Obviously your scale (the final size of the circle generated), should be appropriate for the geography being shown.When you specify the radius of a circle to be plotted on Google Maps, we’re talking about meters, and 1 kilometer is just over .6 of a mile, so you will need to multiply the radius by some number of meters, giving a final formula of

SQRT( (your linear calculated size) / PI()) * (some number of meters)

For more on Google Maps from Excel, see the ramblings site.

Author: bm082975

Leave a Reply

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