Skip to content

Instantly share code, notes, and snippets.

@cgcardona
Created August 29, 2010 19:45
Show Gist options
  • Save cgcardona/556613 to your computer and use it in GitHub Desktop.
Save cgcardona/556613 to your computer and use it in GitHub Desktop.
function initialize() {
if (GBrowserIsCompatible()) {
var firstValue = $('#lat').html()
var secondValue = $('#lon').html()
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(firstValue, secondValue), 16);
// Add 10 markers to the map at random locations
var bounds = map.getBounds();
var southWest = bounds.getSouthWest();
var northEast = bounds.getNorthEast();
var lngSpan = northEast.lng() - southWest.lng();
var latSpan = northEast.lat() - southWest.lat();
for (var i = 0; i < 10; i++) {
var latlng = new GLatLng(southWest.lat() + latSpan * Math.random(),
southWest.lng() + lngSpan * Math.random());
map.addOverlay(new GMarker(latlng));
}
// Select a map type
map.setMapType(G_HYBRID_MAP);
map.setUIToDefault();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment