function addMarkers() { mySelect = document.getElementById('selection'); Achille = [];Bennington = [];Caddo = [];Calera = [];Colbert = [];Durant = [];Bokchito = [];mySelect.options[mySelect.options.length] = new Option("Achille schools",'all=Achille'); mySelect.options[mySelect.options.length] = new Option("Bennington schools",'all=Bennington'); mySelect.options[mySelect.options.length] = new Option("Bokchito schools",'all=Bokchito'); mySelect.options[mySelect.options.length] = new Option("Caddo schools",'all=Caddo'); mySelect.options[mySelect.options.length] = new Option("Calera schools",'all=Calera'); mySelect.options[mySelect.options.length] = new Option("Colbert schools",'all=Colbert'); mySelect.options[mySelect.options.length] = new Option("Durant schools",'all=Durant'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Achille[Achille.length] = createMarker(new GPoint(-96.38690186,33.83330154),"
Achille Elementary School
Po Box 280
Achille, OK 74720

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Achille Elementary School",'Achille=' + Achille.length); Achille[Achille.length] = createMarker(new GPoint(-96.38690186,33.83330154),"
Achille High School
Po Box 280
Achille, OK 74720

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Achille High School",'Achille=' + Achille.length); Bennington[Bennington.length] = createMarker(new GPoint(-96.01270294,33.98260117),"
Bennington Elementary School
729 N Perry St
Bennington, OK 74723

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bennington Elementary School",'Bennington=' + Bennington.length); Bennington[Bennington.length] = createMarker(new GPoint(-96.01270294,33.98260117),"
Bennington High School
729 N Perry St
Bennington, OK 74723

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bennington High School",'Bennington=' + Bennington.length); Caddo[Caddo.length] = createMarker(new GPoint(-96.25890350,34.11560059),"
Caddo Elementary School
Po Box 128
Caddo, OK 74729

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Caddo Elementary School",'Caddo=' + Caddo.length); Caddo[Caddo.length] = createMarker(new GPoint(-96.25890350,34.11560059),"
Caddo High School
Po Box 128
Caddo, OK 74729

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Caddo High School",'Caddo=' + Caddo.length); Calera[Calera.length] = createMarker(new GPoint(-96.41169739,33.92979813),"
Calera Elementary School
Po Box 386
Calera, OK 74730

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Calera Elementary School",'Calera=' + Calera.length); Calera[Calera.length] = createMarker(new GPoint(-96.41169739,33.92979813),"
Calera High School
Po Box 386
Calera, OK 74730

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Calera High School",'Calera=' + Calera.length); Colbert[Colbert.length] = createMarker(new GPoint(-96.49510193,33.85869980),"
Colbert High School
Po Box 310
Colbert, OK 74733

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Colbert High School",'Colbert=' + Colbert.length); Colbert[Colbert.length] = createMarker(new GPoint(-96.49510193,33.85869980),"
Colbert Middle School
Po Box 310
Colbert, OK 74733

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Colbert Middle School",'Colbert=' + Colbert.length); Durant[Durant.length] = createMarker(new GPoint(-96.38148499,34.00183868),"
Durant High School
802 W Walnut St
Durant, OK 74701

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Durant High School",'Durant=' + Durant.length); Durant[Durant.length] = createMarker(new GPoint(-96.38745117,34.00713730),"
Durant Ies Middle School
1314 Waco St
Durant, OK 74701

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Durant Ies Middle School",'Durant=' + Durant.length); Durant[Durant.length] = createMarker(new GPoint(-96.38076019,33.99544525),"
Durant Middle School
410 N 6th Ave
Durant, OK 74701

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Durant Middle School",'Durant=' + Durant.length); Durant[Durant.length] = createMarker(new GPoint(-96.37010956,33.99011230),"
George Washington Elementary School
314 E Main St
Durant, OK 74701

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("George Washington Elementary School",'Durant=' + Durant.length); Durant[Durant.length] = createMarker(new GPoint(-96.39305115,34.00476456),"
Northwest Heights Elementary School
1715 W University Blvd
Durant, OK 74701

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Northwest Heights Elementary School",'Durant=' + Durant.length); Durant[Durant.length] = createMarker(new GPoint(-96.38594818,33.98957062),"
Robert E. Lee Elementary School
824 W Louisiana St
Durant, OK 74701

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Robert E. Lee Elementary School",'Durant=' + Durant.length); Durant[Durant.length] = createMarker(new GPoint(-96.38529968,34.00899887),"
Rock Creek Elementary School
23072 Us Highway 70
Durant, OK 74701

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Rock Creek Elementary School",'Durant=' + Durant.length); Bokchito[Bokchito.length] = createMarker(new GPoint(-96.14302826,34.01913071),"
Rock Creek High School
200 E Steakley St
Bokchito, OK 74726

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Rock Creek High School",'Bokchito=' + Bokchito.length); Durant[Durant.length] = createMarker(new GPoint(-96.38529968,34.00899887),"
Silo Elementary School
122 W Bourne St
Durant, OK 74701

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Silo Elementary School",'Durant=' + Durant.length); Durant[Durant.length] = createMarker(new GPoint(-96.38529968,34.00899887),"
Silo High School
122 W Bourne St
Durant, OK 74701

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Silo High School",'Durant=' + Durant.length); Durant[Durant.length] = createMarker(new GPoint(-96.38602400,33.99320800),"
Silo Jhs
122 W Bourne St
Durant, OK 74701

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Silo Jhs",'Durant=' + Durant.length); Colbert[Colbert.length] = createMarker(new GPoint(-96.49510193,33.85869980),"
Ward Elementary School East
Po Box 310
Colbert, OK 74733

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Ward Elementary School East",'Colbert=' + Colbert.length); Colbert[Colbert.length] = createMarker(new GPoint(-96.49510193,33.85869980),"
Ward Elementary School West
Po Box 310
Colbert, OK 74733

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Ward Elementary School West",'Colbert=' + Colbert.length); Durant[Durant.length] = createMarker(new GPoint(-96.38241577,33.99890137),"
Washington Irving Elementary School
812 W Locust St
Durant, OK 74701

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Washington Irving Elementary School",'Durant=' + Durant.length); Achille[Achille.length] = createMarker(new GPoint(-96.38690186,33.83330154),"
Yuba Elementary School
Po Box 280
Achille, OK 74720

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Yuba Elementary School",'Achille=' + Achille.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(Achille); map.removeOverlays(Bennington); map.removeOverlays(Bokchito); map.removeOverlays(Caddo); map.removeOverlays(Calera); map.removeOverlays(Colbert); map.removeOverlays(Durant); 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(Achille);map.removeOverlays(Achille); map.removeOverlays(Bennington); map.removeOverlays(Bokchito); map.removeOverlays(Caddo); map.removeOverlays(Calera); map.removeOverlays(Colbert); map.removeOverlays(Durant); map.addOverlays(Achille); centerByArray(Achille, false, false); cntMarker += Achille.length; map.addOverlays(Bennington); centerByArray(Bennington, false, false); cntMarker += Bennington.length; map.addOverlays(Bokchito); centerByArray(Bokchito, false, false); cntMarker += Bokchito.length; map.addOverlays(Caddo); centerByArray(Caddo, false, false); cntMarker += Caddo.length; map.addOverlays(Calera); centerByArray(Calera, false, false); cntMarker += Calera.length; map.addOverlays(Colbert); centerByArray(Colbert, false, false); cntMarker += Colbert.length; map.addOverlays(Durant); centerByArray(Durant, false, false); cntMarker += Durant.length; centerByArray(Achille,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'); } }