function addMarkers() { mySelect = document.getElementById('selection'); Coleman = [];Mannsville = [];Milburn = [];Mill_Creek = [];Ravia = [];Tishomingo = [];Wapanucka = [];mySelect.options[mySelect.options.length] = new Option("Coleman schools",'all=Coleman'); mySelect.options[mySelect.options.length] = new Option("Mannsville schools",'all=Mannsville'); mySelect.options[mySelect.options.length] = new Option("Milburn schools",'all=Milburn'); mySelect.options[mySelect.options.length] = new Option("Mill Creek schools",'all=Mill_Creek'); mySelect.options[mySelect.options.length] = new Option("Ravia schools",'all=Ravia'); mySelect.options[mySelect.options.length] = new Option("Tishomingo schools",'all=Tishomingo'); mySelect.options[mySelect.options.length] = new Option("Wapanucka schools",'all=Wapanucka'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Coleman[Coleman.length] = createMarker(new GPoint(-96.46309662,34.27249908),"
Coleman Elementary School
Po Box 188
Coleman, OK 73432

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Coleman Elementary School",'Coleman=' + Coleman.length); Coleman[Coleman.length] = createMarker(new GPoint(-96.46309662,34.27249908),"
Coleman High School
Po Box 188
Coleman, OK 73432

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Coleman High School",'Coleman=' + Coleman.length); Mannsville[Mannsville.length] = createMarker(new GPoint(-96.87190247,34.19029999),"
Mannsville Elementary School
Po Box 68
Mannsville, OK 73447

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mannsville Elementary School",'Mannsville=' + Mannsville.length); Milburn[Milburn.length] = createMarker(new GPoint(-96.54450226,34.18669891),"
Milburn Elementary School
Po Box 429
Milburn, OK 73450

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Milburn Elementary School",'Milburn=' + Milburn.length); Milburn[Milburn.length] = createMarker(new GPoint(-96.54450226,34.18669891),"
Milburn High School
Po Box 429
Milburn, OK 73450

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Milburn High School",'Milburn=' + Milburn.length); Mill_Creek[Mill_Creek.length] = createMarker(new GPoint(-96.80590057,34.33710098),"
Mill Creek Elementary School
Po Box 118
Mill Creek, OK 74856

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mill Creek Elementary School",'Mill_Creek=' + Mill_Creek.length); Mill_Creek[Mill_Creek.length] = createMarker(new GPoint(-96.80590057,34.33710098),"
Mill Creek High School
Po Box 118
Mill Creek, OK 74856

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Mill Creek High School",'Mill_Creek=' + Mill_Creek.length); Ravia[Ravia.length] = createMarker(new GPoint(-96.75589752,34.24069977),"
Ravia Elementary School
Po Box 299
Ravia, OK 73455

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Ravia Elementary School",'Ravia=' + Ravia.length); Tishomingo[Tishomingo.length] = createMarker(new GPoint(-96.66314697,34.23073578),"
Tishomingo Elementary School
1300 E Main St
Tishomingo, OK 73460

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Tishomingo Elementary School",'Tishomingo=' + Tishomingo.length); Tishomingo[Tishomingo.length] = createMarker(new GPoint(-96.66314697,34.23073578),"
Tishomingo High School
1300 E Main St
Tishomingo, OK 73460

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Tishomingo High School",'Tishomingo=' + Tishomingo.length); Tishomingo[Tishomingo.length] = createMarker(new GPoint(-96.66314697,34.23073578),"
Tishomingo Middle School
1300 E Main St
Tishomingo, OK 73460

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Tishomingo Middle School",'Tishomingo=' + Tishomingo.length); Wapanucka[Wapanucka.length] = createMarker(new GPoint(-96.45310211,34.38479996),"
Wapanucka Elementary School
Po Box 188
Wapanucka, OK 73461

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Wapanucka Elementary School",'Wapanucka=' + Wapanucka.length); Wapanucka[Wapanucka.length] = createMarker(new GPoint(-96.45310211,34.38479996),"
Wapanucka High School
Po Box 188
Wapanucka, OK 73461

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Wapanucka High School",'Wapanucka=' + Wapanucka.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(Coleman); map.removeOverlays(Mannsville); map.removeOverlays(Milburn); map.removeOverlays(Mill_Creek); map.removeOverlays(Ravia); map.removeOverlays(Tishomingo); map.removeOverlays(Wapanucka); 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(Coleman);map.removeOverlays(Coleman); map.removeOverlays(Mannsville); map.removeOverlays(Milburn); map.removeOverlays(Mill_Creek); map.removeOverlays(Ravia); map.removeOverlays(Tishomingo); map.removeOverlays(Wapanucka); map.addOverlays(Coleman); centerByArray(Coleman, false, false); cntMarker += Coleman.length; map.addOverlays(Mannsville); centerByArray(Mannsville, false, false); cntMarker += Mannsville.length; map.addOverlays(Milburn); centerByArray(Milburn, false, false); cntMarker += Milburn.length; map.addOverlays(Mill_Creek); centerByArray(Mill_Creek, false, false); cntMarker += Mill_Creek.length; map.addOverlays(Ravia); centerByArray(Ravia, false, false); cntMarker += Ravia.length; map.addOverlays(Tishomingo); centerByArray(Tishomingo, false, false); cntMarker += Tishomingo.length; map.addOverlays(Wapanucka); centerByArray(Wapanucka, false, false); cntMarker += Wapanucka.length; centerByArray(Coleman,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'); } }