//Used to show locations eg local groups on a google map //June 2008 - JN changed to use Lat/long values, and restrict zoom // Create FOE marker icon var icon = new GIcon(); icon.image = "/imgs/common/map_marker.gif"; icon.iconSize = new GSize(12, 12); icon.iconAnchor = new GPoint(1,1); icon.infoWindowAnchor = new GPoint(5, 1); //create info box with group URL function createInfoMarker(point, address, url, group_name, location) { var marker = new GMarker(point,icon); var maddress = 'null'; var text1 = '

'+ address +', '+ location +'
Thanks to '+ group_name +' for this signup

'; var text2 = '

'+ address +', '+ location +'

'; if (group_name == "unknown") { maddress = text2; } else { maddress = text1; } GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(maddress); } ); return marker; } //Get initial lat, long, zoom level and map type from calling page function loadmap(lat,long,z,maptype) { //Fade the map out slightly - value can be anything less than 1. G_NORMAL_MAP.getTileLayers()[0].getOpacity = function () {return 0.8;}; //Set max and min zoom levels G_NORMAL_MAP.getMinimumResolution = function () { return 5 }; G_NORMAL_MAP.getMaximumResolution = function () { return 13 }; var map = new GMap2(document.getElementById("map")); map.addControl(new GLargeMapControl()); //Show scale map.addControl(new GScaleControl()); //Add control to change type of map //map.addControl(new GMapTypeControl()); // Center the map on a particular point, with a certain zoom level map.setCenter(new GLatLng(lat,long), z, maptype); // Download the data in from an xml source file and load it on the map. var request = GXmlHttp.create(); request.open("GET", "/xml/renewables_signups.xml", true); request.onreadystatechange = function() { if (request.readyState == 4) { var xmlDoc = request.responseXML; var markers = xmlDoc.documentElement.getElementsByTagName("item"); for (var i = 0; i < markers.length; i++) { var lati = markers[i].getElementsByTagName("Lat")[0].firstChild.nodeValue; var longi = markers[i].getElementsByTagName("Long")[0].firstChild.nodeValue; var point = new GLatLng(parseFloat(lati),parseFloat(longi)); var location = markers[i].getElementsByTagName("Location")[0].firstChild.nodeValue; var group_name = markers[i].getElementsByTagName("Local_Group")[0].firstChild.nodeValue; var address = markers[i].getElementsByTagName("Title")[0].firstChild.nodeValue; //Ignore any entries without lat/long values and where local group source is unknown //NB else IE stops showing markers when NULL value occurs, and FF shows them in the wrong place if (lati != "NULL" && longi != "NULL") { var url = markers[i].getElementsByTagName("Title")[0].firstChild.nodeValue; var marker = new GMarker(point); var marker =createInfoMarker(point, address, url, group_name, location); map.addOverlay(marker); } } } } request.send(null); }