function addMarkers() { mySelect = document.getElementById('selection'); Altus = [];Blair = [];Duke = [];Eldorado = [];Olustee = [];mySelect.options[mySelect.options.length] = new Option("Altus schools",'all=Altus'); mySelect.options[mySelect.options.length] = new Option("Blair schools",'all=Blair'); mySelect.options[mySelect.options.length] = new Option("Duke schools",'all=Duke'); mySelect.options[mySelect.options.length] = new Option("Eldorado schools",'all=Eldorado'); mySelect.options[mySelect.options.length] = new Option("Olustee schools",'all=Olustee'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Altus[Altus.length] = createMarker(new GPoint(-99.31956482,34.64123917),"
Altus High School
400 N Park Ave
Altus, OK 73521

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Altus High School",'Altus=' + Altus.length); Altus[Altus.length] = createMarker(new GPoint(-99.31632996,34.62406158),"
Altus Jhs
1600 S Park Ln
Altus, OK 73521

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Altus Jhs",'Altus=' + Altus.length); Altus[Altus.length] = createMarker(new GPoint(-99.32496643,34.64977264),"
Altus Middle School
1221 N Howse St
Altus, OK 73521

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Altus Middle School",'Altus=' + Altus.length); Blair[Blair.length] = createMarker(new GPoint(-99.34259796,34.78060150),"
Blair Elementary School
Po Box 428
Blair, OK 73526

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Blair Elementary School",'Blair=' + Blair.length); Blair[Blair.length] = createMarker(new GPoint(-99.34259796,34.78060150),"
Blair High School
Po Box 428
Blair, OK 73526

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Blair High School",'Blair=' + Blair.length); Duke[Duke.length] = createMarker(new GPoint(-99.55000305,34.66310120),"
Duke Elementary School
Po Box 160
Duke, OK 73532

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Duke Elementary School",'Duke=' + Duke.length); Duke[Duke.length] = createMarker(new GPoint(-99.55000305,34.66310120),"
Duke High School
Po Box 160
Duke, OK 73532

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Duke High School",'Duke=' + Duke.length); Eldorado[Eldorado.length] = createMarker(new GPoint(-99.61689758,34.46780014),"
Eldorado Elementary School
Po Box J
Eldorado, OK 73537

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Eldorado Elementary School",'Eldorado=' + Eldorado.length); Eldorado[Eldorado.length] = createMarker(new GPoint(-99.61689758,34.46780014),"
Eldorado High School
Po Box J
Eldorado, OK 73537

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Eldorado High School",'Eldorado=' + Eldorado.length); Altus[Altus.length] = createMarker(new GPoint(-99.32313538,34.63534546),"
Eugene Field Elementary School
314 S Forrest St
Altus, OK 73521

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Eugene Field Elementary School",'Altus=' + Altus.length); Altus[Altus.length] = createMarker(new GPoint(-99.32479858,34.65019989),"
Navajo Elementary School
15695 S County Rd 210
Altus, OK 73521

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Navajo Elementary School",'Altus=' + Altus.length); Altus[Altus.length] = createMarker(new GPoint(-99.32479858,34.65019989),"
Navajo High School
15695 S County Rd 210
Altus, OK 73521

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Navajo High School",'Altus=' + Altus.length); Altus[Altus.length] = createMarker(new GPoint(-99.32479858,34.65019989),"
Navajo Junior High School
15695 S County Rd 210
Altus, OK 73521

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Navajo Junior High School",'Altus=' + Altus.length); Olustee[Olustee.length] = createMarker(new GPoint(-99.47740173,34.55300140),"
Olustee Elementary School
Po Box 70
Olustee, OK 73560

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Olustee Elementary School",'Olustee=' + Olustee.length); Olustee[Olustee.length] = createMarker(new GPoint(-99.47740173,34.55300140),"
Olustee High School
Po Box 70
Olustee, OK 73560

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Olustee High School",'Olustee=' + Olustee.length); Altus[Altus.length] = createMarker(new GPoint(-99.29869080,34.67066193),"
Rivers Elementary School
3000 N Veterans Dr
Altus, OK 73522

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Rivers Elementary School",'Altus=' + Altus.length); Altus[Altus.length] = createMarker(new GPoint(-99.32196045,34.62594223),"
Roosevelt Elementary School
1200 Glenda St
Altus, OK 73521

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Roosevelt Elementary School",'Altus=' + Altus.length); Altus[Altus.length] = createMarker(new GPoint(-99.34103394,34.65827179),"
Sunset Elementary School
1830 Sunset Dr
Altus, OK 73521

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Sunset Elementary School",'Altus=' + Altus.length); Altus[Altus.length] = createMarker(new GPoint(-99.33101654,34.64013672),"
Washington Elementary School
311 E Cypress St
Altus, OK 73521

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Washington Elementary School",'Altus=' + Altus.length); Altus[Altus.length] = createMarker(new GPoint(-99.32341766,34.64852524),"
Will Rogers Elementary School
1100 N Forrest St
Altus, OK 73521

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Will Rogers Elementary School",'Altus=' + Altus.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(Altus); map.removeOverlays(Blair); map.removeOverlays(Duke); map.removeOverlays(Eldorado); map.removeOverlays(Olustee); 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(Altus);map.removeOverlays(Altus); map.removeOverlays(Blair); map.removeOverlays(Duke); map.removeOverlays(Eldorado); map.removeOverlays(Olustee); map.addOverlays(Altus); centerByArray(Altus, false, false); cntMarker += Altus.length; map.addOverlays(Blair); centerByArray(Blair, false, false); cntMarker += Blair.length; map.addOverlays(Duke); centerByArray(Duke, false, false); cntMarker += Duke.length; map.addOverlays(Eldorado); centerByArray(Eldorado, false, false); cntMarker += Eldorado.length; map.addOverlays(Olustee); centerByArray(Olustee, false, false); cntMarker += Olustee.length; centerByArray(Altus,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'); } }