function addMarkers() { mySelect = document.getElementById('selection'); Andover = [];Augusta = [];Benton = [];Leon = [];Towanda = [];Douglass = [];El_Dorado = [];Rosalia = [];Cassoday = [];Whitewater = [];Potwin = [];Rose_Hill = [];mySelect.options[mySelect.options.length] = new Option("Andover schools",'all=Andover'); mySelect.options[mySelect.options.length] = new Option("Augusta schools",'all=Augusta'); mySelect.options[mySelect.options.length] = new Option("Benton schools",'all=Benton'); mySelect.options[mySelect.options.length] = new Option("Cassoday schools",'all=Cassoday'); mySelect.options[mySelect.options.length] = new Option("Douglass schools",'all=Douglass'); mySelect.options[mySelect.options.length] = new Option("El Dorado schools",'all=El_Dorado'); mySelect.options[mySelect.options.length] = new Option("Leon schools",'all=Leon'); mySelect.options[mySelect.options.length] = new Option("Potwin schools",'all=Potwin'); mySelect.options[mySelect.options.length] = new Option("Rosalia schools",'all=Rosalia'); mySelect.options[mySelect.options.length] = new Option("Rose Hill schools",'all=Rose_Hill'); mySelect.options[mySelect.options.length] = new Option("Towanda schools",'all=Towanda'); mySelect.options[mySelect.options.length] = new Option("Whitewater schools",'all=Whitewater'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Andover[Andover.length] = createMarker(new GPoint(-97.12577057,37.69386292),"
",iconGr); mySelect.options[mySelect.options.length] = new Option("Andover Central High School",'Andover=' + Andover.length); Andover[Andover.length] = createMarker(new GPoint(-97.12532043,37.69386292),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Andover Central Middle School",'Andover=' + Andover.length); Andover[Andover.length] = createMarker(new GPoint(-97.13492584,37.71706772),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Andover High School",'Andover=' + Andover.length); Andover[Andover.length] = createMarker(new GPoint(-97.13492584,37.71460342),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Andover Middle School",'Andover=' + Andover.length); Augusta[Augusta.length] = createMarker(new GPoint(-96.97907257,37.68343735),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Augusta Middle School",'Augusta=' + Augusta.length); Augusta[Augusta.length] = createMarker(new GPoint(-96.97122955,37.69524384),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Augusta Senior High School",'Augusta=' + Augusta.length); Benton[Benton.length] = createMarker(new GPoint(-97.10330200,37.80989838),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Benton Elementary School",'Benton=' + Benton.length); Leon[Leon.length] = createMarker(new GPoint(-96.70300293,37.68000031),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Bluestem High School",'Leon=' + Leon.length); Leon[Leon.length] = createMarker(new GPoint(-96.78667450,37.68424606),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Bluestem Middle School",'Leon=' + Leon.length); Augusta[Augusta.length] = createMarker(new GPoint(-96.88037872,37.69241714),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bluestem-haverhill Elementary School",'Augusta=' + Augusta.length); Leon[Leon.length] = createMarker(new GPoint(-96.78667450,37.68468475),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bluestem-leon Elementary School",'Leon=' + Leon.length); Towanda[Towanda.length] = createMarker(new GPoint(-96.99707794,37.79612732),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Circle High School",'Towanda=' + Towanda.length); Benton[Benton.length] = createMarker(new GPoint(-97.15309906,37.80329895),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Circle Middle School",'Benton=' + Benton.length); Andover[Andover.length] = createMarker(new GPoint(-97.13526917,37.71711349),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cottonwood Elementary School",'Andover=' + Andover.length); Douglass[Douglass.length] = createMarker(new GPoint(-97.00090027,37.51739883),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Douglass High School",'Douglass=' + Douglass.length); El_Dorado[El_Dorado.length] = createMarker(new GPoint(-96.85006600,37.81742200),"",iconGr); mySelect.options[mySelect.options.length] = new Option("E-cats",'El_Dorado=' + El_Dorado.length); El_Dorado[El_Dorado.length] = createMarker(new GPoint(-96.84079742,37.83269882),"",iconGr); mySelect.options[mySelect.options.length] = new Option("El Dorado High School",'El_Dorado=' + El_Dorado.length); El_Dorado[El_Dorado.length] = createMarker(new GPoint(-96.85546875,37.81753540),"",iconBl); mySelect.options[mySelect.options.length] = new Option("El Dorado Middle School",'El_Dorado=' + El_Dorado.length); Augusta[Augusta.length] = createMarker(new GPoint(-96.96418762,37.69891739),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Ewalt Elementary School",'Augusta=' + Augusta.length); Rosalia[Rosalia.length] = createMarker(new GPoint(-96.59259796,37.77980042),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Flinthills Intermediate School",'Rosalia=' + Rosalia.length); Rosalia[Rosalia.length] = createMarker(new GPoint(-96.59259796,37.77980042),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Flinthills Middle School-high School",'Rosalia=' + Rosalia.length); Cassoday[Cassoday.length] = createMarker(new GPoint(-96.63916016,38.04010010),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Flinthills Primary School",'Cassoday=' + Cassoday.length); Whitewater[Whitewater.length] = createMarker(new GPoint(-97.09732819,37.95407486),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Frederic Remington High School",'Whitewater=' + Whitewater.length); Augusta[Augusta.length] = createMarker(new GPoint(-96.97840881,37.68432617),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Garfield Elementary School",'Augusta=' + Augusta.length); El_Dorado[El_Dorado.length] = createMarker(new GPoint(-96.84297180,37.83273697),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Grandview Elementary School",'El_Dorado=' + El_Dorado.length); El_Dorado[El_Dorado.length] = createMarker(new GPoint(-96.86551666,37.82113647),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'El_Dorado=' + El_Dorado.length); Douglass[Douglass.length] = createMarker(new GPoint(-97.00090027,37.51739883),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Leonard C Seal Elementary School",'Douglass=' + Douglass.length); El_Dorado[El_Dorado.length] = createMarker(new GPoint(-96.85568237,37.82343674),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'El_Dorado=' + El_Dorado.length); Augusta[Augusta.length] = createMarker(new GPoint(-96.97396851,37.69274521),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Augusta=' + Augusta.length); Douglass[Douglass.length] = createMarker(new GPoint(-97.00090027,37.51739883),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Marvin Sisk Middle School",'Douglass=' + Douglass.length); Andover[Andover.length] = createMarker(new GPoint(-97.13647461,37.71056747),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Meadowlark Elementary School",'Andover=' + Andover.length); El_Dorado[El_Dorado.length] = createMarker(new GPoint(-96.89035034,37.82513046),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Oil Hill Elementary School",'El_Dorado=' + El_Dorado.length); Potwin[Potwin.length] = createMarker(new GPoint(-96.99069977,37.97689819),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Remington Elementary At Potwin",'Potwin=' + Potwin.length); Whitewater[Whitewater.length] = createMarker(new GPoint(-97.11350250,37.96260071),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Remington Middle School",'Whitewater=' + Whitewater.length); Andover[Andover.length] = createMarker(new GPoint(-97.13647461,37.71060181),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Robert M. Martin Elementary School",'Andover=' + Andover.length); Augusta[Augusta.length] = createMarker(new GPoint(-96.98236847,37.68834686),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Robinson Elementary School",'Augusta=' + Augusta.length); Rose_Hill[Rose_Hill.length] = createMarker(new GPoint(-97.13525391,37.55970764),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Rose Hill High School",'Rose_Hill=' + Rose_Hill.length); Rose_Hill[Rose_Hill.length] = createMarker(new GPoint(-97.13525391,37.55970764),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Rose Hill Intermediate",'Rose_Hill=' + Rose_Hill.length); Rose_Hill[Rose_Hill.length] = createMarker(new GPoint(-97.13525391,37.55970764),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Rose Hill Middle School",'Rose_Hill=' + Rose_Hill.length); Rose_Hill[Rose_Hill.length] = createMarker(new GPoint(-97.13525391,37.55970764),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Rose Hill Primary",'Rose_Hill=' + Rose_Hill.length); El_Dorado[El_Dorado.length] = createMarker(new GPoint(-96.86827087,37.80996323),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Skelly Elementary School",'El_Dorado=' + El_Dorado.length); Andover[Andover.length] = createMarker(new GPoint(-97.12516022,37.68664169),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sunflower Elementary School",'Andover=' + Andover.length); Towanda[Towanda.length] = createMarker(new GPoint(-97.00040436,37.79721069),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Towanda Elementary School",'Towanda=' + Towanda.length); El_Dorado[El_Dorado.length] = createMarker(new GPoint(-96.85802460,37.81175613),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Washington Elementary School",'El_Dorado=' + El_Dorado.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(Andover); map.removeOverlays(Augusta); map.removeOverlays(Benton); map.removeOverlays(Cassoday); map.removeOverlays(Douglass); map.removeOverlays(El_Dorado); map.removeOverlays(Leon); map.removeOverlays(Potwin); map.removeOverlays(Rosalia); map.removeOverlays(Rose_Hill); map.removeOverlays(Towanda); map.removeOverlays(Whitewater); 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(Andover);map.removeOverlays(Andover); map.removeOverlays(Augusta); map.removeOverlays(Benton); map.removeOverlays(Cassoday); map.removeOverlays(Douglass); map.removeOverlays(El_Dorado); map.removeOverlays(Leon); map.removeOverlays(Potwin); map.removeOverlays(Rosalia); map.removeOverlays(Rose_Hill); map.removeOverlays(Towanda); map.removeOverlays(Whitewater); map.addOverlays(Andover); centerByArray(Andover, false, false); cntMarker += Andover.length; map.addOverlays(Augusta); centerByArray(Augusta, false, false); cntMarker += Augusta.length; map.addOverlays(Benton); centerByArray(Benton, false, false); cntMarker += Benton.length; map.addOverlays(Cassoday); centerByArray(Cassoday, false, false); cntMarker += Cassoday.length; map.addOverlays(Douglass); centerByArray(Douglass, false, false); cntMarker += Douglass.length; map.addOverlays(El_Dorado); centerByArray(El_Dorado, false, false); cntMarker += El_Dorado.length; map.addOverlays(Leon); centerByArray(Leon, false, false); cntMarker += Leon.length; map.addOverlays(Potwin); centerByArray(Potwin, false, false); cntMarker += Potwin.length; map.addOverlays(Rosalia); centerByArray(Rosalia, false, false); cntMarker += Rosalia.length; map.addOverlays(Rose_Hill); centerByArray(Rose_Hill, false, false); cntMarker += Rose_Hill.length; map.addOverlays(Towanda); centerByArray(Towanda, false, false); cntMarker += Towanda.length; map.addOverlays(Whitewater); centerByArray(Whitewater, false, false); cntMarker += Whitewater.length; centerByArray(Andover,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'); } }