function addMarkers() { mySelect = document.getElementById('selection'); Clinton = [];Roseboro = [];Autryville = [];Faison = [];Newton_Grove = [];Salemburg = [];Dunn = [];mySelect.options[mySelect.options.length] = new Option("Autryville schools",'all=Autryville'); mySelect.options[mySelect.options.length] = new Option("Clinton schools",'all=Clinton'); mySelect.options[mySelect.options.length] = new Option("Dunn schools",'all=Dunn'); mySelect.options[mySelect.options.length] = new Option("Faison schools",'all=Faison'); mySelect.options[mySelect.options.length] = new Option("Newton Grove schools",'all=Newton_Grove'); mySelect.options[mySelect.options.length] = new Option("Roseboro schools",'all=Roseboro'); mySelect.options[mySelect.options.length] = new Option("Salemburg schools",'all=Salemburg'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Clinton[Clinton.length] = createMarker(new GPoint(-78.31504059,34.99147415),"
Butler Avenue Elementary School
301 Butler Ave
Clinton, NC 28328

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Butler Avenue Elementary School",'Clinton=' + Clinton.length); Roseboro[Roseboro.length] = createMarker(new GPoint(-78.50579834,34.97370148),"
Charles E Perry Elementary School
Po Box 829
Roseboro, NC 28382

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Charles E Perry Elementary School",'Roseboro=' + Roseboro.length); Autryville[Autryville.length] = createMarker(new GPoint(-78.58950806,35.10453415),"
Clement Elementary School
3220 Maxwell Rd
Autryville, NC 28318

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Clement Elementary School",'Autryville=' + Autryville.length); Clinton[Clinton.length] = createMarker(new GPoint(-78.33132172,34.98143768),"
Clinton High School
1201 W Elizabeth St
Clinton, NC 28328

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Clinton High School",'Clinton=' + Clinton.length); Faison[Faison.length] = createMarker(new GPoint(-78.23559570,35.09150314),"
Hargrove Elementary School
7725 Faison Hwy
Faison, NC 28341

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Hargrove Elementary School",'Faison=' + Faison.length); Newton_Grove[Newton_Grove.length] = createMarker(new GPoint(-78.32846832,35.17989731),"
Hobbton Elementary School
12361 Hobbton Hwy
Newton Grove, NC 28366

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Hobbton Elementary School",'Newton_Grove=' + Newton_Grove.length); Newton_Grove[Newton_Grove.length] = createMarker(new GPoint(-78.32832336,35.17787170),"
Hobbton High School
12201 Hobbton Hwy
Newton Grove, NC 28366

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Hobbton High School",'Newton_Grove=' + Newton_Grove.length); Newton_Grove[Newton_Grove.length] = createMarker(new GPoint(-78.32817078,35.17651367),"
Hobbton Middle School
12081 Hobbton Hwy
Newton Grove, NC 28366

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Hobbton Middle School",'Newton_Grove=' + Newton_Grove.length); Salemburg[Salemburg.length] = createMarker(new GPoint(-78.49936676,34.99054718),"
Lakewood High School
245 Lakewood School Rd
Salemburg, NC 28385

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Lakewood High School",'Salemburg=' + Salemburg.length); Clinton[Clinton.length] = createMarker(new GPoint(-78.32202911,35.01390839),"
Langdon C Kerr Elementary School
112 Kimbrough Rd
Clinton, NC 28328

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Langdon C Kerr Elementary School",'Clinton=' + Clinton.length); Dunn[Dunn.length] = createMarker(new GPoint(-78.50350189,35.18854904),"
Midway Elementary School
1500 Midway Elementary Rd
Dunn, NC 28334

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Midway Elementary School",'Dunn=' + Dunn.length); Dunn[Dunn.length] = createMarker(new GPoint(-78.53377533,35.16741180),"
Midway Middle School
1115 Roberts Grove Road
Dunn, NC 28334

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Midway Middle School",'Dunn=' + Dunn.length); Dunn[Dunn.length] = createMarker(new GPoint(-78.53987122,35.23493958),"
Plain View Elementary School
4140 Plain View Hwy
Dunn, NC 28334

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Plain View Elementary School",'Dunn=' + Dunn.length); Roseboro[Roseboro.length] = createMarker(new GPoint(-78.50579834,34.97370148),"
Roseboro-salemburg Middle School
Po Box 976
Roseboro, NC 28382

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Roseboro-salemburg Middle School",'Roseboro=' + Roseboro.length); Salemburg[Salemburg.length] = createMarker(new GPoint(-78.49690247,35.03430176),"
Salemburg Elementary School
Po Box 9
Salemburg, NC 28385

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Salemburg Elementary School",'Salemburg=' + Salemburg.length); Clinton[Clinton.length] = createMarker(new GPoint(-78.33076600,34.99788500),"
Sampson Early College High School
Po Box 318
Clinton, NC 28329

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Sampson Early College High School",'Clinton=' + Clinton.length); Clinton[Clinton.length] = createMarker(new GPoint(-78.33081818,34.99782944),"
Sampson Middle School
505 Sunset Avenue
Clinton, NC 28328

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Sampson Middle School",'Clinton=' + Clinton.length); Clinton[Clinton.length] = createMarker(new GPoint(-78.25396729,34.83774185),"
Union Elementary School
10400 Taylors Bridge Hwy
Clinton, NC 28328

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Union Elementary School",'Clinton=' + Clinton.length); Clinton[Clinton.length] = createMarker(new GPoint(-78.24055481,34.83032990),"
Union High School
455 River Road
Clinton, NC 28328

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Union High School",'Clinton=' + Clinton.length); Clinton[Clinton.length] = createMarker(new GPoint(-78.28124237,34.85414124),"
Union Middle School
1190 Edmond Matthis Rd
Clinton, NC 28328

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Union Middle School",'Clinton=' + Clinton.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(Autryville); map.removeOverlays(Clinton); map.removeOverlays(Dunn); map.removeOverlays(Faison); map.removeOverlays(Newton_Grove); map.removeOverlays(Roseboro); map.removeOverlays(Salemburg); 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(Clinton);map.removeOverlays(Autryville); map.removeOverlays(Clinton); map.removeOverlays(Dunn); map.removeOverlays(Faison); map.removeOverlays(Newton_Grove); map.removeOverlays(Roseboro); map.removeOverlays(Salemburg); map.addOverlays(Autryville); centerByArray(Autryville, false, false); cntMarker += Autryville.length; map.addOverlays(Clinton); centerByArray(Clinton, false, false); cntMarker += Clinton.length; map.addOverlays(Dunn); centerByArray(Dunn, false, false); cntMarker += Dunn.length; map.addOverlays(Faison); centerByArray(Faison, false, false); cntMarker += Faison.length; map.addOverlays(Newton_Grove); centerByArray(Newton_Grove, false, false); cntMarker += Newton_Grove.length; map.addOverlays(Roseboro); centerByArray(Roseboro, false, false); cntMarker += Roseboro.length; map.addOverlays(Salemburg); centerByArray(Salemburg, false, false); cntMarker += Salemburg.length; centerByArray(Clinton,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'); } }