function addMarkers() { mySelect = document.getElementById('selection'); Trenton = [];North_Augusta = [];Johnston = [];Edgefield = [];mySelect.options[mySelect.options.length] = new Option("Edgefield schools",'all=Edgefield'); mySelect.options[mySelect.options.length] = new Option("Johnston schools",'all=Johnston'); mySelect.options[mySelect.options.length] = new Option("North Augusta schools",'all=North_Augusta'); mySelect.options[mySelect.options.length] = new Option("Trenton schools",'all=Trenton'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Trenton[Trenton.length] = createMarker(new GPoint(-81.83558655,33.73252487),"
Douglas Elementary School
215 S. E. Diggs Road
Trenton, SC 29847

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Douglas Elementary School",'Trenton=' + Trenton.length); North_Augusta[North_Augusta.length] = createMarker(new GPoint(-82.00152800,33.60471700),"
Fox Creek High School
1297 West Martintown Rd.
North Augusta, SC 29841

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Fox Creek High School",'North_Augusta=' + North_Augusta.length); Johnston[Johnston.length] = createMarker(new GPoint(-81.85494232,33.80780411),"
Johnson-edgefield-trenton Middle School
1095 Columbia Road
Johnston, SC 29832

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Johnson-edgefield-trenton Middle School",'Johnston=' + Johnston.length); Johnston[Johnston.length] = createMarker(new GPoint(-81.81044769,33.84381866),"
Johnston Elementary School
710 Lee Street
Johnston, SC 29832

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Johnston Elementary School",'Johnston=' + Johnston.length); North_Augusta[North_Augusta.length] = createMarker(new GPoint(-81.99395752,33.58269119),"
Merriwether Elementary School
565 Springhaven Road
North Augusta, SC 29841

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Merriwether Elementary School",'North_Augusta=' + North_Augusta.length); North_Augusta[North_Augusta.length] = createMarker(new GPoint(-81.98347473,33.58354950),"
Merriwether Middle School
430 Murrah Road
North Augusta, SC 29841

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Merriwether Middle School",'North_Augusta=' + North_Augusta.length); Johnston[Johnston.length] = createMarker(new GPoint(-81.86172100,33.80734800),"
Strom Thurmond Career Center
17 Par Drive
Johnston, SC 29832

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Strom Thurmond Career Center",'Johnston=' + Johnston.length); Johnston[Johnston.length] = createMarker(new GPoint(-81.86319733,33.80644608),"
Strom Thurmond High School
1131 Columbia Road
Johnston, SC 29832

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Strom Thurmond High School",'Johnston=' + Johnston.length); Trenton[Trenton.length] = createMarker(new GPoint(-81.84114838,33.74383163),"
Trenton Correctional Institution High School
Route 1 Box 1000
Trenton, SC 29847

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Trenton Correctional Institution High School",'Trenton=' + Trenton.length); Edgefield[Edgefield.length] = createMarker(new GPoint(-81.92690277,33.80336380),"
W. E. Parker Elementary School
41 Crest Road
Edgefield, SC 29824

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("W. E. Parker Elementary School",'Edgefield=' + Edgefield.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(Edgefield); map.removeOverlays(Johnston); map.removeOverlays(North_Augusta); map.removeOverlays(Trenton); 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(Trenton);map.removeOverlays(Edgefield); map.removeOverlays(Johnston); map.removeOverlays(North_Augusta); map.removeOverlays(Trenton); map.addOverlays(Edgefield); centerByArray(Edgefield, false, false); cntMarker += Edgefield.length; map.addOverlays(Johnston); centerByArray(Johnston, false, false); cntMarker += Johnston.length; map.addOverlays(North_Augusta); centerByArray(North_Augusta, false, false); cntMarker += North_Augusta.length; map.addOverlays(Trenton); centerByArray(Trenton, false, false); cntMarker += Trenton.length; centerByArray(Trenton,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'); } }