// arrays to hold copies of the markers and html used by the sidebar // because the function closure trick doesnt work there var gmarkers = []; var htmls = []; // This function picks up the click and opens the corresponding info window function myclick(i) { gmarkers[i].openInfoWindowHtml(htmls[i]); } function MakeMap() { // Globals. // Icon(s), and if gender is enabled, php will allow those to be defined. function cancelscroll() { window.event.returnValue = false; window.event.cancelBubble = true; } // Our standard pin var icon = new GIcon() icon.image = "http://chart.apis.google.com/chart?chst=d_map_pin_letter_withshadow&chld=|66FF66|202020"; icon.iconSize = new GSize(27,25); icon.iconAnchor = new GPoint(9,25); icon.infoWindowAnchor = new GPoint(9,6.25); // For that clustering thing! var clusterIcon = new GIcon(); clusterIcon.image = "http://chart.apis.google.com/chart?chst=d_map_pin_icon_withshadow&chld=info|FF66FF|202020"; clusterIcon.iconSize = new GSize(27,25); clusterIcon.iconAnchor = new GPoint(9,25); clusterIcon.infoWindowAnchor = new GPoint(9,6.25); if (GBrowserIsCompatible()) { // this variable will collect the html which will eventually be placed in the sidebar var sidebar_html = ""; var i = 0; // A function to create the marker and set up the event window function createMarker(point, icon, name, html) { var marker = new GMarker(point, icon); GEvent.addListener(marker, "click", function() { map.getCenter(point); map.panTo(point); marker.openInfoWindowHtml(html); }); // save the info we need to use later for the sidebar gmarkers[i] = marker; htmls[i] = html; name = name.replace(/\[b\](.*)\[\/b\]/gi, "$1"); // add a line to the sidebar html sidebar_html += '' + name + ', '; //Now that we cached it lets return the marker.... i++; return marker; } // create the map var map = new GMap2(document.getElementById("map")); map.addControl(new GLargeMapControl3D()); map.addControl(new GMapTypeControl()); map.disableScrollWheelZoom(); map.enableContinuousZoom(); // Lets load up the default long/lat/zoom for the map. map.setCenter(new GLatLng(39, -95), 4,G_HYBRID_MAP); // This is so we can try to cluster some of those pins together so the map does not get over loaded. var clusterer = new Clusterer(map); clusterer.icon = clusterIcon; clusterer.minMarkersPerClusterer = 5; clusterer.maxVisibleMarkers = 90; clusterer.GridSize = 10; clusterer.MaxLinesPerInfoBox = 10; // Read the data var request = GXmlHttp.create(); request.open("GET", "http://www.deerhuntingtoday.com/index.php?PHPSESSID=koplaklpdhmpok8onkcbmevjp2&action=googlemap;sa=.xml", true); request.onreadystatechange = function() { if (request.readyState == 4) { var xmlDoc = request.responseXML; // obtain the array of markers and loop through it var markers = xmlDoc.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { // obtain the attribues of each marker var lat = parseFloat(markers[i].getAttribute("lat")); var lng = parseFloat(markers[i].getAttribute("lng")); var point = new GLatLng(lat,lng); var html = markers[i].childNodes[0].nodeValue; var label = markers[i].getAttribute("label"); // create the marker var marker = createMarker(point, icon, label, html); clusterer.AddMarker(marker, label); } // put the assembled sidebar_html contents into the sidebar div document.getElementById("gooSidebar").innerHTML = sidebar_html; } } request.send(null); } else { alert("Sorry, the Google Maps API is not compatible with this browser"); } } setTimeout('MakeMap()', 500);