function addMarkers() { mySelect = document.getElementById('selection'); Agra = [];Carney = [];Chandler = [];Davenport = [];Meeker = [];Stroud = [];Prague = [];Wellston = [];Mcloud = [];mySelect.options[mySelect.options.length] = new Option("Agra schools",'all=Agra'); mySelect.options[mySelect.options.length] = new Option("Carney schools",'all=Carney'); mySelect.options[mySelect.options.length] = new Option("Chandler schools",'all=Chandler'); mySelect.options[mySelect.options.length] = new Option("Davenport schools",'all=Davenport'); mySelect.options[mySelect.options.length] = new Option("Mcloud schools",'all=Mcloud'); mySelect.options[mySelect.options.length] = new Option("Meeker schools",'all=Meeker'); mySelect.options[mySelect.options.length] = new Option("Prague schools",'all=Prague'); mySelect.options[mySelect.options.length] = new Option("Stroud schools",'all=Stroud'); mySelect.options[mySelect.options.length] = new Option("Wellston schools",'all=Wellston'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Agra[Agra.length] = createMarker(new GPoint(-96.87079620,35.88389969),"
Agra Elementary School
Po Box 279
Agra, OK 74824

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Agra Elementary School",'Agra=' + Agra.length); Agra[Agra.length] = createMarker(new GPoint(-96.87079620,35.88389969),"
Agra High School
Po Box 279
Agra, OK 74824

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Agra High School",'Agra=' + Agra.length); Carney[Carney.length] = createMarker(new GPoint(-97.01059723,35.80120087),"
Carney Elementary School
Po Box 240
Carney, OK 74832

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Carney Elementary School",'Carney=' + Carney.length); Carney[Carney.length] = createMarker(new GPoint(-97.01059723,35.80120087),"
Carney High School
Po Box 240
Carney, OK 74832

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Carney High School",'Carney=' + Carney.length); Chandler[Chandler.length] = createMarker(new GPoint(-96.88227081,35.70553970),"
Chandler High School
901 S Chs St
Chandler, OK 74834

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Chandler High School",'Chandler=' + Chandler.length); Chandler[Chandler.length] = createMarker(new GPoint(-96.88227081,35.70553970),"
Chandler Junior High School
901 S Chs St
Chandler, OK 74834

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Chandler Junior High School",'Chandler=' + Chandler.length); Davenport[Davenport.length] = createMarker(new GPoint(-96.76490021,35.70809937),"
Davenport Elementary School
Po Box 849
Davenport, OK 74026

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Davenport Elementary School",'Davenport=' + Davenport.length); Davenport[Davenport.length] = createMarker(new GPoint(-96.76490021,35.70809937),"
Davenport High School
Po Box 849
Davenport, OK 74026

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Davenport High School",'Davenport=' + Davenport.length); Chandler[Chandler.length] = createMarker(new GPoint(-96.88227081,35.70553970),"
East Side Elementary School
901 S Chs St
Chandler, OK 74834

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("East Side Elementary School",'Chandler=' + Chandler.length); Meeker[Meeker.length] = createMarker(new GPoint(-96.97709656,35.52590179),"
Meeker Elementary School
214 E Carl Hubbell Blvd
Meeker, OK 74855

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Meeker Elementary School",'Meeker=' + Meeker.length); Meeker[Meeker.length] = createMarker(new GPoint(-96.97709656,35.52590179),"
Meeker High School
214 E Carl Hubbell Blvd
Meeker, OK 74855

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Meeker High School",'Meeker=' + Meeker.length); Meeker[Meeker.length] = createMarker(new GPoint(-96.97709656,35.52590179),"
Meeker Middle School
214 E Carl Hubbell Blvd
Meeker, OK 74855

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Meeker Middle School",'Meeker=' + Meeker.length); Chandler[Chandler.length] = createMarker(new GPoint(-96.88227081,35.70553970),"
Park Road Elementary School
901 S Chs St
Chandler, OK 74834

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Park Road Elementary School",'Chandler=' + Chandler.length); Stroud[Stroud.length] = createMarker(new GPoint(-96.68340302,35.77759933),"
Parkview Elementary School
212 W 7th St
Stroud, OK 74079

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Parkview Elementary School",'Stroud=' + Stroud.length); Prague[Prague.length] = createMarker(new GPoint(-96.69180298,35.48970032),"
Prague Elementary School
3504 Nbu
Prague, OK 74864

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Prague Elementary School",'Prague=' + Prague.length); Prague[Prague.length] = createMarker(new GPoint(-96.69180298,35.48970032),"
Prague High School
3504 Nbu
Prague, OK 74864

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Prague High School",'Prague=' + Prague.length); Prague[Prague.length] = createMarker(new GPoint(-96.69180298,35.48970032),"
Prague Middle School
3504 Nbu
Prague, OK 74864

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Prague Middle School",'Prague=' + Prague.length); Stroud[Stroud.length] = createMarker(new GPoint(-96.68340302,35.77759933),"
Stroud High School
212 W 7th St
Stroud, OK 74079

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Stroud High School",'Stroud=' + Stroud.length); Stroud[Stroud.length] = createMarker(new GPoint(-96.68340302,35.77759933),"
Stroud Middle School
212 W 7th St
Stroud, OK 74079

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Stroud Middle School",'Stroud=' + Stroud.length); Wellston[Wellston.length] = createMarker(new GPoint(-97.05059814,35.68069839),"
Wellston Elementary School
Po Box 60
Wellston, OK 74881

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Wellston Elementary School",'Wellston=' + Wellston.length); Wellston[Wellston.length] = createMarker(new GPoint(-97.05059814,35.68069839),"
Wellston High School
Po Box 60
Wellston, OK 74881

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Wellston High School",'Wellston=' + Wellston.length); Wellston[Wellston.length] = createMarker(new GPoint(-97.05059814,35.68069839),"
Wellston Middle School
Po Box 60
Wellston, OK 74881

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Wellston Middle School",'Wellston=' + Wellston.length); Mcloud[Mcloud.length] = createMarker(new GPoint(-97.12449646,35.30329895),"
White Rock Elementary School
Rr 2 Box 325
Mcloud, OK 74851

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("White Rock Elementary School",'Mcloud=' + Mcloud.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(Agra); map.removeOverlays(Carney); map.removeOverlays(Chandler); map.removeOverlays(Davenport); map.removeOverlays(Mcloud); map.removeOverlays(Meeker); map.removeOverlays(Prague); map.removeOverlays(Stroud); map.removeOverlays(Wellston); 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(Agra);map.removeOverlays(Agra); map.removeOverlays(Carney); map.removeOverlays(Chandler); map.removeOverlays(Davenport); map.removeOverlays(Mcloud); map.removeOverlays(Meeker); map.removeOverlays(Prague); map.removeOverlays(Stroud); map.removeOverlays(Wellston); map.addOverlays(Agra); centerByArray(Agra, false, false); cntMarker += Agra.length; map.addOverlays(Carney); centerByArray(Carney, false, false); cntMarker += Carney.length; map.addOverlays(Chandler); centerByArray(Chandler, false, false); cntMarker += Chandler.length; map.addOverlays(Davenport); centerByArray(Davenport, false, false); cntMarker += Davenport.length; map.addOverlays(Mcloud); centerByArray(Mcloud, false, false); cntMarker += Mcloud.length; map.addOverlays(Meeker); centerByArray(Meeker, false, false); cntMarker += Meeker.length; map.addOverlays(Prague); centerByArray(Prague, false, false); cntMarker += Prague.length; map.addOverlays(Stroud); centerByArray(Stroud, false, false); cntMarker += Stroud.length; map.addOverlays(Wellston); centerByArray(Wellston, false, false); cntMarker += Wellston.length; centerByArray(Agra,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'); } }