function addMarkers() { mySelect = document.getElementById('selection'); Bakersfield = [];Fairfax = [];Richford = [];Enosburg_Falls = [];Fairfield = [];Cambridge = [];Saint_Albans = [];Franklin = [];Swanton = [];St_Albans = [];Highgate_Center = [];Montgomery_Cent = [];Sheldon = [];mySelect.options[mySelect.options.length] = new Option("Bakersfield schools",'all=Bakersfield'); mySelect.options[mySelect.options.length] = new Option("Cambridge schools",'all=Cambridge'); mySelect.options[mySelect.options.length] = new Option("Enosburg Falls schools",'all=Enosburg_Falls'); mySelect.options[mySelect.options.length] = new Option("Fairfax schools",'all=Fairfax'); mySelect.options[mySelect.options.length] = new Option("Fairfield schools",'all=Fairfield'); mySelect.options[mySelect.options.length] = new Option("Franklin schools",'all=Franklin'); mySelect.options[mySelect.options.length] = new Option("Highgate Center schools",'all=Highgate_Center'); mySelect.options[mySelect.options.length] = new Option("Montgomery Cent schools",'all=Montgomery_Cent'); mySelect.options[mySelect.options.length] = new Option("Richford schools",'all=Richford'); mySelect.options[mySelect.options.length] = new Option("Saint Albans schools",'all=Saint_Albans'); mySelect.options[mySelect.options.length] = new Option("Sheldon schools",'all=Sheldon'); mySelect.options[mySelect.options.length] = new Option("St Albans schools",'all=St_Albans'); mySelect.options[mySelect.options.length] = new Option("Swanton schools",'all=Swanton'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Bakersfield[Bakersfield.length] = createMarker(new GPoint(-72.80175781,44.78327942),"
Bakersfield School
Academy Drive
Bakersfield, VT 05441

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bakersfield School",'Bakersfield=' + Bakersfield.length); Fairfax[Fairfax.length] = createMarker(new GPoint(-73.02549744,44.69340134),"
Bellows Free Academy
Po Box 68
Fairfax, VT 05454

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bellows Free Academy",'Fairfax=' + Fairfax.length); Richford[Richford.length] = createMarker(new GPoint(-72.76696777,44.97294235),"
Berkshire Elementary School
4850 Water Tower Road
Richford, VT 05476

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Berkshire Elementary School",'Richford=' + Richford.length); Fairfax[Fairfax.length] = createMarker(new GPoint(-73.01270400,44.66298000),"
Bfa Elem/ Middle School
Po Box 68
Fairfax, VT 05454

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bfa Elem/ Middle School",'Fairfax=' + Fairfax.length); Enosburg_Falls[Enosburg_Falls.length] = createMarker(new GPoint(-72.80290222,44.90029907),"
Cold Hollow Career Center
Po Box 530
Enosburg Falls, VT 05450

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cold Hollow Career Center",'Enosburg_Falls=' + Enosburg_Falls.length); Enosburg_Falls[Enosburg_Falls.length] = createMarker(new GPoint(-72.80290222,44.90029907),"
Enosburg Falls Elementary School
Po Box 510
Enosburg Falls, VT 05450

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Enosburg Falls Elementary School",'Enosburg_Falls=' + Enosburg_Falls.length); Enosburg_Falls[Enosburg_Falls.length] = createMarker(new GPoint(-72.80004120,44.90515900),"
Enosburg Falls Jr/sr High S
School Street Po Box 417
Enosburg Falls, VT 05450

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Enosburg Falls Jr/sr High S",'Enosburg_Falls=' + Enosburg_Falls.length); Fairfield[Fairfield.length] = createMarker(new GPoint(-72.94515228,44.80163193),"
Fairfield Center School
Route 36
Fairfield, VT 05455

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Fairfield Center School",'Fairfield=' + Fairfield.length); Cambridge[Cambridge.length] = createMarker(new GPoint(-72.92349243,44.66981888),"
Fletcher Elementary School
340 School Road
Cambridge, VT 05444

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Fletcher Elementary School",'Cambridge=' + Cambridge.length); Saint_Albans[Saint_Albans.length] = createMarker(new GPoint(-73.08604431,44.81045532),"
Franklin Central S.u.
28 Catherine St
Saint Albans, VT 05478

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Franklin Central S.u.",'Saint_Albans=' + Saint_Albans.length); Franklin[Franklin.length] = createMarker(new GPoint(-72.89839935,44.97750092),"
Franklin Central School
Po Box 146
Franklin, VT 05457

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Franklin Central School",'Franklin=' + Franklin.length); Richford[Richford.length] = createMarker(new GPoint(-72.66400146,44.97940063),"
Franklin Northeast S.u. Elementary School
Po Box 130
Richford, VT 05476

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Franklin Northeast S.u. Elementary School",'Richford=' + Richford.length); Swanton[Swanton.length] = createMarker(new GPoint(-73.12493896,44.91807938),"
Franklin Northwest S.u. Elementary School
21 Church Street
Swanton, VT 05488

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Franklin Northwest S.u. Elementary School",'Swanton=' + Swanton.length); St_Albans[St_Albans.length] = createMarker(new GPoint(-73.11624908,44.73352051),"
Georgia Elementary & Middle School
4416 Ethan Allen Highway
St. Albans, VT 05478

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Georgia Elementary & Middle School",'St_Albans=' + St_Albans.length); Highgate_Center[Highgate_Center.length] = createMarker(new GPoint(-73.02519989,44.94169998),"
Highgate Schools Elementary School
Po Box 163
Highgate Center, VT 05459

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Highgate Schools Elementary School",'Highgate_Center=' + Highgate_Center.length); Swanton[Swanton.length] = createMarker(new GPoint(-73.10066986,44.92647171),"
Missisquoi Valley Uhsd #7 High School
100 Thunder Bird Drive
Swanton, VT 05488

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Missisquoi Valley Uhsd #7 High School",'Swanton=' + Swanton.length); Montgomery_Cent[Montgomery_Cent.length] = createMarker(new GPoint(-72.61579132,44.88633347),"
Montgomery Center School
249 School Drive
Montgomery Cent, VT 05471

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Montgomery Center School",'Montgomery_Cent=' + Montgomery_Cent.length); St_Albans[St_Albans.length] = createMarker(new GPoint(-73.08332800,44.80814300),"
Northwest Technical Center
71 South Main Street
St Albans, VT 05478

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Northwest Technical Center",'St_Albans=' + St_Albans.length); Richford[Richford.length] = createMarker(new GPoint(-72.68034363,44.98580933),"
Richford Elementary School
1 Elementary School Road
Richford, VT 05476

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Richford Elementary School",'Richford=' + Richford.length); Richford[Richford.length] = createMarker(new GPoint(-72.66995239,44.99613571),"
Richford Jr/sr High School
1 Corliss Heights
Richford, VT 05476

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Richford Jr/sr High School",'Richford=' + Richford.length); Saint_Albans[Saint_Albans.length] = createMarker(new GPoint(-73.09058380,44.81961441),"
Saint Albans City Elementary School
29 Bellows Street
Saint Albans, VT 05478

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Saint Albans City Elementary School",'Saint_Albans=' + Saint_Albans.length); Saint_Albans[Saint_Albans.length] = createMarker(new GPoint(-73.08813477,44.80221176),"
Saint Albans Town Educ. Cente Elementary School
169 South Main Street
Saint Albans, VT 05478

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Saint Albans Town Educ. Cente Elementary School",'Saint_Albans=' + Saint_Albans.length); Sheldon[Sheldon.length] = createMarker(new GPoint(-72.96885681,44.90111542),"
Sheldon Elementary School
78 Poor Farm Road
Sheldon, VT 05483

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Sheldon Elementary School",'Sheldon=' + Sheldon.length); Swanton[Swanton.length] = createMarker(new GPoint(-73.11426544,44.91632462),"
Swanton Schools Elementary School
24 Fourth Street
Swanton, VT 05488

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Swanton Schools Elementary School",'Swanton=' + Swanton.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(Bakersfield); map.removeOverlays(Cambridge); map.removeOverlays(Enosburg_Falls); map.removeOverlays(Fairfax); map.removeOverlays(Fairfield); map.removeOverlays(Franklin); map.removeOverlays(Highgate_Center); map.removeOverlays(Montgomery_Cent); map.removeOverlays(Richford); map.removeOverlays(Saint_Albans); map.removeOverlays(Sheldon); map.removeOverlays(St_Albans); map.removeOverlays(Swanton); 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(Bakersfield);map.removeOverlays(Bakersfield); map.removeOverlays(Cambridge); map.removeOverlays(Enosburg_Falls); map.removeOverlays(Fairfax); map.removeOverlays(Fairfield); map.removeOverlays(Franklin); map.removeOverlays(Highgate_Center); map.removeOverlays(Montgomery_Cent); map.removeOverlays(Richford); map.removeOverlays(Saint_Albans); map.removeOverlays(Sheldon); map.removeOverlays(St_Albans); map.removeOverlays(Swanton); map.addOverlays(Bakersfield); centerByArray(Bakersfield, false, false); cntMarker += Bakersfield.length; map.addOverlays(Cambridge); centerByArray(Cambridge, false, false); cntMarker += Cambridge.length; map.addOverlays(Enosburg_Falls); centerByArray(Enosburg_Falls, false, false); cntMarker += Enosburg_Falls.length; map.addOverlays(Fairfax); centerByArray(Fairfax, false, false); cntMarker += Fairfax.length; map.addOverlays(Fairfield); centerByArray(Fairfield, false, false); cntMarker += Fairfield.length; map.addOverlays(Franklin); centerByArray(Franklin, false, false); cntMarker += Franklin.length; map.addOverlays(Highgate_Center); centerByArray(Highgate_Center, false, false); cntMarker += Highgate_Center.length; map.addOverlays(Montgomery_Cent); centerByArray(Montgomery_Cent, false, false); cntMarker += Montgomery_Cent.length; map.addOverlays(Richford); centerByArray(Richford, false, false); cntMarker += Richford.length; map.addOverlays(Saint_Albans); centerByArray(Saint_Albans, false, false); cntMarker += Saint_Albans.length; map.addOverlays(Sheldon); centerByArray(Sheldon, false, false); cntMarker += Sheldon.length; map.addOverlays(St_Albans); centerByArray(St_Albans, false, false); cntMarker += St_Albans.length; map.addOverlays(Swanton); centerByArray(Swanton, false, false); cntMarker += Swanton.length; centerByArray(Bakersfield,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'); } }