function addMarkers() { mySelect = document.getElementById('selection'); Altavista = [];Brookneal = [];Lynchburg = [];Rustburg = [];Concord = [];Gladys = [];Naruna = [];mySelect.options[mySelect.options.length] = new Option("Altavista schools",'all=Altavista'); mySelect.options[mySelect.options.length] = new Option("Brookneal schools",'all=Brookneal'); mySelect.options[mySelect.options.length] = new Option("Concord schools",'all=Concord'); mySelect.options[mySelect.options.length] = new Option("Gladys schools",'all=Gladys'); mySelect.options[mySelect.options.length] = new Option("Lynchburg schools",'all=Lynchburg'); mySelect.options[mySelect.options.length] = new Option("Naruna schools",'all=Naruna'); mySelect.options[mySelect.options.length] = new Option("Rustburg schools",'all=Rustburg'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Altavista[Altavista.length] = createMarker(new GPoint(-79.29606628,37.14453888),"
Altavista Elementary School
1003 Lynch Mill Rd
Altavista, VA 24517

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Altavista Elementary School",'Altavista=' + Altavista.length); Altavista[Altavista.length] = createMarker(new GPoint(-79.29427338,37.10978317),"
Altavista High School
904 Bedford Avenue
Altavista, VA 24517

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Altavista High School",'Altavista=' + Altavista.length); Brookneal[Brookneal.length] = createMarker(new GPoint(-78.91929626,37.06890106),"
Brookneal Elementary School
Po Box 36
Brookneal, VA 24528

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Brookneal Elementary School",'Brookneal=' + Brookneal.length); Lynchburg[Lynchburg.length] = createMarker(new GPoint(-79.23535156,37.34643173),"
Brookville High School
100 Laxton Rd
Lynchburg, VA 24502

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Brookville High School",'Lynchburg=' + Lynchburg.length); Lynchburg[Lynchburg.length] = createMarker(new GPoint(-79.23886871,37.34499359),"
Brookville Middle School
320 Bee Dr
Lynchburg, VA 24502

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Brookville Middle School",'Lynchburg=' + Lynchburg.length); Rustburg[Rustburg.length] = createMarker(new GPoint(-79.18259430,37.25219345),"
Campbell County Technical Center
194 Dennis Riddle Rd
Rustburg, VA 24588

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Campbell County Technical Center",'Rustburg=' + Rustburg.length); Concord[Concord.length] = createMarker(new GPoint(-78.98380280,37.33580017),"
Concord Elementary School
Po Box 95
Concord, VA 24538

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Concord Elementary School",'Concord=' + Concord.length); Rustburg[Rustburg.length] = createMarker(new GPoint(-79.08712769,37.27687073),"
Fray Educational Ctr.
1551 Village Highway
Rustburg, VA 24588

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Fray Educational Ctr.",'Rustburg=' + Rustburg.length); Gladys[Gladys.length] = createMarker(new GPoint(-79.06259918,37.13880157),"
Gladys Elementary School
P O Box 37
Gladys, VA 24554

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Gladys Elementary School",'Gladys=' + Gladys.length); Lynchburg[Lynchburg.length] = createMarker(new GPoint(-79.21940613,37.32808685),"
Leesville Road Elementary School
19965 Leesville Road
Lynchburg, VA 24502

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Leesville Road Elementary School",'Lynchburg=' + Lynchburg.length); Rustburg[Rustburg.length] = createMarker(new GPoint(-79.12169647,37.27679825),"
Rustburg Elementary School
Po Box 225
Rustburg, VA 24588

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Rustburg Elementary School",'Rustburg=' + Rustburg.length); Rustburg[Rustburg.length] = createMarker(new GPoint(-79.12169647,37.27679825),"
Rustburg High School
Po Box 830
Rustburg, VA 24588

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Rustburg High School",'Rustburg=' + Rustburg.length); Rustburg[Rustburg.length] = createMarker(new GPoint(-79.12169647,37.27679825),"
Rustburg Middle School
Po Box 130
Rustburg, VA 24588

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Rustburg Middle School",'Rustburg=' + Rustburg.length); Lynchburg[Lynchburg.length] = createMarker(new GPoint(-79.23824310,37.34310913),"
Tomahawk Elementary School
155 Bee Drive
Lynchburg, VA 24502

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Tomahawk Elementary School",'Lynchburg=' + Lynchburg.length); Naruna[Naruna.length] = createMarker(new GPoint(-79.00270081,37.10580063),"
William Campbell High School
Po Box 7
Naruna, VA 24576

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("William Campbell High School",'Naruna=' + Naruna.length); Rustburg[Rustburg.length] = createMarker(new GPoint(-79.18498993,37.25137329),"
Yellow Branch Elementary School
377 Dennis Riddle Dr
Rustburg, VA 24588

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Yellow Branch Elementary School",'Rustburg=' + Rustburg.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(Altavista); map.removeOverlays(Brookneal); map.removeOverlays(Concord); map.removeOverlays(Gladys); map.removeOverlays(Lynchburg); map.removeOverlays(Naruna); map.removeOverlays(Rustburg); 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(Altavista);map.removeOverlays(Altavista); map.removeOverlays(Brookneal); map.removeOverlays(Concord); map.removeOverlays(Gladys); map.removeOverlays(Lynchburg); map.removeOverlays(Naruna); map.removeOverlays(Rustburg); map.addOverlays(Altavista); centerByArray(Altavista, false, false); cntMarker += Altavista.length; map.addOverlays(Brookneal); centerByArray(Brookneal, false, false); cntMarker += Brookneal.length; map.addOverlays(Concord); centerByArray(Concord, false, false); cntMarker += Concord.length; map.addOverlays(Gladys); centerByArray(Gladys, false, false); cntMarker += Gladys.length; map.addOverlays(Lynchburg); centerByArray(Lynchburg, false, false); cntMarker += Lynchburg.length; map.addOverlays(Naruna); centerByArray(Naruna, false, false); cntMarker += Naruna.length; map.addOverlays(Rustburg); centerByArray(Rustburg, false, false); cntMarker += Rustburg.length; centerByArray(Altavista,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'); } }