function addMarkers() { mySelect = document.getElementById('selection'); Caldwell = [];Forrest_City = [];Hughes = [];Madison = [];Palestine = [];Wheatley = [];mySelect.options[mySelect.options.length] = new Option("Caldwell schools",'all=Caldwell'); mySelect.options[mySelect.options.length] = new Option("Forrest City schools",'all=Forrest_City'); mySelect.options[mySelect.options.length] = new Option("Hughes schools",'all=Hughes'); mySelect.options[mySelect.options.length] = new Option("Madison schools",'all=Madison'); mySelect.options[mySelect.options.length] = new Option("Palestine schools",'all=Palestine'); mySelect.options[mySelect.options.length] = new Option("Wheatley schools",'all=Wheatley'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Caldwell[Caldwell.length] = createMarker(new GPoint(-90.81674194,35.07460022),"
Caldwell Elementary School
4986 Hwy 1 North
Caldwell, AR 72322

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Caldwell Elementary School",'Caldwell=' + Caldwell.length); Forrest_City[Forrest_City.length] = createMarker(new GPoint(-90.79978180,35.02987289),"
Central Elementary School
801 Deaderick Road
Forrest City, AR 72335

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Forrest_City=' + Forrest_City.length); Forrest_City[Forrest_City.length] = createMarker(new GPoint(-90.77605600,35.02814600),"
East Arkansas Career Center
1700 New Castle Road
Forrest City, AR 72335

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("East Arkansas Career Center",'Forrest_City=' + Forrest_City.length); Forrest_City[Forrest_City.length] = createMarker(new GPoint(-90.79418182,35.02056122),"
Forrest City High School
467 Victoria
Forrest City, AR 72335

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Forrest City High School",'Forrest_City=' + Forrest_City.length); Forrest_City[Forrest_City.length] = createMarker(new GPoint(-90.78997040,35.01937866),"
Forrest City Jr. High School
1133 N Division
Forrest City, AR 72335

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Forrest City Jr. High School",'Forrest_City=' + Forrest_City.length); Forrest_City[Forrest_City.length] = createMarker(new GPoint(-90.77693176,34.98624802),"
Forrest Hills Elementary School
2505 Sycamore Street
Forrest City, AR 72335

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Forrest Hills Elementary School",'Forrest_City=' + Forrest_City.length); Hughes[Hughes.length] = createMarker(new GPoint(-90.43039703,34.93790054),"
Hughes Elementary School
Po Box 9
Hughes, AR 72348

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Hughes Elementary School",'Hughes=' + Hughes.length); Hughes[Hughes.length] = createMarker(new GPoint(-90.43039703,34.93790054),"
Hughes High School
Po Box 9
Hughes, AR 72348

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Hughes High School",'Hughes=' + Hughes.length); Forrest_City[Forrest_City.length] = createMarker(new GPoint(-90.79595184,35.00823593),"
Lincoln Middle School
616 W Broadway
Forrest City, AR 72335

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Lincoln Middle School",'Forrest_City=' + Forrest_City.length); Madison[Madison.length] = createMarker(new GPoint(-90.72602844,35.01326752),"
Madison Elementary School
106 North 5th Street
Madison, AR 72359

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Madison Elementary School",'Madison=' + Madison.length); Palestine[Palestine.length] = createMarker(new GPoint(-90.93609619,34.97200012),"
Palestine-wheatley Elementary School
P.o. Box 790
Palestine, AR 72372

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Palestine-wheatley Elementary School",'Palestine=' + Palestine.length); Wheatley[Wheatley.length] = createMarker(new GPoint(-91.09760284,34.92910004),"
Palestine-wheatley Junior High School
P.o. Box 109
Wheatley, AR 72392

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Palestine-wheatley Junior High School",'Wheatley=' + Wheatley.length); Wheatley[Wheatley.length] = createMarker(new GPoint(-91.09760284,34.92910004),"
Palestine-wheatley Middle School
P.o. Box 109
Wheatley, AR 72392

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Palestine-wheatley Middle School",'Wheatley=' + Wheatley.length); Palestine[Palestine.length] = createMarker(new GPoint(-90.93609619,34.97200012),"
Palestine-wheatley Senior High School
P.o. Box 790
Palestine, AR 72372

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Palestine-wheatley Senior High School",'Palestine=' + Palestine.length); Forrest_City[Forrest_City.length] = createMarker(new GPoint(-90.79611969,35.01156235),"
Stewart Elementary School
625 Irving Street
Forrest City, AR 72335

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Stewart Elementary School",'Forrest_City=' + Forrest_City.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(Caldwell); map.removeOverlays(Forrest_City); map.removeOverlays(Hughes); map.removeOverlays(Madison); map.removeOverlays(Palestine); map.removeOverlays(Wheatley); 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(Caldwell);map.removeOverlays(Caldwell); map.removeOverlays(Forrest_City); map.removeOverlays(Hughes); map.removeOverlays(Madison); map.removeOverlays(Palestine); map.removeOverlays(Wheatley); map.addOverlays(Caldwell); centerByArray(Caldwell, false, false); cntMarker += Caldwell.length; map.addOverlays(Forrest_City); centerByArray(Forrest_City, false, false); cntMarker += Forrest_City.length; map.addOverlays(Hughes); centerByArray(Hughes, false, false); cntMarker += Hughes.length; map.addOverlays(Madison); centerByArray(Madison, false, false); cntMarker += Madison.length; map.addOverlays(Palestine); centerByArray(Palestine, false, false); cntMarker += Palestine.length; map.addOverlays(Wheatley); centerByArray(Wheatley, false, false); cntMarker += Wheatley.length; centerByArray(Caldwell,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'); } }