Hacking Google Maps and Google Earth (ExtremeTech)

(Dana P.) #1

Chapter 7 — Extending the Google API Examples 115


var point = new GPoint(parseFloat(x),parseFloat(y));
map.addOverlay(new GMarker(point));
}


//]]>



This time, the code defines a new function,addmarker(). This function creates a new point
and marker and then adds this to the active map. Calls to the function are then added at the
end of the onLoad()function to create the markers when the web page is loaded.


The result is shown in Figure 7-7.


FIGURE7-7: Adding multiple markers during startup.


Adding Lines


Individual map markers are a great way of highlighting a particular point on a map, but some-
times you want to indicate an area or locale, rather than a specific point. You could create an
icon that highlights this information, but a more effective approach is to use the built-in line
drawing system provided by the Google Maps API to draw a polyline.

Free download pdf