//Used to show locations eg local groups on a google map //June 2008 - JN changed to use Lat/long values, and restrict zoom //april 2009 - SG changed to expand zoom :) // Create FOE marker icon var icon = new GIcon(); icon.image = "http://www.foe.co.uk/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) { var marker = new GMarker(point,icon); var maddress = '
' + address + '
' GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(maddress); actiontracker('search.lg.map'); } ); 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 10 }; G_NORMAL_MAP.getMaximumResolution = function () { return 12 }; var map = new GMap2(document.getElementById("map")); map.addControl(new GSmallMapControl()); //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", "/rss/lgs.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("latitude")[0].firstChild.nodeValue; var longi = markers[i].getElementsByTagName("longitude")[0].firstChild.nodeValue; var point = new GLatLng(parseFloat(lati),parseFloat(longi)); var address = markers[i].getElementsByTagName("title")[0].firstChild.nodeValue; //Ignore Test Friends of the Earth, and any entries without lat/long values //NB else IE stops showing markers when NULL value occurs, and FF shows them in the wrong place if (address.indexOf("Test Friends of the Earth") ==-1 && lati != "NULL" && longi != "NULL") { var url = markers[i].getElementsByTagName("link")[0].firstChild.nodeValue; var marker = new GMarker(point); var marker =createInfoMarker(point, address, url); map.addOverlay(marker); } } } } request.send(null); }