function addMarkers() { mySelect = document.getElementById('selection'); Clarkton = [];Elizabethtown = [];Bladenboro = [];Dublin = [];Riegelwood = [];Tar_Heel = [];mySelect.options[mySelect.options.length] = new Option("Bladenboro schools",'all=Bladenboro'); mySelect.options[mySelect.options.length] = new Option("Clarkton schools",'all=Clarkton'); mySelect.options[mySelect.options.length] = new Option("Dublin schools",'all=Dublin'); mySelect.options[mySelect.options.length] = new Option("Elizabethtown schools",'all=Elizabethtown'); mySelect.options[mySelect.options.length] = new Option("Riegelwood schools",'all=Riegelwood'); mySelect.options[mySelect.options.length] = new Option("Tar Heel schools",'all=Tar_Heel'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Clarkton[Clarkton.length] = createMarker(new GPoint(-78.63960266,34.50070190),"
B T Washington Primary
66 Booker T Washington Road
Clarkton, NC 28433

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("B T Washington Primary",'Clarkton=' + Clarkton.length); Elizabethtown[Elizabethtown.length] = createMarker(new GPoint(-78.57168579,34.74161911),"
Bladen Lakes Primary
9554 Johnsontown Road
Elizabethtown, NC 28337

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bladen Lakes Primary",'Elizabethtown=' + Elizabethtown.length); Bladenboro[Bladenboro.length] = createMarker(new GPoint(-78.79758453,34.53124619),"
Bladenboro High School
910 South Main St
Bladenboro, NC 28320

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bladenboro High School",'Bladenboro=' + Bladenboro.length); Bladenboro[Bladenboro.length] = createMarker(new GPoint(-78.79758453,34.53124619),"
Bladenboro Middle School
910 South Main Street
Bladenboro, NC 28320

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Bladenboro Middle School",'Bladenboro=' + Bladenboro.length); Bladenboro[Bladenboro.length] = createMarker(new GPoint(-78.78040314,34.56150055),"
Bladenboro Primary
Po Box 820
Bladenboro, NC 28320

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bladenboro Primary",'Bladenboro=' + Bladenboro.length); Clarkton[Clarkton.length] = createMarker(new GPoint(-78.63960266,34.50070190),"
Clarkton School Of Discovery
Po Box 127
Clarkton, NC 28433

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Clarkton School Of Discovery",'Clarkton=' + Clarkton.length); Dublin[Dublin.length] = createMarker(new GPoint(-78.73049927,34.65530014),"
Dublin Elementary School
Po Box 307
Dublin, NC 28332

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Dublin Elementary School",'Dublin=' + Dublin.length); Riegelwood[Riegelwood.length] = createMarker(new GPoint(-78.25920105,34.35620117),"
East Arcadia Elementary School
21451 Nc 87 Hwy
Riegelwood, NC 28456

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("East Arcadia Elementary School",'Riegelwood=' + Riegelwood.length); Elizabethtown[Elizabethtown.length] = createMarker(new GPoint(-78.56809998,34.65079880),"
East Bladen High School
Po Box 578
Elizabethtown, NC 28337

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("East Bladen High School",'Elizabethtown=' + Elizabethtown.length); Elizabethtown[Elizabethtown.length] = createMarker(new GPoint(-78.56809998,34.65079880),"
Elizabethtown Middle School
Po Box 639
Elizabethtown, NC 28337

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Elizabethtown Middle School",'Elizabethtown=' + Elizabethtown.length); Elizabethtown[Elizabethtown.length] = createMarker(new GPoint(-78.56809998,34.65079880),"
Elizabethtown Primary
Po Box 2649
Elizabethtown, NC 28337

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Elizabethtown Primary",'Elizabethtown=' + Elizabethtown.length); Tar_Heel[Tar_Heel.length] = createMarker(new GPoint(-78.80999756,34.74570084),"
Plain View Primary
1963 Chicken Foot Road
Tar Heel, NC 28392

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Plain View Primary",'Tar_Heel=' + Tar_Heel.length); Elizabethtown[Elizabethtown.length] = createMarker(new GPoint(-78.56809998,34.65079880),"
School Of Extended Hope
Po Box 236
Elizabethtown, NC 28337

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("School Of Extended Hope",'Elizabethtown=' + Elizabethtown.length); Tar_Heel[Tar_Heel.length] = createMarker(new GPoint(-78.80999756,34.74570084),"
Tar Heel Middle School
Po Box 128
Tar Heel, NC 28392

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Tar Heel Middle School",'Tar_Heel=' + Tar_Heel.length); Bladenboro[Bladenboro.length] = createMarker(new GPoint(-78.73886108,34.63866425),"
West Bladen High School
1600 Nc Hwy 410
Bladenboro, NC 28320

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("West Bladen High School",'Bladenboro=' + Bladenboro.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(Bladenboro); map.removeOverlays(Clarkton); map.removeOverlays(Dublin); map.removeOverlays(Elizabethtown); map.removeOverlays(Riegelwood); map.removeOverlays(Tar_Heel); 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(Clarkton);map.removeOverlays(Bladenboro); map.removeOverlays(Clarkton); map.removeOverlays(Dublin); map.removeOverlays(Elizabethtown); map.removeOverlays(Riegelwood); map.removeOverlays(Tar_Heel); map.addOverlays(Bladenboro); centerByArray(Bladenboro, false, false); cntMarker += Bladenboro.length; map.addOverlays(Clarkton); centerByArray(Clarkton, false, false); cntMarker += Clarkton.length; map.addOverlays(Dublin); centerByArray(Dublin, false, false); cntMarker += Dublin.length; map.addOverlays(Elizabethtown); centerByArray(Elizabethtown, false, false); cntMarker += Elizabethtown.length; map.addOverlays(Riegelwood); centerByArray(Riegelwood, false, false); cntMarker += Riegelwood.length; map.addOverlays(Tar_Heel); centerByArray(Tar_Heel, false, false); cntMarker += Tar_Heel.length; centerByArray(Clarkton,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'); } }