function addMarkers() { mySelect = document.getElementById('selection'); Madison_Heights = [];Amherst = [];Lynchburg = [];Monroe = [];mySelect.options[mySelect.options.length] = new Option("Amherst schools",'all=Amherst'); mySelect.options[mySelect.options.length] = new Option("Lynchburg schools",'all=Lynchburg'); mySelect.options[mySelect.options.length] = new Option("Madison Heights schools",'all=Madison_Heights'); mySelect.options[mySelect.options.length] = new Option("Monroe schools",'all=Monroe'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Madison_Heights[Madison_Heights.length] = createMarker(new GPoint(-79.11905670,37.46972275),"
Amelon Elementary School
132 Amer Court
Madison Heights, VA 24572

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Amelon Elementary School",'Madison_Heights=' + Madison_Heights.length); Amherst[Amherst.length] = createMarker(new GPoint(-79.05922699,37.56898499),"
Amherst County High School
139 Lancer Lane
Amherst, VA 24521

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Amherst County High School",'Amherst=' + Amherst.length); Amherst[Amherst.length] = createMarker(new GPoint(-79.04531860,37.58827972),"
Amherst Elementary School
156 Davis St
Amherst, VA 24521

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Amherst Elementary School",'Amherst=' + Amherst.length); Amherst[Amherst.length] = createMarker(new GPoint(-79.03751373,37.57046509),"
Amherst Middle School
165 Gordons Fairground Rd
Amherst, VA 24521

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Amherst Middle School",'Amherst=' + Amherst.length); Amherst[Amherst.length] = createMarker(new GPoint(-79.04046631,37.56925201),"
Central Elementary School
575 Union Hill Rd
Amherst, VA 24521

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Amherst=' + Amherst.length); Lynchburg[Lynchburg.length] = createMarker(new GPoint(-79.15471900,37.40420300),"
Central Va. Training Ctr.
Po Box 1098
Lynchburg, VA 24505

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Central Va. Training Ctr.",'Lynchburg=' + Lynchburg.length); Madison_Heights[Madison_Heights.length] = createMarker(new GPoint(-79.19432068,37.51460648),"
Elon Elementary School
147 Younger Dr
Madison Heights, VA 24572

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Elon Elementary School",'Madison_Heights=' + Madison_Heights.length); Madison_Heights[Madison_Heights.length] = createMarker(new GPoint(-79.13277435,37.43338394),"
Madison Heights Elementary School
287 Learning Ln
Madison Heights, VA 24572

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Madison Heights Elementary School",'Madison_Heights=' + Madison_Heights.length); Madison_Heights[Madison_Heights.length] = createMarker(new GPoint(-79.11450958,37.45708847),"
Monelison Middle School
257 Trojan Rd
Madison Heights, VA 24572

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Monelison Middle School",'Madison_Heights=' + Madison_Heights.length); Monroe[Monroe.length] = createMarker(new GPoint(-79.28379822,37.59343338),"
Pleasant View Elementary School
229 Dancing Creek Rd
Monroe, VA 24574

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Pleasant View Elementary School",'Monroe=' + Monroe.length); Amherst[Amherst.length] = createMarker(new GPoint(-79.08126831,37.69178009),"
Temperance Elementary School
1981 Lowesville Rd
Amherst, VA 24521

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Temperance Elementary School",'Amherst=' + Amherst.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(Amherst); map.removeOverlays(Lynchburg); map.removeOverlays(Madison_Heights); map.removeOverlays(Monroe); 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(Madison_Heights);map.removeOverlays(Amherst); map.removeOverlays(Lynchburg); map.removeOverlays(Madison_Heights); map.removeOverlays(Monroe); map.addOverlays(Amherst); centerByArray(Amherst, false, false); cntMarker += Amherst.length; map.addOverlays(Lynchburg); centerByArray(Lynchburg, false, false); cntMarker += Lynchburg.length; map.addOverlays(Madison_Heights); centerByArray(Madison_Heights, false, false); cntMarker += Madison_Heights.length; map.addOverlays(Monroe); centerByArray(Monroe, false, false); cntMarker += Monroe.length; centerByArray(Madison_Heights,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'); } }