function addMarkers() { mySelect = document.getElementById('selection'); Dryden = [];Pennington_Gap = [];Ewing = [];Jonesville = [];Keokee = [];Ben_Hur = [];Rose_Hill = [];Saint_Charles = [];Duffield = [];mySelect.options[mySelect.options.length] = new Option("Ben Hur schools",'all=Ben_Hur'); mySelect.options[mySelect.options.length] = new Option("Dryden schools",'all=Dryden'); mySelect.options[mySelect.options.length] = new Option("Duffield schools",'all=Duffield'); mySelect.options[mySelect.options.length] = new Option("Ewing schools",'all=Ewing'); mySelect.options[mySelect.options.length] = new Option("Jonesville schools",'all=Jonesville'); mySelect.options[mySelect.options.length] = new Option("Keokee schools",'all=Keokee'); mySelect.options[mySelect.options.length] = new Option("Pennington Gap schools",'all=Pennington_Gap'); mySelect.options[mySelect.options.length] = new Option("Rose Hill schools",'all=Rose_Hill'); mySelect.options[mySelect.options.length] = new Option("Saint Charles schools",'all=Saint_Charles'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Dryden[Dryden.length] = createMarker(new GPoint(-82.94080353,36.77489853),"
Dryden Primary
Route 1 Box 1825
Dryden, VA 24243

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Dryden Primary",'Dryden=' + Dryden.length); Pennington_Gap[Pennington_Gap.length] = createMarker(new GPoint(-83.03369904,36.75099945),"
Elk Knob Elementary School
Rt 2 Box 193
Pennington Gap, VA 24277

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Elk Knob Elementary School",'Pennington_Gap=' + Pennington_Gap.length); Ewing[Ewing.length] = createMarker(new GPoint(-83.51509857,36.62279892),"
Elydale Elementary School
Rt 2 Box 557
Ewing, VA 24248

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Elydale Elementary School",'Ewing=' + Ewing.length); Ewing[Ewing.length] = createMarker(new GPoint(-83.51509857,36.62279892),"
Ewing Elementary School
Po Box 279
Ewing, VA 24248

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Ewing Elementary School",'Ewing=' + Ewing.length); Jonesville[Jonesville.length] = createMarker(new GPoint(-83.12370300,36.68450165),"
Flatwoods Primary
Rt 1 Box 552
Jonesville, VA 24263

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Flatwoods Primary",'Jonesville=' + Jonesville.length); Jonesville[Jonesville.length] = createMarker(new GPoint(-83.12370300,36.68450165),"
Jonesville Middle School
Rt 1 Box 104h
Jonesville, VA 24263

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Jonesville Middle School",'Jonesville=' + Jonesville.length); Keokee[Keokee.length] = createMarker(new GPoint(-82.94580078,36.83710098),"
Keokee Elementary School
Po Box 93
Keokee, VA 24265

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Keokee Elementary School",'Keokee=' + Keokee.length); Ben_Hur[Ben_Hur.length] = createMarker(new GPoint(-83.08239746,36.73429871),"
Lee County Career & Tech. Center
Po Box 100
Ben Hur, VA 24218

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Lee County Career & Tech. Center",'Ben_Hur=' + Ben_Hur.length); Jonesville[Jonesville.length] = createMarker(new GPoint(-83.12370300,36.68450165),"
Lee High School
Rt 2 Box 3145
Jonesville, VA 24263

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Lee High School",'Jonesville=' + Jonesville.length); Pennington_Gap[Pennington_Gap.length] = createMarker(new GPoint(-83.01612091,36.76203918),"
Pennington Middle School
201 Middle School Dr
Pennington Gap, VA 24277

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Pennington Middle School",'Pennington_Gap=' + Pennington_Gap.length); Rose_Hill[Rose_Hill.length] = createMarker(new GPoint(-83.36029816,36.65919876),"
Rose Hill Elementary School
Rr 1 Box 136
Rose Hill, VA 24281

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Rose Hill Elementary School",'Rose_Hill=' + Rose_Hill.length); Saint_Charles[Saint_Charles.length] = createMarker(new GPoint(-83.05757141,36.80179977),"
Saint Charles Elementary School
1 Main Street
Saint Charles, VA 24282

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Saint Charles Elementary School",'Saint_Charles=' + Saint_Charles.length); Duffield[Duffield.length] = createMarker(new GPoint(-82.81369781,36.71730042),"
Stickleyville Elementary School
Rt 1 Box 141s
Duffield, VA 24244

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Stickleyville Elementary School",'Duffield=' + Duffield.length); Ewing[Ewing.length] = createMarker(new GPoint(-83.51509857,36.62279892),"
Thomas Walker High School
Po Box 39
Ewing, VA 24248

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Thomas Walker High School",'Ewing=' + Ewing.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(Ben_Hur); map.removeOverlays(Dryden); map.removeOverlays(Duffield); map.removeOverlays(Ewing); map.removeOverlays(Jonesville); map.removeOverlays(Keokee); map.removeOverlays(Pennington_Gap); map.removeOverlays(Rose_Hill); map.removeOverlays(Saint_Charles); 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(Dryden);map.removeOverlays(Ben_Hur); map.removeOverlays(Dryden); map.removeOverlays(Duffield); map.removeOverlays(Ewing); map.removeOverlays(Jonesville); map.removeOverlays(Keokee); map.removeOverlays(Pennington_Gap); map.removeOverlays(Rose_Hill); map.removeOverlays(Saint_Charles); map.addOverlays(Ben_Hur); centerByArray(Ben_Hur, false, false); cntMarker += Ben_Hur.length; map.addOverlays(Dryden); centerByArray(Dryden, false, false); cntMarker += Dryden.length; map.addOverlays(Duffield); centerByArray(Duffield, false, false); cntMarker += Duffield.length; map.addOverlays(Ewing); centerByArray(Ewing, false, false); cntMarker += Ewing.length; map.addOverlays(Jonesville); centerByArray(Jonesville, false, false); cntMarker += Jonesville.length; map.addOverlays(Keokee); centerByArray(Keokee, false, false); cntMarker += Keokee.length; map.addOverlays(Pennington_Gap); centerByArray(Pennington_Gap, false, false); cntMarker += Pennington_Gap.length; map.addOverlays(Rose_Hill); centerByArray(Rose_Hill, false, false); cntMarker += Rose_Hill.length; map.addOverlays(Saint_Charles); centerByArray(Saint_Charles, false, false); cntMarker += Saint_Charles.length; centerByArray(Dryden,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'); } }