function addMarkers() { mySelect = document.getElementById('selection'); Xenia = [];Fairborn = [];Beavercreek = [];Bellbrook = [];Cedarville = [];Jamestown = [];Yellow_Springs = [];mySelect.options[mySelect.options.length] = new Option("Beavercreek schools",'all=Beavercreek'); mySelect.options[mySelect.options.length] = new Option("Bellbrook schools",'all=Bellbrook'); mySelect.options[mySelect.options.length] = new Option("Cedarville schools",'all=Cedarville'); mySelect.options[mySelect.options.length] = new Option("Fairborn schools",'all=Fairborn'); mySelect.options[mySelect.options.length] = new Option("Jamestown schools",'all=Jamestown'); mySelect.options[mySelect.options.length] = new Option("Xenia schools",'all=Xenia'); mySelect.options[mySelect.options.length] = new Option("Yellow Springs schools",'all=Yellow_Springs'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Xenia[Xenia.length] = createMarker(new GPoint(-83.95820618,39.67556000),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Arrowood Elementary School",'Xenia=' + Xenia.length); Fairborn[Fairborn.length] = createMarker(new GPoint(-84.01365662,39.82754898),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Baker Junior High School",'Fairborn=' + Fairborn.length); Beavercreek[Beavercreek.length] = createMarker(new GPoint(-84.03238678,39.71898651),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Beavercreek High School",'Beavercreek=' + Beavercreek.length); Bellbrook[Bellbrook.length] = createMarker(new GPoint(-84.06941223,39.65161133),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Bell Creek Elementary School",'Bellbrook=' + Bellbrook.length); Bellbrook[Bellbrook.length] = createMarker(new GPoint(-84.06924438,39.65374756),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Bellbrook High School",'Bellbrook=' + Bellbrook.length); Bellbrook[Bellbrook.length] = createMarker(new GPoint(-84.06954193,39.64989471),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Bellbrook Junior High School",'Bellbrook=' + Bellbrook.length); Fairborn[Fairborn.length] = createMarker(new GPoint(-83.98833466,39.83086014),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Black Lane Elementary School",'Fairborn=' + Fairborn.length); Cedarville[Cedarville.length] = createMarker(new GPoint(-83.79799652,39.74570084),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cedarville Elementary School",'Cedarville=' + Cedarville.length); Cedarville[Cedarville.length] = createMarker(new GPoint(-83.79799652,39.74570084),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Cedarville High School",'Cedarville=' + Cedarville.length); Xenia[Xenia.length] = createMarker(new GPoint(-83.92711639,39.69040680),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Central Middle School",'Xenia=' + Xenia.length); Xenia[Xenia.length] = createMarker(new GPoint(-83.94442749,39.68787003),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cox Elementary School",'Xenia=' + Xenia.length); Fairborn[Fairborn.length] = createMarker(new GPoint(-84.01353455,39.82835770),"",iconRd); mySelect.options[mySelect.options.length] = new Option("East Sixth School",'Fairborn=' + Fairborn.length); Fairborn[Fairborn.length] = createMarker(new GPoint(-84.02517700,39.81779861),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Fairborn Digital Academy",'Fairborn=' + Fairborn.length); Fairborn[Fairborn.length] = createMarker(new GPoint(-83.95919800,39.78971863),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Fairborn High School",'Fairborn=' + Fairborn.length); Fairborn[Fairborn.length] = createMarker(new GPoint(-84.01557159,39.80917740),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Fairborn Intermediate School",'Fairborn=' + Fairborn.length); Fairborn[Fairborn.length] = createMarker(new GPoint(-84.02635193,39.79256821),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Fairborn Primary School",'Fairborn=' + Fairborn.length); Beavercreek[Beavercreek.length] = createMarker(new GPoint(-84.06590271,39.69800186),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Fairbrook Elementary School",'Beavercreek=' + Beavercreek.length); Beavercreek[Beavercreek.length] = createMarker(new GPoint(-84.03365326,39.71948624),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Ferguson Middle School",'Beavercreek=' + Beavercreek.length); Xenia[Xenia.length] = createMarker(new GPoint(-83.94720459,39.76972580),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Greene County Career Center",'Xenia=' + Xenia.length); Jamestown[Jamestown.length] = createMarker(new GPoint(-83.75881195,39.65563583),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Greeneview High School",'Jamestown=' + Jamestown.length); Jamestown[Jamestown.length] = createMarker(new GPoint(-83.73474121,39.66326904),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Greeneview Intermediate School",'Jamestown=' + Jamestown.length); Jamestown[Jamestown.length] = createMarker(new GPoint(-83.69673157,39.72172546),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Greeneview North Elementary School",'Jamestown=' + Jamestown.length); Jamestown[Jamestown.length] = createMarker(new GPoint(-83.73464203,39.66304016),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Greeneview Primary School",'Jamestown=' + Jamestown.length); Jamestown[Jamestown.length] = createMarker(new GPoint(-83.72907257,39.58061981),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Greeneview South Elementary School",'Jamestown=' + Jamestown.length); Beavercreek[Beavercreek.length] = createMarker(new GPoint(-84.09051514,39.71417999),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Herman K Ankeney Middle School",'Beavercreek=' + Beavercreek.length); Beavercreek[Beavercreek.length] = createMarker(new GPoint(-84.04430389,39.72353745),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Main Elementary School",'Beavercreek=' + Beavercreek.length); Xenia[Xenia.length] = createMarker(new GPoint(-83.97040558,39.67148590),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mckinley Elementary School",'Xenia=' + Xenia.length); Yellow_Springs[Yellow_Springs.length] = createMarker(new GPoint(-83.89041138,39.80519104),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mills Lawn Elementary School",'Yellow_Springs=' + Yellow_Springs.length); Beavercreek[Beavercreek.length] = createMarker(new GPoint(-84.09834290,39.74456787),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Parkwood Elementary School",'Beavercreek=' + Beavercreek.length); Beavercreek[Beavercreek.length] = createMarker(new GPoint(-84.06404877,39.75602341),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Shaw Elementary School",'Beavercreek=' + Beavercreek.length); Xenia[Xenia.length] = createMarker(new GPoint(-83.92973328,39.69500351),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Shawnee Elementary School",'Xenia=' + Xenia.length); Xenia[Xenia.length] = createMarker(new GPoint(-83.94889069,39.68178558),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Simon Kenton Elementary School",'Xenia=' + Xenia.length); Xenia[Xenia.length] = createMarker(new GPoint(-83.92774200,39.67499161),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Spring Hill Elementary School",'Xenia=' + Xenia.length); Bellbrook[Bellbrook.length] = createMarker(new GPoint(-84.09386444,39.64080811),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Stephen Bell Elementary School",'Bellbrook=' + Bellbrook.length); Bellbrook[Bellbrook.length] = createMarker(new GPoint(-84.06932068,39.63454056),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sugarcreek Elementary School",'Bellbrook=' + Bellbrook.length); Xenia[Xenia.length] = createMarker(new GPoint(-83.93144226,39.67336273),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Summit Academy-xenia Elementary School",'Xenia=' + Xenia.length); Xenia[Xenia.length] = createMarker(new GPoint(-83.93441010,39.71369171),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Tecumseh Elementary School",'Xenia=' + Xenia.length); Beavercreek[Beavercreek.length] = createMarker(new GPoint(-84.07028961,39.71766663),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Valley Elementary School",'Beavercreek=' + Beavercreek.length); Xenia[Xenia.length] = createMarker(new GPoint(-83.95623016,39.67890549),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Warner Middle School",'Xenia=' + Xenia.length); Fairborn[Fairborn.length] = createMarker(new GPoint(-84.03272247,39.79018784),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wright Elementary School",'Fairborn=' + Fairborn.length); Xenia[Xenia.length] = createMarker(new GPoint(-83.92254639,39.71327972),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Xenia High School",'Xenia=' + Xenia.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(Beavercreek); map.removeOverlays(Bellbrook); map.removeOverlays(Cedarville); map.removeOverlays(Fairborn); map.removeOverlays(Jamestown); map.removeOverlays(Xenia); map.removeOverlays(Yellow_Springs); 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(Xenia);map.removeOverlays(Beavercreek); map.removeOverlays(Bellbrook); map.removeOverlays(Cedarville); map.removeOverlays(Fairborn); map.removeOverlays(Jamestown); map.removeOverlays(Xenia); map.removeOverlays(Yellow_Springs); map.addOverlays(Beavercreek); centerByArray(Beavercreek, false, false); cntMarker += Beavercreek.length; map.addOverlays(Bellbrook); centerByArray(Bellbrook, false, false); cntMarker += Bellbrook.length; map.addOverlays(Cedarville); centerByArray(Cedarville, false, false); cntMarker += Cedarville.length; map.addOverlays(Fairborn); centerByArray(Fairborn, false, false); cntMarker += Fairborn.length; map.addOverlays(Jamestown); centerByArray(Jamestown, false, false); cntMarker += Jamestown.length; map.addOverlays(Xenia); centerByArray(Xenia, false, false); cntMarker += Xenia.length; map.addOverlays(Yellow_Springs); centerByArray(Yellow_Springs, false, false); cntMarker += Yellow_Springs.length; centerByArray(Xenia,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'); } }