//<![CDATA[
var map = new GMap(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.centerAndZoom(new GPoint(-122.241944, 37.441944), 4);
// Add 10 random Markers in the map viewport using the default icon
var bounds = map.getBoundsLatLng();
var width = bounds.maxX - bounds.minX;
var height = bounds.maxY - bounds.minY;
for( var i=0; i<10; i++)
{
var point = new GPoint(bounds.minX+width*Math.random(), bounds.minY+height*Math.random());
var marker = new GMarker(point);
map.addOverlay(marker);
}
// Add a polyline with 4 random points. Sort the points by long so that
// the line does not intersect itself
var points = [];
for( var i=0; i<5; i++)
{
points.push(new GPoint(bounds.minX+width*Math.random(), bounds.minY+height*Math.random()));
}
points.sort(function(p1,p2) {return p1.x - p2.x; });
map.addOverlay(new GPolyline(points));
map.openInfoWindow(map.getCenterLatLng(),
document.createTextNode("Hello world"));
GEvent.addListener(map, 'click', function(overlay, point)
{
if(overlay) { map.removeOverlay(overlay); }
else if(point) { map.addOverlay(new GMarker(point)); }
});
// window.setTimeout(function() {
//map.recenterOrPanToLatLng(new GPoint(-122.1569, 37.4569)); }, 2000);
//]]>