function addMarkers() { mySelect = document.getElementById('selection'); Bennett = [];Bonlee = [];Bear_Creek = [];Siler_City = [];Pittsboro = [];Goldston = [];Moncure = [];Chapel_Hill = [];mySelect.options[mySelect.options.length] = new Option("Bear Creek schools",'all=Bear_Creek'); mySelect.options[mySelect.options.length] = new Option("Bennett schools",'all=Bennett'); mySelect.options[mySelect.options.length] = new Option("Bonlee schools",'all=Bonlee'); mySelect.options[mySelect.options.length] = new Option("Chapel Hill schools",'all=Chapel_Hill'); mySelect.options[mySelect.options.length] = new Option("Goldston schools",'all=Goldston'); mySelect.options[mySelect.options.length] = new Option("Moncure schools",'all=Moncure'); mySelect.options[mySelect.options.length] = new Option("Pittsboro schools",'all=Pittsboro'); mySelect.options[mySelect.options.length] = new Option("Siler City schools",'all=Siler_City'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Bennett[Bennett.length] = createMarker(new GPoint(-79.54270172,35.56069946),"
Bennett Elementary School
Po Box 107
Bennett, NC 27208

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bennett Elementary School",'Bennett=' + Bennett.length); Bonlee[Bonlee.length] = createMarker(new GPoint(-79.41470337,35.64580154),"
Bonlee Elementary School
153 Bonlee School Road
Bonlee, NC 27213

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bonlee Elementary School",'Bonlee=' + Bonlee.length); Bear_Creek[Bear_Creek.length] = createMarker(new GPoint(-79.38490295,35.61240005),"
Chatham Central High School
14950 Nc Hwy 902 W
Bear Creek, NC 27207

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Chatham Central High School",'Bear_Creek=' + Bear_Creek.length); Siler_City[Siler_City.length] = createMarker(new GPoint(-79.44940186,35.73109818),"
Chatham Charter
Po Box 245
Siler City, NC 27344

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Chatham Charter",'Siler_City=' + Siler_City.length); Siler_City[Siler_City.length] = createMarker(new GPoint(-79.44940186,35.73109818),"
Chatham Middle School
2025 South 2nd Avenue Ext
Siler City, NC 27344

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Chatham Middle School",'Siler_City=' + Siler_City.length); Pittsboro[Pittsboro.length] = createMarker(new GPoint(-79.16809845,35.76250076),"
Horton Middle School
Po Box 639
Pittsboro, NC 27312

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Horton Middle School",'Pittsboro=' + Pittsboro.length); Goldston[Goldston.length] = createMarker(new GPoint(-79.33599854,35.56919861),"
J S Waters Elementary School
Po Box 99
Goldston, NC 27252

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("J S Waters Elementary School",'Goldston=' + Goldston.length); Siler_City[Siler_City.length] = createMarker(new GPoint(-79.45232391,35.72415161),"
Jordan Matthews High School
910 East Cardinal Street
Siler City, NC 27344

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Jordan Matthews High School",'Siler_City=' + Siler_City.length); Moncure[Moncure.length] = createMarker(new GPoint(-79.07791200,35.62279600),"
Moncure Elementary School
600 Moncure School Road
Moncure, NC 27559

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Moncure Elementary School",'Moncure=' + Moncure.length); Chapel_Hill[Chapel_Hill.length] = createMarker(new GPoint(-79.03562164,35.82226181),"
North Chatham Elementary School
3380 Lystra Road
Chapel Hill, NC 27517

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("North Chatham Elementary School",'Chapel_Hill=' + Chapel_Hill.length); Pittsboro[Pittsboro.length] = createMarker(new GPoint(-79.16809845,35.76250076),"
Northwood High School
310 Northwood High School Road
Pittsboro, NC 27312

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Northwood High School",'Pittsboro=' + Pittsboro.length); Pittsboro[Pittsboro.length] = createMarker(new GPoint(-79.15410614,35.80398178),"
Perry W Harrison Elementary School
2655 Hamlet Chapel Road
Pittsboro, NC 27312

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Perry W Harrison Elementary School",'Pittsboro=' + Pittsboro.length); Pittsboro[Pittsboro.length] = createMarker(new GPoint(-79.16809845,35.76250076),"
Pittsboro Elementary School
375 Pittsboro School Road
Pittsboro, NC 27312

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Pittsboro Elementary School",'Pittsboro=' + Pittsboro.length); Siler_City[Siler_City.length] = createMarker(new GPoint(-79.44940186,35.73109818),"
Sage Academy
439 Martin L King Jr Blvd
Siler City, NC 27344

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Sage Academy",'Siler_City=' + Siler_City.length); Siler_City[Siler_City.length] = createMarker(new GPoint(-79.49471283,35.72549057),"
Siler City Elementary School
671 Ellington Road
Siler City, NC 27344

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Siler City Elementary School",'Siler_City=' + Siler_City.length); Siler_City[Siler_City.length] = createMarker(new GPoint(-79.44940186,35.73109818),"
Silk Hope Elementary School
7945 Silk Hopegum Springs Rd
Siler City, NC 27344

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Silk Hope Elementary School",'Siler_City=' + Siler_City.length); Chapel_Hill[Chapel_Hill.length] = createMarker(new GPoint(-79.02359772,35.88159943),"
Woods Charter
Po Box 5008
Chapel Hill, NC 27517

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Woods Charter",'Chapel_Hill=' + Chapel_Hill.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(Bear_Creek); map.removeOverlays(Bennett); map.removeOverlays(Bonlee); map.removeOverlays(Chapel_Hill); map.removeOverlays(Goldston); map.removeOverlays(Moncure); map.removeOverlays(Pittsboro); map.removeOverlays(Siler_City); 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(Bennett);map.removeOverlays(Bear_Creek); map.removeOverlays(Bennett); map.removeOverlays(Bonlee); map.removeOverlays(Chapel_Hill); map.removeOverlays(Goldston); map.removeOverlays(Moncure); map.removeOverlays(Pittsboro); map.removeOverlays(Siler_City); map.addOverlays(Bear_Creek); centerByArray(Bear_Creek, false, false); cntMarker += Bear_Creek.length; map.addOverlays(Bennett); centerByArray(Bennett, false, false); cntMarker += Bennett.length; map.addOverlays(Bonlee); centerByArray(Bonlee, false, false); cntMarker += Bonlee.length; map.addOverlays(Chapel_Hill); centerByArray(Chapel_Hill, false, false); cntMarker += Chapel_Hill.length; map.addOverlays(Goldston); centerByArray(Goldston, false, false); cntMarker += Goldston.length; map.addOverlays(Moncure); centerByArray(Moncure, false, false); cntMarker += Moncure.length; map.addOverlays(Pittsboro); centerByArray(Pittsboro, false, false); cntMarker += Pittsboro.length; map.addOverlays(Siler_City); centerByArray(Siler_City, false, false); cntMarker += Siler_City.length; centerByArray(Bennett,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'); } }