function addMarkers() { mySelect = document.getElementById('selection'); Toluca = [];Wenona = [];Henry = [];Washburn = [];Lacon = [];Varna = [];Sparland = [];mySelect.options[mySelect.options.length] = new Option("Henry schools",'all=Henry'); mySelect.options[mySelect.options.length] = new Option("Lacon schools",'all=Lacon'); mySelect.options[mySelect.options.length] = new Option("Sparland schools",'all=Sparland'); mySelect.options[mySelect.options.length] = new Option("Toluca schools",'all=Toluca'); mySelect.options[mySelect.options.length] = new Option("Varna schools",'all=Varna'); mySelect.options[mySelect.options.length] = new Option("Washburn schools",'all=Washburn'); mySelect.options[mySelect.options.length] = new Option("Wenona schools",'all=Wenona'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Toluca[Toluca.length] = createMarker(new GPoint(-89.13079834,40.99039841),"
Fieldcrest Elementary - West
Po Box 709
Toluca, IL 61369

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Fieldcrest Elementary - West",'Toluca=' + Toluca.length); Wenona[Wenona.length] = createMarker(new GPoint(-89.05001900,41.05332500),"
Fieldcrest Middle Sch/elem - East
102 W Elm St
Wenona, IL 61377

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Fieldcrest Middle Sch/elem - East",'Wenona=' + Wenona.length); Wenona[Wenona.length] = createMarker(new GPoint(-89.05043030,41.05708313),"
Fieldcrest Middle School - East
102 W Elm St
Wenona, IL 61377

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Fieldcrest Middle School - East",'Wenona=' + Wenona.length); Toluca[Toluca.length] = createMarker(new GPoint(-89.13079834,40.99039841),"
Fieldcrest Middle School - West
Po Box 709
Toluca, IL 61369

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Fieldcrest Middle School - West",'Toluca=' + Toluca.length); Henry[Henry.length] = createMarker(new GPoint(-89.35156250,41.11534500),"
Henry-senachwine Grade Sch00l Elementary School
201 Richard St
Henry, IL 61537

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Henry-senachwine Grade Sch00l Elementary School",'Henry=' + Henry.length); Henry[Henry.length] = createMarker(new GPoint(-89.36793518,41.11533737),"
Henry-senachwine High School
1023 College Ave
Henry, IL 61537

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Henry-senachwine High School",'Henry=' + Henry.length); Washburn[Washburn.length] = createMarker(new GPoint(-89.30719757,40.89889908),"
Lowpoint-washburn Elementary School
Po Box 580
Washburn, IL 61570

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lowpoint-washburn Elementary School",'Washburn=' + Washburn.length); Lacon[Lacon.length] = createMarker(new GPoint(-89.40489960,41.02516556),"
Midland Elementary School
206 N High St
Lacon, IL 61540

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Midland Elementary School",'Lacon=' + Lacon.length); Varna[Varna.length] = createMarker(new GPoint(-89.29090881,41.02663040),"
Midland High School
1830 State Rt 17
Varna, IL 61375

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Midland High School",'Varna=' + Varna.length); Sparland[Sparland.length] = createMarker(new GPoint(-89.44045258,41.03344345),"
Midland Middle School
901 Hilltop Dr
Sparland, IL 61565

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Midland Middle School",'Sparland=' + Sparland.length); Sparland[Sparland.length] = createMarker(new GPoint(-89.44045258,41.03344345),"
Sparland Elementary School
901 Hilltop Dr
Sparland, IL 61565

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Sparland Elementary School",'Sparland=' + Sparland.length); Varna[Varna.length] = createMarker(new GPoint(-89.25019836,41.05879974),"
Varna Elementary School
Po Box 200
Varna, IL 61375

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Varna Elementary School",'Varna=' + Varna.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(Henry); map.removeOverlays(Lacon); map.removeOverlays(Sparland); map.removeOverlays(Toluca); map.removeOverlays(Varna); map.removeOverlays(Washburn); map.removeOverlays(Wenona); 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(Toluca);map.removeOverlays(Henry); map.removeOverlays(Lacon); map.removeOverlays(Sparland); map.removeOverlays(Toluca); map.removeOverlays(Varna); map.removeOverlays(Washburn); map.removeOverlays(Wenona); map.addOverlays(Henry); centerByArray(Henry, false, false); cntMarker += Henry.length; map.addOverlays(Lacon); centerByArray(Lacon, false, false); cntMarker += Lacon.length; map.addOverlays(Sparland); centerByArray(Sparland, false, false); cntMarker += Sparland.length; map.addOverlays(Toluca); centerByArray(Toluca, false, false); cntMarker += Toluca.length; map.addOverlays(Varna); centerByArray(Varna, false, false); cntMarker += Varna.length; map.addOverlays(Washburn); centerByArray(Washburn, false, false); cntMarker += Washburn.length; map.addOverlays(Wenona); centerByArray(Wenona, false, false); cntMarker += Wenona.length; centerByArray(Toluca,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'); } }