function addMarkers() { mySelect = document.getElementById('selection'); Rocky_Mount = [];Boones_Mill = [];Wirtz = [];Callaway = [];Ferrum = [];Glade_Hill = [];Henry = [];Penhook = [];mySelect.options[mySelect.options.length] = new Option("Boones Mill schools",'all=Boones_Mill'); mySelect.options[mySelect.options.length] = new Option("Callaway schools",'all=Callaway'); mySelect.options[mySelect.options.length] = new Option("Ferrum schools",'all=Ferrum'); mySelect.options[mySelect.options.length] = new Option("Glade Hill schools",'all=Glade_Hill'); mySelect.options[mySelect.options.length] = new Option("Henry schools",'all=Henry'); mySelect.options[mySelect.options.length] = new Option("Penhook schools",'all=Penhook'); mySelect.options[mySelect.options.length] = new Option("Rocky Mount schools",'all=Rocky_Mount'); mySelect.options[mySelect.options.length] = new Option("Wirtz schools",'all=Wirtz'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Rocky_Mount[Rocky_Mount.length] = createMarker(new GPoint(-79.88578033,37.01557159),"
Ben. Franklin Middle-east Middle School
375 Middle School Rd
Rocky Mount, VA 24151

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Ben. Franklin Middle-east Middle School",'Rocky_Mount=' + Rocky_Mount.length); Rocky_Mount[Rocky_Mount.length] = createMarker(new GPoint(-79.88729858,37.01494598),"
Ben. Franklin Middle-west Middle School
225 Middle School Road
Rocky Mount, VA 24151

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Ben. Franklin Middle-west Middle School",'Rocky_Mount=' + Rocky_Mount.length); Boones_Mill[Boones_Mill.length] = createMarker(new GPoint(-79.92998505,37.08951950),"
Boones Mill Elementary School
265 Taylors Rd
Boones Mill, VA 24065

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Boones Mill Elementary School",'Boones_Mill=' + Boones_Mill.length); Wirtz[Wirtz.length] = createMarker(new GPoint(-79.81678772,37.10277176),"
Burnt Chimney Elementary School
80 Burnt Chimney Road
Wirtz, VA 24184

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Burnt Chimney Elementary School",'Wirtz=' + Wirtz.length); Callaway[Callaway.length] = createMarker(new GPoint(-80.04489136,37.01296234),"
Callaway Elementary School
8451 Callaway Rd
Callaway, VA 24067

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Callaway Elementary School",'Callaway=' + Callaway.length); Rocky_Mount[Rocky_Mount.length] = createMarker(new GPoint(-79.89260864,37.01533890),"
Center For Apl Tech&career Expl
150 Technology Dr
Rocky Mount, VA 24151

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Center For Apl Tech&career Expl",'Rocky_Mount=' + Rocky_Mount.length); Wirtz[Wirtz.length] = createMarker(new GPoint(-79.75093079,37.08029556),"
Dudley Elementary School
7250 Brooks Mill Rd
Wirtz, VA 24184

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Dudley Elementary School",'Wirtz=' + Wirtz.length); Ferrum[Ferrum.length] = createMarker(new GPoint(-80.03060150,36.92200089),"
Ferrum Elementary School
660 Ferrum School Rd
Ferrum, VA 24088

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Ferrum Elementary School",'Ferrum=' + Ferrum.length); Rocky_Mount[Rocky_Mount.length] = createMarker(new GPoint(-79.87940979,37.00486755),"
Franklin County High School
700 Tanyard Rd
Rocky Mount, VA 24151

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Franklin County High School",'Rocky_Mount=' + Rocky_Mount.length); Glade_Hill[Glade_Hill.length] = createMarker(new GPoint(-79.74695587,36.98669434),"
Glade Hill Elementary School
8081 Old Franklin Trnpk
Glade Hill, VA 24092

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Glade Hill Elementary School",'Glade_Hill=' + Glade_Hill.length); Henry[Henry.length] = createMarker(new GPoint(-79.92607880,36.84827042),"
Henry Elementary School
200 Henry School Rd
Henry, VA 24102

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Henry Elementary School",'Henry=' + Henry.length); Rocky_Mount[Rocky_Mount.length] = createMarker(new GPoint(-79.87877655,36.99615860),"
Lee M. Waid Elementary School
540 E Court St
Rocky Mount, VA 24151

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lee M. Waid Elementary School",'Rocky_Mount=' + Rocky_Mount.length); Rocky_Mount[Rocky_Mount.length] = createMarker(new GPoint(-79.88729858,37.01494598),"
New Opportunities For Winning School
225 Middle School Road
Rocky Mount, VA 24151

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("New Opportunities For Winning School",'Rocky_Mount=' + Rocky_Mount.length); Rocky_Mount[Rocky_Mount.length] = createMarker(new GPoint(-79.86437988,37.01911545),"
Rocky Mount Elementary School
555 School Board Rd
Rocky Mount, VA 24151

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Rocky Mount Elementary School",'Rocky_Mount=' + Rocky_Mount.length); Penhook[Penhook.length] = createMarker(new GPoint(-79.75354004,36.83343887),"
Snow Creek Elementary School
5393 Snow Creek Rd
Penhook, VA 24137

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Snow Creek Elementary School",'Penhook=' + Penhook.length); Rocky_Mount[Rocky_Mount.length] = createMarker(new GPoint(-79.83976746,36.92551422),"
Sontag Elementary School
3101 Sontag Rd
Rocky Mount, VA 24151

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Sontag Elementary School",'Rocky_Mount=' + Rocky_Mount.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(Boones_Mill); map.removeOverlays(Callaway); map.removeOverlays(Ferrum); map.removeOverlays(Glade_Hill); map.removeOverlays(Henry); map.removeOverlays(Penhook); map.removeOverlays(Rocky_Mount); map.removeOverlays(Wirtz); 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(Rocky_Mount);map.removeOverlays(Boones_Mill); map.removeOverlays(Callaway); map.removeOverlays(Ferrum); map.removeOverlays(Glade_Hill); map.removeOverlays(Henry); map.removeOverlays(Penhook); map.removeOverlays(Rocky_Mount); map.removeOverlays(Wirtz); map.addOverlays(Boones_Mill); centerByArray(Boones_Mill, false, false); cntMarker += Boones_Mill.length; map.addOverlays(Callaway); centerByArray(Callaway, false, false); cntMarker += Callaway.length; map.addOverlays(Ferrum); centerByArray(Ferrum, false, false); cntMarker += Ferrum.length; map.addOverlays(Glade_Hill); centerByArray(Glade_Hill, false, false); cntMarker += Glade_Hill.length; map.addOverlays(Henry); centerByArray(Henry, false, false); cntMarker += Henry.length; map.addOverlays(Penhook); centerByArray(Penhook, false, false); cntMarker += Penhook.length; map.addOverlays(Rocky_Mount); centerByArray(Rocky_Mount, false, false); cntMarker += Rocky_Mount.length; map.addOverlays(Wirtz); centerByArray(Wirtz, false, false); cntMarker += Wirtz.length; centerByArray(Rocky_Mount,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'); } }