// Creates a marker at the given point function createMarker(point, lat, lon, image, spec_id, species, citation) { var marker = new GMarker(point); var new_html = '
' new_html += 'Species: ' + species + ' ' + citation + '
'; if(spec_id != null){ new_html += 'Specimen No.: ' + spec_id + '
'; } new_html += 'Lat: ' + lat +' '; new_html += 'Long: ' + lon +'
'; if(image != null) { new_html += 'Image of ' + species + ''; } new_html += '
'; GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(new_html); }); return marker; } function google_map_load() { if (GBrowserIsCompatible()) { //Create new instance of Google Map var map = new GMap2(document.getElementById("google_map")); //Add small controls, up/down/left/right, zoom in/zoom out map.addControl(new GSmallMapControl()); //Add random center for map map.setCenter(new GLatLng(0, 0), 0); //Set the map to Hybrid mode var x=map.getMapTypes(); map.setMapType(x[2]); //create new instance of boundary markers var bounds = new GLatLngBounds(); var col_num = 0; //Download the XML file that contains the relevant point markers for an overlay GDownloadUrl(siteroot + "map_markers/campaign/1/id/506", function(data, responseCode) { var xml = GXml.parse(data); var markers = xml.documentElement.getElementsByTagName("marker"); //Loop through the markes and create overlay points and set the boundary zone for (var i = 0; i < markers.length; i++) { var bold_lat = parseFloat(markers[i].getAttribute("lat")); var bold_lon = parseFloat(markers[i].getAttribute("lng")); var species = markers[i].getAttribute("name"); var citation = markers[i].getAttribute("citation"); var spec_id =markers[i].getAttribute("spec_id"); var bold_img = markers[i].getAttribute("pic"); var point = new GLatLng(bold_lat,bold_lon); var marker = createMarker(point, bold_lat, bold_lon, bold_img, spec_id, species, citation); map.addOverlay(marker); bounds.extend(point); var zoom_lvl = map.getBoundsZoomLevel(bounds); if(zoom_lvl > 5){ zoom_lvl = 5; } map.setZoom(zoom_lvl); var clat = (bounds.getNorthEast().lat() + bounds.getSouthWest().lat()) /2; var clng = (bounds.getNorthEast().lng() + bounds.getSouthWest().lng()) /2; map.setCenter(new GLatLng(clat,clng)); col_num++; $('col_num').innerHTML = col_num; } }); } } Behaviour.addLoadEvent(google_map_load);