function addMarkers() { mySelect = document.getElementById('selection'); Abingdon = [];Galesburg = [];Knoxville = [];Oneida = [];Altona = [];Wataga = [];East_Galesburg = [];Rio = [];Victoria = [];Williamsfield = [];Yates_City = [];mySelect.options[mySelect.options.length] = new Option("Abingdon schools",'all=Abingdon'); mySelect.options[mySelect.options.length] = new Option("Altona schools",'all=Altona'); mySelect.options[mySelect.options.length] = new Option("East Galesburg schools",'all=East_Galesburg'); mySelect.options[mySelect.options.length] = new Option("Galesburg schools",'all=Galesburg'); mySelect.options[mySelect.options.length] = new Option("Knoxville schools",'all=Knoxville'); mySelect.options[mySelect.options.length] = new Option("Oneida schools",'all=Oneida'); mySelect.options[mySelect.options.length] = new Option("Rio schools",'all=Rio'); mySelect.options[mySelect.options.length] = new Option("Victoria schools",'all=Victoria'); mySelect.options[mySelect.options.length] = new Option("Wataga schools",'all=Wataga'); mySelect.options[mySelect.options.length] = new Option("Williamsfield schools",'all=Williamsfield'); mySelect.options[mySelect.options.length] = new Option("Yates City schools",'all=Yates_City'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Abingdon[Abingdon.length] = createMarker(new GPoint(-90.40557861,40.80149841),"
",iconGr); mySelect.options[mySelect.options.length] = new Option("Abingdon High School",'Abingdon=' + Abingdon.length); Abingdon[Abingdon.length] = createMarker(new GPoint(-90.40030670,40.79966354),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Abingdon Middle School",'Abingdon=' + Abingdon.length); Galesburg[Galesburg.length] = createMarker(new GPoint(-90.37841797,40.95808792),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Churchill Junior High School",'Galesburg=' + Galesburg.length); Galesburg[Galesburg.length] = createMarker(new GPoint(-90.38351440,40.93695450),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cooke School",'Galesburg=' + Galesburg.length); Galesburg[Galesburg.length] = createMarker(new GPoint(-90.39072418,40.96613693),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Gale School",'Galesburg=' + Galesburg.length); Galesburg[Galesburg.length] = createMarker(new GPoint(-90.38867950,40.96263885),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Galesburg Area Voc Center",'Galesburg=' + Galesburg.length); Galesburg[Galesburg.length] = createMarker(new GPoint(-90.38867950,40.96263885),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Galesburg High School",'Galesburg=' + Galesburg.length); Abingdon[Abingdon.length] = createMarker(new GPoint(-90.40319061,40.80543518),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hedding Grade School",'Abingdon=' + Abingdon.length); Galesburg[Galesburg.length] = createMarker(new GPoint(-90.37110138,40.94770050),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Hill Correctional Center",'Galesburg=' + Galesburg.length); Galesburg[Galesburg.length] = createMarker(new GPoint(-90.34587860,40.93381500),"",iconRd); mySelect.options[mySelect.options.length] = new Option("King School",'Galesburg=' + Galesburg.length); Galesburg[Galesburg.length] = createMarker(new GPoint(-90.35744900,40.94556700),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Knox County Academy",'Galesburg=' + Galesburg.length); Knoxville[Knoxville.length] = createMarker(new GPoint(-90.27449799,40.90513611),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Knoxville Junior High School",'Knoxville=' + Knoxville.length); Knoxville[Knoxville.length] = createMarker(new GPoint(-90.27621460,40.90786362),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Knoxville Senior High School",'Knoxville=' + Knoxville.length); Galesburg[Galesburg.length] = createMarker(new GPoint(-90.35278320,40.95764160),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Galesburg=' + Galesburg.length); Galesburg[Galesburg.length] = createMarker(new GPoint(-90.36465900,40.94691500),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Lombard Junior High School",'Galesburg=' + Galesburg.length); Knoxville[Knoxville.length] = createMarker(new GPoint(-90.27897644,40.90196228),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mable Woolsey Elementary School",'Knoxville=' + Knoxville.length); Galesburg[Galesburg.length] = createMarker(new GPoint(-90.34501648,40.95381546),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Nielson Elementary School",'Galesburg=' + Galesburg.length); Galesburg[Galesburg.length] = createMarker(new GPoint(-90.36516571,40.94736481),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Off Campus School",'Galesburg=' + Galesburg.length); Galesburg[Galesburg.length] = createMarker(new GPoint(-90.34525299,40.94426727),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Phoenix Program High School",'Galesburg=' + Galesburg.length); Oneida[Oneida.length] = createMarker(new GPoint(-90.22969818,41.07289886),"",iconRd); mySelect.options[mySelect.options.length] = new Option("R O W V A Central Elementary School",'Oneida=' + Oneida.length); Altona[Altona.length] = createMarker(new GPoint(-90.15509796,41.11529922),"",iconRd); mySelect.options[mySelect.options.length] = new Option("R O W V A East Elementary School",'Altona=' + Altona.length); Oneida[Oneida.length] = createMarker(new GPoint(-90.22969818,41.07289886),"",iconBl); mySelect.options[mySelect.options.length] = new Option("R O W V A Junior High School",'Oneida=' + Oneida.length); Oneida[Oneida.length] = createMarker(new GPoint(-90.22969818,41.07289886),"",iconGr); mySelect.options[mySelect.options.length] = new Option("R O W V A Senior High School",'Oneida=' + Oneida.length); Wataga[Wataga.length] = createMarker(new GPoint(-90.28690338,41.02259827),"",iconRd); mySelect.options[mySelect.options.length] = new Option("R O W V A West Elementary School",'Wataga=' + Wataga.length); East_Galesburg[East_Galesburg.length] = createMarker(new GPoint(-90.31340027,40.94770050),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Raymond R Marquith Elementary School",'East_Galesburg=' + East_Galesburg.length); Rio[Rio.length] = createMarker(new GPoint(-90.38680267,41.08589935),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Rio Elementary School",'Rio=' + Rio.length); Galesburg[Galesburg.length] = createMarker(new GPoint(-90.36350250,40.96228409),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Silas Willard Elementary School",'Galesburg=' + Galesburg.length); Galesburg[Galesburg.length] = createMarker(new GPoint(-90.39399719,40.94756317),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Steele School",'Galesburg=' + Galesburg.length); Galesburg[Galesburg.length] = createMarker(new GPoint(-90.38763428,40.95106125),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Stone Early Education Center",'Galesburg=' + Galesburg.length); Victoria[Victoria.length] = createMarker(new GPoint(-90.08049774,41.02059937),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Victoria Elementary School",'Victoria=' + Victoria.length); Williamsfield[Williamsfield.length] = createMarker(new GPoint(-90.03179932,40.91450119),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Williamsfield Elementary School",'Williamsfield=' + Williamsfield.length); Williamsfield[Williamsfield.length] = createMarker(new GPoint(-90.03179932,40.91450119),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Williamsfield High School",'Williamsfield=' + Williamsfield.length); Williamsfield[Williamsfield.length] = createMarker(new GPoint(-90.03179932,40.91450119),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Williamsfield Middle School",'Williamsfield=' + Williamsfield.length); Yates_City[Yates_City.length] = createMarker(new GPoint(-90.02590179,40.77989960),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Yates City Elementary School",'Yates_City=' + Yates_City.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(Abingdon); map.removeOverlays(Altona); map.removeOverlays(East_Galesburg); map.removeOverlays(Galesburg); map.removeOverlays(Knoxville); map.removeOverlays(Oneida); map.removeOverlays(Rio); map.removeOverlays(Victoria); map.removeOverlays(Wataga); map.removeOverlays(Williamsfield); map.removeOverlays(Yates_City); 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(Abingdon);map.removeOverlays(Abingdon); map.removeOverlays(Altona); map.removeOverlays(East_Galesburg); map.removeOverlays(Galesburg); map.removeOverlays(Knoxville); map.removeOverlays(Oneida); map.removeOverlays(Rio); map.removeOverlays(Victoria); map.removeOverlays(Wataga); map.removeOverlays(Williamsfield); map.removeOverlays(Yates_City); map.addOverlays(Abingdon); centerByArray(Abingdon, false, false); cntMarker += Abingdon.length; map.addOverlays(Altona); centerByArray(Altona, false, false); cntMarker += Altona.length; map.addOverlays(East_Galesburg); centerByArray(East_Galesburg, false, false); cntMarker += East_Galesburg.length; map.addOverlays(Galesburg); centerByArray(Galesburg, false, false); cntMarker += Galesburg.length; map.addOverlays(Knoxville); centerByArray(Knoxville, false, false); cntMarker += Knoxville.length; map.addOverlays(Oneida); centerByArray(Oneida, false, false); cntMarker += Oneida.length; map.addOverlays(Rio); centerByArray(Rio, false, false); cntMarker += Rio.length; map.addOverlays(Victoria); centerByArray(Victoria, false, false); cntMarker += Victoria.length; map.addOverlays(Wataga); centerByArray(Wataga, false, false); cntMarker += Wataga.length; map.addOverlays(Williamsfield); centerByArray(Williamsfield, false, false); cntMarker += Williamsfield.length; map.addOverlays(Yates_City); centerByArray(Yates_City, false, false); cntMarker += Yates_City.length; centerByArray(Abingdon,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'); } }