function addMarkers() { mySelect = document.getElementById('selection'); Turbeville = [];Manning = [];_West_Manning = [];Alcolu = [];Summerton = [];New_Zion = [];mySelect.options[mySelect.options.length] = new Option("Alcolu schools",'all=Alcolu'); mySelect.options[mySelect.options.length] = new Option("Manning schools",'all=Manning'); mySelect.options[mySelect.options.length] = new Option("New Zion schools",'all=New_Zion'); mySelect.options[mySelect.options.length] = new Option("Summerton schools",'all=Summerton'); mySelect.options[mySelect.options.length] = new Option("Turbeville schools",'all=Turbeville'); mySelect.options[mySelect.options.length] = new Option(" West Manning schools",'all=_West_Manning'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Turbeville[Turbeville.length] = createMarker(new GPoint(-79.99770355,33.88370132),"
East Clarendon High School
P O Box 67
Turbeville, SC 29162

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("East Clarendon High School",'Turbeville=' + Turbeville.length); Turbeville[Turbeville.length] = createMarker(new GPoint(-79.99770355,33.88370132),"
East Clarendon Middle School
1101 Pope Street
Turbeville, SC 29162

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("East Clarendon Middle School",'Turbeville=' + Turbeville.length); Manning[Manning.length] = createMarker(new GPoint(-10.00000000,10.00000000),"
F E Dubose Voc Center
Box 1249
Manning, SC 29102

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("F E Dubose Voc Center",'Manning=' + Manning.length); Manning[Manning.length] = createMarker(new GPoint(-80.24109650,33.70235825),"
Manning Early Childhood Center
2759 Raccoon Road
Manning, SC 29102

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Manning Early Childhood Center",'Manning=' + Manning.length); _West_Manning[_West_Manning.length] = createMarker(new GPoint(-80.30660248,33.72299957),"
Manning Elementary School
Route 6 Box 50 Hwy.
261 West Manning, SC 29102

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Manning Elementary School",'_West_Manning=' + _West_Manning.length); Manning[Manning.length] = createMarker(new GPoint(-80.21070862,33.69517136),"
Manning High School
Highway 261 West
Manning, SC 29102

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Manning High School",'Manning=' + Manning.length); Manning[Manning.length] = createMarker(new GPoint(-80.21914673,33.69615555),"
Manning Junior High School
311 W Boyce St
Manning, SC 29102

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Manning Junior High School",'Manning=' + Manning.length); Manning[Manning.length] = createMarker(new GPoint(-80.21366119,33.69796753),"
Manning Primary School
125 N Boundry Street
Manning, SC 29102

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Manning Primary School",'Manning=' + Manning.length); Alcolu[Alcolu.length] = createMarker(new GPoint(-80.21408844,33.75162125),"
Phoenix Center
P.0. Box 170
Alcolu, SC 29000

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Phoenix Center",'Alcolu=' + Alcolu.length); Summerton[Summerton.length] = createMarker(new GPoint(-80.38289642,33.48270035),"
Saint Paul Primary
255 Liberty Hill Church Rd
Summerton, SC 29148

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Saint Paul Primary",'Summerton=' + Summerton.length); Summerton[Summerton.length] = createMarker(new GPoint(-101.88980700,35.10200300),"
Scott's Branch Middle School
3post Office Box 67
Summerton, SC 29148

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Scott's Branch Middle School",'Summerton=' + Summerton.length); Summerton[Summerton.length] = createMarker(new GPoint(-80.37300110,33.48189926),"
Scotts Branch High School
Rt. 3 Box 802
Summerton, SC 29148

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Scotts Branch High School",'Summerton=' + Summerton.length); Turbeville[Turbeville.length] = createMarker(new GPoint(-79.99770355,33.88370132),"
Turbeville Correctional Institution High School
Post Office Box 252
Turbeville, SC 29162

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Turbeville Correctional Institution High School",'Turbeville=' + Turbeville.length); New_Zion[New_Zion.length] = createMarker(new GPoint(-80.01779938,33.80849838),"
Walker Gamble Elementary School
P O Box 7
New Zion, SC 29111

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Walker Gamble Elementary School",'New_Zion=' + New_Zion.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(Alcolu); map.removeOverlays(Manning); map.removeOverlays(New_Zion); map.removeOverlays(Summerton); map.removeOverlays(Turbeville); map.removeOverlays(_West_Manning); 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(Turbeville);map.removeOverlays(Alcolu); map.removeOverlays(Manning); map.removeOverlays(New_Zion); map.removeOverlays(Summerton); map.removeOverlays(Turbeville); map.removeOverlays(_West_Manning); map.addOverlays(Alcolu); centerByArray(Alcolu, false, false); cntMarker += Alcolu.length; map.addOverlays(Manning); centerByArray(Manning, false, false); cntMarker += Manning.length; map.addOverlays(New_Zion); centerByArray(New_Zion, false, false); cntMarker += New_Zion.length; map.addOverlays(Summerton); centerByArray(Summerton, false, false); cntMarker += Summerton.length; map.addOverlays(Turbeville); centerByArray(Turbeville, false, false); cntMarker += Turbeville.length; map.addOverlays(_West_Manning); centerByArray(_West_Manning, false, false); cntMarker += _West_Manning.length; centerByArray(Turbeville,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'); } }