function loadmap(){ if (GBrowserIsCompatible()) { // arrays to hold copies of the markers used by the side_bar // because the function closure trick doesnt work there var gmarkers = []; var gicons=[]; gicons["large"] = new GIcon(G_DEFAULT_ICON, "/static/images/defaultmarker.png"); gicons["large"].iconSize = new GSize(48, 50); gicons["large"].shadowSize = new GSize(0, 0); gicons["large"].iconAnchor = new GPoint(24, 49); gicons["large"].infoWindowAnchor = new GPoint(24, 5); gicons["large"].imageMap = [0,0,0,49,47,49,47,0]; gicons["small"] = new GIcon(G_DEFAULT_ICON, "/static/images/smallmarker.png"); gicons["small"].iconSize = new GSize(30, 31); gicons["small"].shadowSize = new GSize(0, 0); gicons["small"].iconAnchor = new GPoint(15, 30); gicons["small"].infoWindowAnchor = new GPoint(15, 5); gicons["small"].imageMap = [0,0,0,30,29,30,29,0]; gicons["you"] = new GIcon(G_DEFAULT_ICON, "/static/images/youmarker.png"); gicons["you"].iconSize = new GSize(48, 50); gicons["you"].shadowSize = new GSize(0, 0); gicons["you"].iconAnchor = new GPoint(24, 49); gicons["you"].infoWindowAnchor = new GPoint(24, 5); gicons["you"].imageMap = [0,0,0,49,47,49,47,0]; // A function to create the marker and set up the event window function createMarker(point,name,html,iconimage) { var marker = new GMarker(point, gicons[iconimage]); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); // save the info we need to use later for the side_bar gmarkers.push(marker); return marker; } // This function picks up the click and opens the corresponding info window function myclick(i) { GEvent.trigger(gmarkers[i], "click"); } // create the map var map = new GMap2(document.getElementById("map")); var clusterer = new Clusterer(map); clusterer.SetMaxVisibleMarkers('100'); clusterer.SetMinMarkersPerCluster('3'); clusterer.SetMaxLinesPerInfoBox('2'); map.addControl(new GSmallMapControl()); map.addControl(new GMapTypeControl(1)); map.setCenter(new GLatLng(55.9508818512,-3.2136726379),15); map.enableDoubleClickZoom(); map.enableScrollWheelZoom(); // Read the data from XML GDownloadUrl("/ajax/gm_xml.php?id=238&showme=", function(doc) { var xmlDoc = GXml.parse(doc); var markers = xmlDoc.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { // obtain the attribues of each marker var openmarker; var lat = parseFloat(markers[i].getAttribute("lat")); var lng = parseFloat(markers[i].getAttribute("lng")); var point = new GLatLng(lat,lng); var html = markers[i].getAttribute("html"); var label = markers[i].getAttribute("label"); var iconimage = markers[i].getAttribute("icon"); var openmarker = markers[i].getAttribute("openmarker"); // create the marker var marker = createMarker(point,label,html,iconimage); clusterer.AddMarker(marker,'City Car Club'); if(openmarker == 'true'){ marker.openInfoWindowHtml(html); } } }); } else { alert("Sorry, your browser does not support google maps :-("); } }