192 Part III — Google Map Hacks
FIGURE10-3: A close up of California population data for 2000.
Adding a Circle
Polylines, by their very definition, must have at least two, non-equal points in order for them to
be drawn on the map. By calculating the difference between the original data point and a desti-
nation data point, you can almostcreate a circle (although in reality it is probably closer to an
oval or a rectangle with rounded edges).
To achieve this, a cue about the size of the circle that is to be created can be taken from the
current longitude and latitude span of the map. In fact, you can use the same basic calculation
you use when determining the bar graph interval size.
Instead of modifying only the latitude, you adjust both the latitude and longitude. To show the
population values, the width of the line is adjusted according to the same rules as before. The
code is almost identical, aside from the second point in the array for the polyline and the vol-
ume specification:
function addgraph(year) {
var currentsize = map.getSpanLatLng();
var increment = (parseFloat(currentsize.height)/10.0)/100;
var maxsize = 0;
var graphdata = [];
map.clearOverlays();
polylines = [];
markers = [];
infopanel.innerHTML = ‘’;
for(var i=0;i<popdata.length;i++) {
graphdata.push(popdata[i][year]);
if (popdata[i][year] > maxsize) {
maxsize = popdata[i][year];