function addMarkers() { mySelect = document.getElementById('selection'); Dekalb = [];De_Kalb = [];Cortland = [];Genoa = [];Sandwich = [];Kirkland = [];Hinckley = [];Shabbona = [];Waterman = [];Somonauk = [];Kingston = [];Malta = [];Sycamore = [];mySelect.options[mySelect.options.length] = new Option("Cortland schools",'all=Cortland'); mySelect.options[mySelect.options.length] = new Option("De Kalb schools",'all=De_Kalb'); mySelect.options[mySelect.options.length] = new Option("Dekalb schools",'all=Dekalb'); mySelect.options[mySelect.options.length] = new Option("Genoa schools",'all=Genoa'); mySelect.options[mySelect.options.length] = new Option("Hinckley schools",'all=Hinckley'); mySelect.options[mySelect.options.length] = new Option("Kingston schools",'all=Kingston'); mySelect.options[mySelect.options.length] = new Option("Kirkland schools",'all=Kirkland'); mySelect.options[mySelect.options.length] = new Option("Malta schools",'all=Malta'); mySelect.options[mySelect.options.length] = new Option("Sandwich schools",'all=Sandwich'); mySelect.options[mySelect.options.length] = new Option("Shabbona schools",'all=Shabbona'); mySelect.options[mySelect.options.length] = new Option("Somonauk schools",'all=Somonauk'); mySelect.options[mySelect.options.length] = new Option("Sycamore schools",'all=Sycamore'); mySelect.options[mySelect.options.length] = new Option("Waterman schools",'all=Waterman'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Dekalb[Dekalb.length] = createMarker(new GPoint(-88.74537659,41.92322540),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Chesebro Elementary School",'Dekalb=' + Dekalb.length); De_Kalb[De_Kalb.length] = createMarker(new GPoint(-88.75166321,41.93492508),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Clinton Rosette Middle School",'De_Kalb=' + De_Kalb.length); Cortland[Cortland.length] = createMarker(new GPoint(-88.69130707,41.91876221),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cortland Elementary School",'Cortland=' + Cortland.length); Genoa[Genoa.length] = createMarker(new GPoint(-88.69276428,42.09963608),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Davenport Elementary School",'Genoa=' + Genoa.length); De_Kalb[De_Kalb.length] = createMarker(new GPoint(-88.75368500,41.91206741),"",iconGr); mySelect.options[mySelect.options.length] = new Option("De Kalb High School",'De_Kalb=' + De_Kalb.length); Genoa[Genoa.length] = createMarker(new GPoint(-88.68959808,42.09849930),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Genoa Elementary School",'Genoa=' + Genoa.length); Genoa[Genoa.length] = createMarker(new GPoint(-88.70389557,42.10092545),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Genoa-kingston High School",'Genoa=' + Genoa.length); Genoa[Genoa.length] = createMarker(new GPoint(-88.68511963,42.09304810),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Genoa-kingston Middle School",'Genoa=' + Genoa.length); De_Kalb[De_Kalb.length] = createMarker(new GPoint(-88.75184631,41.96713638),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Gwendolyn Brooks Elementary School",'De_Kalb=' + De_Kalb.length); Sandwich[Sandwich.length] = createMarker(new GPoint(-88.62011719,41.64202499),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Herman E Dummer Middle School",'Sandwich=' + Sandwich.length); Kirkland[Kirkland.length] = createMarker(new GPoint(-88.86689758,42.09740067),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hiawatha Elementary School",'Kirkland=' + Kirkland.length); Kirkland[Kirkland.length] = createMarker(new GPoint(-88.86689758,42.09740067),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Hiawatha Junior And Senior High School",'Kirkland=' + Kirkland.length); Hinckley[Hinckley.length] = createMarker(new GPoint(-88.64679718,41.77489853),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hinckley Elementary School",'Hinckley=' + Hinckley.length); Hinckley[Hinckley.length] = createMarker(new GPoint(-88.64679718,41.77489853),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Hinckley-big Rock High School",'Hinckley=' + Hinckley.length); Dekalb[Dekalb.length] = createMarker(new GPoint(-88.74877930,41.92134094),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Huntley Middle School",'Dekalb=' + Dekalb.length); Shabbona[Shabbona.length] = createMarker(new GPoint(-88.87691498,41.76365280),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Indian Creek High School",'Shabbona=' + Shabbona.length); Waterman[Waterman.length] = createMarker(new GPoint(-88.77397919,41.76486969),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Indian Creek Middle School",'Waterman=' + Waterman.length); Sandwich[Sandwich.length] = createMarker(new GPoint(-88.61420441,41.63843536),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Indian Valley Area Voc Center",'Sandwich=' + Sandwich.length); Somonauk[Somonauk.length] = createMarker(new GPoint(-88.68460083,41.63309860),"",iconRd); mySelect.options[mySelect.options.length] = new Option("James R Wood Elementary School",'Somonauk=' + Somonauk.length); De_Kalb[De_Kalb.length] = createMarker(new GPoint(-88.75158691,41.94878769),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'De_Kalb=' + De_Kalb.length); Dekalb[Dekalb.length] = createMarker(new GPoint(-88.74622345,41.93099594),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Kec Central Area Voc Center",'Dekalb=' + Dekalb.length); Dekalb[Dekalb.length] = createMarker(new GPoint(-88.75358582,41.91985321),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Kec Central Efe 170 High School",'Dekalb=' + Dekalb.length); Dekalb[Dekalb.length] = createMarker(new GPoint(-88.75358582,41.91985321),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Kecol",'Dekalb=' + Dekalb.length); Kingston[Kingston.length] = createMarker(new GPoint(-88.75451660,42.09986115),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Kingston Elementary School",'Kingston=' + Kingston.length); Dekalb[Dekalb.length] = createMarker(new GPoint(-88.75654602,41.91816330),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Dekalb=' + Dekalb.length); Dekalb[Dekalb.length] = createMarker(new GPoint(-88.73937225,41.93853760),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Littlejohn Elementary School",'Dekalb=' + Dekalb.length); Sandwich[Sandwich.length] = createMarker(new GPoint(-88.62001801,41.63929749),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lynn G Haskin Elementary School",'Sandwich=' + Sandwich.length); Malta[Malta.length] = createMarker(new GPoint(-88.86201477,41.93439865),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Malta Elementary School",'Malta=' + Malta.length); Sycamore[Sycamore.length] = createMarker(new GPoint(-88.69306946,42.00950241),"",iconRd); mySelect.options[mySelect.options.length] = new Option("North Elementary School",'Sycamore=' + Sycamore.length); Malta[Malta.length] = createMarker(new GPoint(-88.93860300,41.93547000),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Paul T Wright Elementary School",'Malta=' + Malta.length); Sandwich[Sandwich.length] = createMarker(new GPoint(-88.62841797,41.65751266),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Prairie View Elementary School",'Sandwich=' + Sandwich.length); Sandwich[Sandwich.length] = createMarker(new GPoint(-88.61509705,41.63869095),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Sandwich Community High School",'Sandwich=' + Sandwich.length); Sandwich[Sandwich.length] = createMarker(new GPoint(-88.62010193,41.64037323),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Sandwich Middle School",'Sandwich=' + Sandwich.length); Shabbona[Shabbona.length] = createMarker(new GPoint(-88.87509918,41.76686478),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Shabbona Elementary School",'Shabbona=' + Shabbona.length); Somonauk[Somonauk.length] = createMarker(new GPoint(-88.68460083,41.63309860),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Somonauk High School",'Somonauk=' + Somonauk.length); Somonauk[Somonauk.length] = createMarker(new GPoint(-88.68460083,41.63309860),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Somonauk Middle School",'Somonauk=' + Somonauk.length); Sycamore[Sycamore.length] = createMarker(new GPoint(-88.70089722,41.97666168),"",iconRd); mySelect.options[mySelect.options.length] = new Option("South Prairie Elementary School",'Sycamore=' + Sycamore.length); Sycamore[Sycamore.length] = createMarker(new GPoint(-88.68466187,41.98072815),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Southeast Elementary School",'Sycamore=' + Sycamore.length); Sycamore[Sycamore.length] = createMarker(new GPoint(-88.70226288,41.98498154),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Sycamore High School",'Sycamore=' + Sycamore.length); Sycamore[Sycamore.length] = createMarker(new GPoint(-88.68220520,42.00226212),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Sycamore Middle School",'Sycamore=' + Sycamore.length); De_Kalb[De_Kalb.length] = createMarker(new GPoint(-88.75358582,41.91985321),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Tyler Elementary School",'De_Kalb=' + De_Kalb.length); Sandwich[Sandwich.length] = createMarker(new GPoint(-88.61820984,41.64816284),"",iconRd); mySelect.options[mySelect.options.length] = new Option("W W Woodbury Elementary School",'Sandwich=' + Sandwich.length); Waterman[Waterman.length] = createMarker(new GPoint(-88.77091217,41.77080536),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Waterman Elementary School",'Waterman=' + Waterman.length); Sycamore[Sycamore.length] = createMarker(new GPoint(-88.69757843,41.99164963),"",iconRd); mySelect.options[mySelect.options.length] = new Option("West Elementary School",'Sycamore=' + Sycamore.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(Cortland); map.removeOverlays(De_Kalb); map.removeOverlays(Dekalb); map.removeOverlays(Genoa); map.removeOverlays(Hinckley); map.removeOverlays(Kingston); map.removeOverlays(Kirkland); map.removeOverlays(Malta); map.removeOverlays(Sandwich); map.removeOverlays(Shabbona); map.removeOverlays(Somonauk); map.removeOverlays(Sycamore); map.removeOverlays(Waterman); 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(Dekalb);map.removeOverlays(Cortland); map.removeOverlays(De_Kalb); map.removeOverlays(Dekalb); map.removeOverlays(Genoa); map.removeOverlays(Hinckley); map.removeOverlays(Kingston); map.removeOverlays(Kirkland); map.removeOverlays(Malta); map.removeOverlays(Sandwich); map.removeOverlays(Shabbona); map.removeOverlays(Somonauk); map.removeOverlays(Sycamore); map.removeOverlays(Waterman); map.addOverlays(Cortland); centerByArray(Cortland, false, false); cntMarker += Cortland.length; map.addOverlays(De_Kalb); centerByArray(De_Kalb, false, false); cntMarker += De_Kalb.length; map.addOverlays(Dekalb); centerByArray(Dekalb, false, false); cntMarker += Dekalb.length; map.addOverlays(Genoa); centerByArray(Genoa, false, false); cntMarker += Genoa.length; map.addOverlays(Hinckley); centerByArray(Hinckley, false, false); cntMarker += Hinckley.length; map.addOverlays(Kingston); centerByArray(Kingston, false, false); cntMarker += Kingston.length; map.addOverlays(Kirkland); centerByArray(Kirkland, false, false); cntMarker += Kirkland.length; map.addOverlays(Malta); centerByArray(Malta, false, false); cntMarker += Malta.length; map.addOverlays(Sandwich); centerByArray(Sandwich, false, false); cntMarker += Sandwich.length; map.addOverlays(Shabbona); centerByArray(Shabbona, false, false); cntMarker += Shabbona.length; map.addOverlays(Somonauk); centerByArray(Somonauk, false, false); cntMarker += Somonauk.length; map.addOverlays(Sycamore); centerByArray(Sycamore, false, false); cntMarker += Sycamore.length; map.addOverlays(Waterman); centerByArray(Waterman, false, false); cntMarker += Waterman.length; centerByArray(Dekalb,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'); } }