function addMarkers() { mySelect = document.getElementById('selection'); Roanoke = [];Bent_Mountain = [];Salem = [];Vinton = [];mySelect.options[mySelect.options.length] = new Option("Bent Mountain schools",'all=Bent_Mountain'); mySelect.options[mySelect.options.length] = new Option("Roanoke schools",'all=Roanoke'); mySelect.options[mySelect.options.length] = new Option("Salem schools",'all=Salem'); mySelect.options[mySelect.options.length] = new Option("Vinton schools",'all=Vinton'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Roanoke[Roanoke.length] = createMarker(new GPoint(-80.07444000,37.19932938),"
Back Creek Elementary School
7130 Bent Mountain Rd
Roanoke, VA 24018

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Back Creek Elementary School",'Roanoke=' + Roanoke.length); Bent_Mountain[Bent_Mountain.length] = createMarker(new GPoint(-80.12297058,37.15612030),"
Bent Mountain Elementary School
10148 Tinsley Ln
Bent Mountain, VA 24059

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bent Mountain Elementary School",'Bent_Mountain=' + Bent_Mountain.length); Roanoke[Roanoke.length] = createMarker(new GPoint(-79.88031006,37.32904434),"
Bonsack Elementary School
5437 Crumpacker Dr
Roanoke, VA 24019

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bonsack Elementary School",'Roanoke=' + Roanoke.length); Roanoke[Roanoke.length] = createMarker(new GPoint(-79.96179199,37.34452438),"
Burlington Elementary School
6533 Peters Creek Rd
Roanoke, VA 24019

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Burlington Elementary School",'Roanoke=' + Roanoke.length); Roanoke[Roanoke.length] = createMarker(new GPoint(-80.01470184,37.21504211),"
Cave Spring Elementary School
5404 Springlawn Ave
Roanoke, VA 24018

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Cave Spring Elementary School",'Roanoke=' + Roanoke.length); Roanoke[Roanoke.length] = createMarker(new GPoint(-80.00139618,37.21384430),"
Cave Spring High School
3712 Chaparral Dr
Roanoke, VA 24018

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cave Spring High School",'Roanoke=' + Roanoke.length); Roanoke[Roanoke.length] = createMarker(new GPoint(-80.01887512,37.21511841),"
Cave Spring Middle School
4880 Brambleton Ave
Roanoke, VA 24018

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Cave Spring Middle School",'Roanoke=' + Roanoke.length); Roanoke[Roanoke.length] = createMarker(new GPoint(-79.95156097,37.20410538),"
Clearbrook Elementary School
5205 Franklin Rd
Roanoke, VA 24014

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Clearbrook Elementary School",'Roanoke=' + Roanoke.length); Salem[Salem.length] = createMarker(new GPoint(-80.11373138,37.28111267),"
Fort Lewis Elementary School
3115 West Main St
Salem, VA 24153

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Fort Lewis Elementary School",'Salem=' + Salem.length); Roanoke[Roanoke.length] = createMarker(new GPoint(-80.02169037,37.32065582),"
Glen Cove Elementary School
5901 Cove Rd
Roanoke, VA 24019

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Glen Cove Elementary School",'Roanoke=' + Roanoke.length); Salem[Salem.length] = createMarker(new GPoint(-80.13626099,37.27885818),"
Glenvar Elementary School
4507 Malus Dr
Salem, VA 24153

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Glenvar Elementary School",'Salem=' + Salem.length); Salem[Salem.length] = createMarker(new GPoint(-80.13742065,37.27923203),"
Glenvar High School
4549 Malus Dr
Salem, VA 24153

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Glenvar High School",'Salem=' + Salem.length); Salem[Salem.length] = createMarker(new GPoint(-80.13763428,37.27923965),"
Glenvar Middle School
4555 Malus Dr
Salem, VA 24153

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Glenvar Middle School",'Salem=' + Salem.length); Roanoke[Roanoke.length] = createMarker(new GPoint(-79.99119568,37.23212051),"
Green Valley Elementary School
3838 Overdale Rd
Roanoke, VA 24018

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Green Valley Elementary School",'Roanoke=' + Roanoke.length); Vinton[Vinton.length] = createMarker(new GPoint(-79.88333130,37.28260040),"
Herman L. Horn Elementary School
1002 Ruddell Rd
Vinton, VA 24179

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Herman L. Horn Elementary School",'Vinton=' + Vinton.length); Roanoke[Roanoke.length] = createMarker(new GPoint(-80.02008820,37.22347260),"
Hidden Valley High School
5000 Titan Trail
Roanoke, VA 24018

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Hidden Valley High School",'Roanoke=' + Roanoke.length); Salem[Salem.length] = createMarker(new GPoint(-80.05998230,37.36631012),"
Masons Cove Elementary School
3370 Bradshaw Rd
Salem, VA 24153

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Masons Cove Elementary School",'Salem=' + Salem.length); Roanoke[Roanoke.length] = createMarker(new GPoint(-79.93764496,37.33446884),"
Mountain View Elementary School
5901 Plantation Circle
Roanoke, VA 24019

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mountain View Elementary School",'Roanoke=' + Roanoke.length); Roanoke[Roanoke.length] = createMarker(new GPoint(-79.90695953,37.23652267),"
Mt. Pleasant Elementary School
3216 Mt Pleasant Blvd
Roanoke, VA 24014

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mt. Pleasant Elementary School",'Roanoke=' + Roanoke.length); Roanoke[Roanoke.length] = createMarker(new GPoint(-79.99768066,37.32817459),"
Northside High School
6758 Northside High School Rd
Roanoke, VA 24019

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Northside High School",'Roanoke=' + Roanoke.length); Roanoke[Roanoke.length] = createMarker(new GPoint(-79.99868774,37.32901764),"
Northside Middle School
6810 Northside High School Rd
Roanoke, VA 24019

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Northside Middle School",'Roanoke=' + Roanoke.length); Roanoke[Roanoke.length] = createMarker(new GPoint(-80.03285980,37.24679565),"
Oak Grove Elementary School
5005 Grandin Rd Extension
Roanoke, VA 24018

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Oak Grove Elementary School",'Roanoke=' + Roanoke.length); Roanoke[Roanoke.length] = createMarker(new GPoint(-80.00030518,37.20390320),"
Penn Forest Elementary School
6328 Merriman Rd
Roanoke, VA 24018

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Penn Forest Elementary School",'Roanoke=' + Roanoke.length); Vinton[Vinton.length] = createMarker(new GPoint(-79.89569855,37.27802658),"
R.e. Cook Regional Alternative
412 Poplar St.
Vinton, VA 24179

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("R.e. Cook Regional Alternative",'Vinton=' + Vinton.length); Roanoke[Roanoke.length] = createMarker(new GPoint(-79.92559100,37.23774000),"
Reg Alternative Plus Self Project/roanoke City
Co Roanoke City Schools
Roanoke, VA 24031

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Reg Alternative Plus Self Project/roanoke City",'Roanoke=' + Roanoke.length); Vinton[Vinton.length] = createMarker(new GPoint(-79.89942169,37.28217316),"
Roanoke County Career Alt Ed Center
100 Highland Rd.
Vinton, VA 24179

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Roanoke County Career Alt Ed Center",'Vinton=' + Vinton.length); Roanoke[Roanoke.length] = createMarker(new GPoint(-79.97202301,37.22470093),"
Roanoke Valley Regional Board
5937 Cove Rd Nw
Roanoke, VA 24019

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Roanoke Valley Regional Board",'Roanoke=' + Roanoke.length); Vinton[Vinton.length] = createMarker(new GPoint(-79.88002777,37.27343750),"
W. E. Cundiff Elementary School
1200 Hardy Rd
Vinton, VA 24179

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("W. E. Cundiff Elementary School",'Vinton=' + Vinton.length); Vinton[Vinton.length] = createMarker(new GPoint(-79.85778809,37.28282166),"
William Byrd High School
2902 Washington Ave
Vinton, VA 24179

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("William Byrd High School",'Vinton=' + Vinton.length); Vinton[Vinton.length] = createMarker(new GPoint(-79.85757446,37.28292465),"
William Byrd Middle School
2910 Washington Ave
Vinton, VA 24179

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("William Byrd Middle School",'Vinton=' + Vinton.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(Bent_Mountain); map.removeOverlays(Roanoke); map.removeOverlays(Salem); map.removeOverlays(Vinton); 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(Roanoke);map.removeOverlays(Bent_Mountain); map.removeOverlays(Roanoke); map.removeOverlays(Salem); map.removeOverlays(Vinton); map.addOverlays(Bent_Mountain); centerByArray(Bent_Mountain, false, false); cntMarker += Bent_Mountain.length; map.addOverlays(Roanoke); centerByArray(Roanoke, false, false); cntMarker += Roanoke.length; map.addOverlays(Salem); centerByArray(Salem, false, false); cntMarker += Salem.length; map.addOverlays(Vinton); centerByArray(Vinton, false, false); cntMarker += Vinton.length; centerByArray(Roanoke,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'); } }