function addMarkers() { mySelect = document.getElementById('selection'); Cumming = [];Gainesville = [];Alpharetta = [];Suwanee = [];mySelect.options[mySelect.options.length] = new Option("Alpharetta schools",'all=Alpharetta'); mySelect.options[mySelect.options.length] = new Option("Cumming schools",'all=Cumming'); mySelect.options[mySelect.options.length] = new Option("Gainesville schools",'all=Gainesville'); mySelect.options[mySelect.options.length] = new Option("Suwanee schools",'all=Suwanee'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Cumming[Cumming.length] = createMarker(new GPoint(-84.17687988,34.11212540),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Big Creek Elementary School",'Cumming=' + Cumming.length); Cumming[Cumming.length] = createMarker(new GPoint(-84.08737946,34.23660278),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Chattahoochee Elementary School",'Cumming=' + Cumming.length); Gainesville[Gainesville.length] = createMarker(new GPoint(-83.77195740,34.27994156),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Chestatee Elementary School",'Gainesville=' + Gainesville.length); Gainesville[Gainesville.length] = createMarker(new GPoint(-83.99594116,34.29566956),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Chestatee Primary School",'Gainesville=' + Gainesville.length); Cumming[Cumming.length] = createMarker(new GPoint(-84.10476685,34.27484131),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Coal Mountain Elementary School",'Cumming=' + Cumming.length); Cumming[Cumming.length] = createMarker(new GPoint(-84.13381195,34.21982956),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cumming Elementary School",'Cumming=' + Cumming.length); Cumming[Cumming.length] = createMarker(new GPoint(-84.14057159,34.13413620),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Daves Creek Elementary School",'Cumming=' + Cumming.length); Cumming[Cumming.length] = createMarker(new GPoint(-84.13920593,34.21564484),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Forsyth Central High School",'Cumming=' + Cumming.length); Cumming[Cumming.length] = createMarker(new GPoint(-84.18338800,34.14363400),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Forsyth County Academy",'Cumming=' + Cumming.length); Cumming[Cumming.length] = createMarker(new GPoint(-84.20417023,34.29145813),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Liberty Middle School",'Cumming=' + Cumming.length); Cumming[Cumming.length] = createMarker(new GPoint(-84.10665131,34.16875839),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mashburn Elementary School",'Cumming=' + Cumming.length); Cumming[Cumming.length] = createMarker(new GPoint(-84.20376587,34.29139709),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Matt Elementary School",'Cumming=' + Cumming.length); Alpharetta[Alpharetta.length] = createMarker(new GPoint(-84.23438263,34.15901566),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Midway Elementary School",'Alpharetta=' + Alpharetta.length); Cumming[Cumming.length] = createMarker(new GPoint(-84.10582733,34.27669907),"",iconGr); mySelect.options[mySelect.options.length] = new Option("North Forsyth High School",'Cumming=' + Cumming.length); Cumming[Cumming.length] = createMarker(new GPoint(-84.10589600,34.27671814),"",iconBl); mySelect.options[mySelect.options.length] = new Option("North Forsyth Middle School",'Cumming=' + Cumming.length); Cumming[Cumming.length] = createMarker(new GPoint(-84.13868713,34.21781158),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Otwell Middle School",'Cumming=' + Cumming.length); Cumming[Cumming.length] = createMarker(new GPoint(-84.18721771,34.17763901),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Piedmont Learning Center",'Cumming=' + Cumming.length); Suwanee[Suwanee.length] = createMarker(new GPoint(-84.10543000,34.12225400),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Riverwatch Middle School",'Suwanee=' + Suwanee.length); Cumming[Cumming.length] = createMarker(new GPoint(-84.17731476,34.24016571),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sawnee Elementary School",'Cumming=' + Cumming.length); Cumming[Cumming.length] = createMarker(new GPoint(-84.17356873,34.24186325),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sawnee Primary School",'Cumming=' + Cumming.length); Suwanee[Suwanee.length] = createMarker(new GPoint(-84.10232544,34.12625122),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Settles Bridge Elementary School",'Suwanee=' + Suwanee.length); Suwanee[Suwanee.length] = createMarker(new GPoint(-84.08232117,34.08837891),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sharon Elementary School",'Suwanee=' + Suwanee.length); Cumming[Cumming.length] = createMarker(new GPoint(-84.17311096,34.14800644),"",iconGr); mySelect.options[mySelect.options.length] = new Option("South Forsyth High School",'Cumming=' + Cumming.length); Cumming[Cumming.length] = createMarker(new GPoint(-84.15493011,34.11682510),"",iconBl); mySelect.options[mySelect.options.length] = new Option("South Forsyth Middle School",'Cumming=' + Cumming.length); Cumming[Cumming.length] = createMarker(new GPoint(-84.22265625,34.17711639),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Vickery Creek Elementary School",'Cumming=' + Cumming.length); Cumming[Cumming.length] = createMarker(new GPoint(-84.22196960,34.17787933),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Vickery Creek Middle School",'Cumming=' + Cumming.length); } // End addStateMarkers JavaScript Function // Takes an array of markers and centers/zooms map based on marker range function centerByArray(myArray, recenter, newMaxMin) { if (newMaxMin == true) reMaxMin(myArray); for (var i = 0; i < myArray.length; i++) { var markLng = myArray[i].getPoint().x; var markLat = myArray[i].getPoint().y; if (markLat > maxLat) maxLat = markLat; if (markLng > maxLng) maxLng = markLng; if (markLat < minLat) minLat = markLat; if (markLng < minLng) minLng = markLng; } if (recenter) reCenterMap(); } // Reinit max/mins function reMaxMin(myArray) { maxLng = myArray[0].getPoint().x; maxLat = myArray[0].getPoint().y; minLng = myArray[0].getPoint().x; minLat = myArray[0].getPoint().y; } // Recenter map based on global max/mins function reCenterMap() { var bounds = new GLatLngBounds(); bounds.extend(new GLatLng(minLat, minLng)); bounds.extend(new GLatLng(maxLat, maxLng)); var center_lat = (bounds.getNorthEast().lat() + bounds.getSouthWest().lat()) / 2.0; var center_lng = (bounds.getNorthEast().lng() + bounds.getSouthWest().lng()) / 2.0; var center = new GLatLng(center_lat, center_lng); var zoom = map.getBoundsZoomLevel(bounds); map.setCenter(center,zoom); //map.setCenter(center,10); /* var center = new GPoint( (maxLng + minLng)/2, (maxLat+minLat)/2 ); var delta = new GSize(maxLng - minLng, maxLat - minLat); var minZoom = map.spec.getLowestZoomLevel(center, delta, map.viewSize); if (minZoom < 4) minZoom = 4; // Lowest possible zoom is 4 map.centerAndZoom(center, minZoom); */ } // Fires when drop down list of schools changes function selectChange(selection) { var myVal = selection.options[selection.selectedIndex].value; map.closeInfoWindow(); // Add entire array based on variable type if (myVal.indexOf('all') != -1 && myVal != 'all') { var temp = myVal.split('='); var showArray = temp[1]; // If Array is > X amount of markers, then open in a new page if (eval(showArray).length > 20) // New window depends on whether or not we're on the search page if (location.href.indexOf('nearby_schools.php') == -1) window.open(location.href + '/map/' + showArray); else window.open('/search////' + showArray); map.removeOverlays(Alpharetta); map.removeOverlays(Cumming); map.removeOverlays(Gainesville); map.removeOverlays(Suwanee); map.addOverlays(eval(showArray)); centerByArray(eval(showArray), true, true); // Center and zoom on set of markers } // Add individual markers if (myVal.indexOf('all') == -1 && myVal != 'all' && myVal.length) { var temp = myVal.split('='); var myArray = temp[0]; var myIndex = parseInt(temp[1]) - 1; document.getElementById('map').width = "750"; map.removeOverlay(eval(myArray)[myIndex]); map.addOverlay(eval(myArray)[myIndex]); GEvent.trigger(eval(myArray)[myIndex],'click'); } // Show all markers if (myVal == 'all') { cntMarker = 0; reMaxMin(Cumming);map.removeOverlays(Alpharetta); map.removeOverlays(Cumming); map.removeOverlays(Gainesville); map.removeOverlays(Suwanee); map.addOverlays(Alpharetta); centerByArray(Alpharetta, false, false); cntMarker += Alpharetta.length; map.addOverlays(Cumming); centerByArray(Cumming, false, false); cntMarker += Cumming.length; map.addOverlays(Gainesville); centerByArray(Gainesville, false, false); cntMarker += Gainesville.length; map.addOverlays(Suwanee); centerByArray(Suwanee, false, false); cntMarker += Suwanee.length; centerByArray(Cumming,true, false); if (cntMarker > 20) // New window depends on whether or not we're on the search page if (location.href.indexOf('schools-by-distance') == -1) window.open(location.href + '/map/all'); else window.open('/search////all'); } }