function addMarkers() { mySelect = document.getElementById('selection'); Mechanicsville = [];Hanover = [];Beaverdam = [];Ashland = [];Montpelier = [];mySelect.options[mySelect.options.length] = new Option("Ashland schools",'all=Ashland'); mySelect.options[mySelect.options.length] = new Option("Beaverdam schools",'all=Beaverdam'); mySelect.options[mySelect.options.length] = new Option("Hanover schools",'all=Hanover'); mySelect.options[mySelect.options.length] = new Option("Mechanicsville schools",'all=Mechanicsville'); mySelect.options[mySelect.options.length] = new Option("Montpelier schools",'all=Montpelier'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Mechanicsville[Mechanicsville.length] = createMarker(new GPoint(-77.41150665,37.66376495),"
Atlee High School
9414 Atlee Station Road
Mechanicsville, VA 23116

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Atlee High School",'Mechanicsville=' + Mechanicsville.length); Hanover[Hanover.length] = createMarker(new GPoint(-77.32890320,37.76499939),"
Barrett Juvenile Correctional Center
Po Box 527
Hanover, VA 23069

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Barrett Juvenile Correctional Center",'Hanover=' + Hanover.length); Mechanicsville[Mechanicsville.length] = createMarker(new GPoint(-77.29732513,37.62723541),"
Battlefield Park Elementary School
5501 Mechanicsville Turnpike
Mechanicsville, VA 23111

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Battlefield Park Elementary School",'Mechanicsville=' + Mechanicsville.length); Beaverdam[Beaverdam.length] = createMarker(new GPoint(-77.64179993,37.93383408),"
Beaverdam Elementary School
15485 Beaverdam School Road
Beaverdam, VA 23015

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Beaverdam Elementary School",'Beaverdam=' + Beaverdam.length); Mechanicsville[Mechanicsville.length] = createMarker(new GPoint(-77.41268158,37.66550827),"
Chickahominy Middle School
9450 Atlee Station Road
Mechanicsville, VA 23116

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Chickahominy Middle School",'Mechanicsville=' + Mechanicsville.length); Mechanicsville[Mechanicsville.length] = createMarker(new GPoint(-77.32037354,37.59214783),"
Cold Harbor Elementary School
6740 Cold Harbor Road
Mechanicsville, VA 23111

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Cold Harbor Elementary School",'Mechanicsville=' + Mechanicsville.length); Mechanicsville[Mechanicsville.length] = createMarker(new GPoint(-77.41000366,37.67046356),"
Cool Spring Elementary School
9964 Honey Meadows Rd
Mechanicsville, VA 23116

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Cool Spring Elementary School",'Mechanicsville=' + Mechanicsville.length); Ashland[Ashland.length] = createMarker(new GPoint(-77.51103973,37.71464157),"
Elmont Elementary School
12007 Cedar Lane
Ashland, VA 23005

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Elmont Elementary School",'Ashland=' + Ashland.length); Mechanicsville[Mechanicsville.length] = createMarker(new GPoint(-77.38227081,37.68791580),"
Hanover High School
10307 Chamberlayne Rd.
Mechanicsville, VA 23116

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Hanover High School",'Mechanicsville=' + Mechanicsville.length); Ashland[Ashland.length] = createMarker(new GPoint(-77.48619080,37.75643539),"
Henry Clay Elementary School
310 S James St
Ashland, VA 23005

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Henry Clay Elementary School",'Ashland=' + Ashland.length); Hanover[Hanover.length] = createMarker(new GPoint(-77.32890320,37.76499939),"
John H Smyth Sch @ Hanover Juv
Po Box 507
Hanover, VA 23069

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("John H Smyth Sch @ Hanover Juv",'Hanover=' + Hanover.length); Ashland[Ashland.length] = createMarker(new GPoint(-77.46926880,37.77080536),"
John M. Gandy Elementary School
201 Archie Cannon Drive
Ashland, VA 23005

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("John M. Gandy Elementary School",'Ashland=' + Ashland.length); Mechanicsville[Mechanicsville.length] = createMarker(new GPoint(-77.33950806,37.61220169),"
Lee Davis High School
7052 Mechanicsville Pike
Mechanicsville, VA 23111

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Lee Davis High School",'Mechanicsville=' + Mechanicsville.length); Ashland[Ashland.length] = createMarker(new GPoint(-77.53034210,37.78487015),"
Liberty Middle School
13496 Liberty School Road
Ashland, VA 23005

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Liberty Middle School",'Ashland=' + Ashland.length); Mechanicsville[Mechanicsville.length] = createMarker(new GPoint(-77.37834167,37.61162186),"
Mechanicsville Elementary School
7425 Mechanicsville Elem Drive
Mechanicsville, VA 23111

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mechanicsville Elementary School",'Mechanicsville=' + Mechanicsville.length); Mechanicsville[Mechanicsville.length] = createMarker(new GPoint(-77.38210297,37.68716812),"
Oak Knoll Middle School
10295 Chamberlayne Rd.
Mechanicsville, VA 23116

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Oak Knoll Middle School",'Mechanicsville=' + Mechanicsville.length); Ashland[Ashland.length] = createMarker(new GPoint(-77.53266144,37.78646851),"
Patrick Henry High School
12449 West Patrick Henry Road
Ashland, VA 23005

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Patrick Henry High School",'Ashland=' + Ashland.length); Mechanicsville[Mechanicsville.length] = createMarker(new GPoint(-77.39023590,37.67729187),"
Pearson's Corner Elementary School
08290 New Ashcake Road
Mechanicsville, VA 23116

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Pearson's Corner Elementary School",'Mechanicsville=' + Mechanicsville.length); Mechanicsville[Mechanicsville.length] = createMarker(new GPoint(-77.30751801,37.63866043),"
Pole Green Elementary School
8393 Pole Green Park Ln
Mechanicsville, VA 23116

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Pole Green Elementary School",'Mechanicsville=' + Mechanicsville.length); Mechanicsville[Mechanicsville.length] = createMarker(new GPoint(-77.34055328,37.66519547),"
Rural Point Elementary School
7161 Studley Road
Mechanicsville, VA 23116

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Rural Point Elementary School",'Mechanicsville=' + Mechanicsville.length); Montpelier[Montpelier.length] = createMarker(new GPoint(-77.66117096,37.76200867),"
South Anna Elementary School
13122 Waltons Tavern Road
Montpelier, VA 23192

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("South Anna Elementary School",'Montpelier=' + Montpelier.length); Mechanicsville[Mechanicsville.length] = createMarker(new GPoint(-77.34004211,37.61787415),"
Stonewall Jackson Middle School
8021 Lee Davis Road
Mechanicsville, VA 23111

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Stonewall Jackson Middle School",'Mechanicsville=' + Mechanicsville.length); Mechanicsville[Mechanicsville.length] = createMarker(new GPoint(-77.38471985,37.64530182),"
Washington Henry Elementary School
9025 Washington Henry Drive
Mechanicsville, VA 23116

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Washington Henry Elementary School",'Mechanicsville=' + Mechanicsville.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(Ashland); map.removeOverlays(Beaverdam); map.removeOverlays(Hanover); map.removeOverlays(Mechanicsville); map.removeOverlays(Montpelier); 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(Mechanicsville);map.removeOverlays(Ashland); map.removeOverlays(Beaverdam); map.removeOverlays(Hanover); map.removeOverlays(Mechanicsville); map.removeOverlays(Montpelier); map.addOverlays(Ashland); centerByArray(Ashland, false, false); cntMarker += Ashland.length; map.addOverlays(Beaverdam); centerByArray(Beaverdam, false, false); cntMarker += Beaverdam.length; map.addOverlays(Hanover); centerByArray(Hanover, false, false); cntMarker += Hanover.length; map.addOverlays(Mechanicsville); centerByArray(Mechanicsville, false, false); cntMarker += Mechanicsville.length; map.addOverlays(Montpelier); centerByArray(Montpelier, false, false); cntMarker += Montpelier.length; centerByArray(Mechanicsville,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'); } }