function addMarkers() { mySelect = document.getElementById('selection'); Braceville = [];Coal_City = [];Morris = [];Gardner = [];Mazon = [];Minooka = [];South_Wilmington = [];mySelect.options[mySelect.options.length] = new Option("Braceville schools",'all=Braceville'); mySelect.options[mySelect.options.length] = new Option("Coal City schools",'all=Coal_City'); mySelect.options[mySelect.options.length] = new Option("Gardner schools",'all=Gardner'); mySelect.options[mySelect.options.length] = new Option("Mazon schools",'all=Mazon'); mySelect.options[mySelect.options.length] = new Option("Minooka schools",'all=Minooka'); mySelect.options[mySelect.options.length] = new Option("Morris schools",'all=Morris'); mySelect.options[mySelect.options.length] = new Option("South Wilmington schools",'all=South_Wilmington'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Braceville[Braceville.length] = createMarker(new GPoint(-88.26029968,41.23089981),"
Braceville Elementary School
209 Mitchell St
Braceville, IL 60407

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Braceville Elementary School",'Braceville=' + Braceville.length); Coal_City[Coal_City.length] = createMarker(new GPoint(-88.28568268,41.29153824),"
Coal City Elementary School
300 N Broadway St
Coal City, IL 60416

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Coal City Elementary School",'Coal_City=' + Coal_City.length); Coal_City[Coal_City.length] = createMarker(new GPoint(-88.30214691,41.28720856),"
Coal City High School
655 W Division St
Coal City, IL 60416

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Coal City High School",'Coal_City=' + Coal_City.length); Coal_City[Coal_City.length] = createMarker(new GPoint(-88.24007416,41.28884888),"
Coal City Intermediate School
305 E Division
Coal City, IL 60416

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Coal City Intermediate School",'Coal_City=' + Coal_City.length); Coal_City[Coal_City.length] = createMarker(new GPoint(-88.30431366,41.28176498),"
Coal City Middle School
500 S Carbon Hill Rd
Coal City, IL 60416

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Coal City Middle School",'Coal_City=' + Coal_City.length); Morris[Morris.length] = createMarker(new GPoint(-88.50944519,41.41224289),"
Erienna Elementary School
8820 Scott School Rd
Morris, IL 60450

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Erienna Elementary School",'Morris=' + Morris.length); Gardner[Gardner.length] = createMarker(new GPoint(-88.31559753,41.17630005),"
Gardner Elementary School
Po Box 347
Gardner, IL 60424

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Gardner Elementary School",'Gardner=' + Gardner.length); Gardner[Gardner.length] = createMarker(new GPoint(-88.31559753,41.17630005),"
Gardner-south Wilmington Township High School
Po Box 257
Gardner, IL 60424

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Gardner-south Wilmington Township High School",'Gardner=' + Gardner.length); Morris[Morris.length] = createMarker(new GPoint(-88.43163300,41.36525345),"
Gavc Pass High School
1715 Division Ste 4
Morris, IL 60450

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Gavc Pass High School",'Morris=' + Morris.length); Morris[Morris.length] = createMarker(new GPoint(-88.43163300,41.36525345),"
Grundy Area Vocational Center
1002 Union St
Morris, IL 60450

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Grundy Area Vocational Center",'Morris=' + Morris.length); Mazon[Mazon.length] = createMarker(new GPoint(-88.42828369,41.23880386),"
Mazon-verona-kinsman Elementary School
513 8th St
Mazon, IL 60444

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mazon-verona-kinsman Elementary School",'Mazon=' + Mazon.length); Mazon[Mazon.length] = createMarker(new GPoint(-88.43144226,41.24076462),"
Mazon-verona-kinsman Middle School
1013 North St
Mazon, IL 60444

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Mazon-verona-kinsman Middle School",'Mazon=' + Mazon.length); Minooka[Minooka.length] = createMarker(new GPoint(-88.26129913,41.44938660),"
Minooka Community High School
301 S Wabena Ave
Minooka, IL 60447

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Minooka Community High School",'Minooka=' + Minooka.length); Minooka[Minooka.length] = createMarker(new GPoint(-88.26328278,41.45983887),"
Minooka Elementary School
400 Coady Dr
Minooka, IL 60447

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Minooka Elementary School",'Minooka=' + Minooka.length); Minooka[Minooka.length] = createMarker(new GPoint(-88.26473999,41.45793533),"
Minooka Intermediate School
305 Church St
Minooka, IL 60447

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Minooka Intermediate School",'Minooka=' + Minooka.length); Minooka[Minooka.length] = createMarker(new GPoint(-88.26911926,41.44789124),"
Minooka Junior High School
333 W Mcevilly Rd
Minooka, IL 60447

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Minooka Junior High School",'Minooka=' + Minooka.length); Morris[Morris.length] = createMarker(new GPoint(-88.43163300,41.36524200),"
Morris Community High School
1000 Union St
Morris, IL 60450

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Morris Community High School",'Morris=' + Morris.length); Morris[Morris.length] = createMarker(new GPoint(-88.50944519,41.41224289),"
Nettle Creek Elementary School
8820 Scott School Rd
Morris, IL 60450

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Nettle Creek Elementary School",'Morris=' + Morris.length); Morris[Morris.length] = createMarker(new GPoint(-88.42490400,41.35865500),"
Saratoga Elementary School
4040 Division St
Morris, IL 60450

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Saratoga Elementary School",'Morris=' + Morris.length); Morris[Morris.length] = createMarker(new GPoint(-88.43229675,41.37004852),"
Shabbona Middle School
725 School St
Morris, IL 60450

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Shabbona Middle School",'Morris=' + Morris.length); South_Wilmington[South_Wilmington.length] = createMarker(new GPoint(-88.27790833,41.17292786),"
South Wilmington Grade School
Po Box 459
South Wilmington, IL 60474

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("South Wilmington Grade School",'South_Wilmington=' + South_Wilmington.length); Morris[Morris.length] = createMarker(new GPoint(-88.42490400,41.35865500),"
White Oak Elementary School
2001 Dupont Ave
Morris, IL 60450

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("White Oak Elementary School",'Morris=' + Morris.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(Braceville); map.removeOverlays(Coal_City); map.removeOverlays(Gardner); map.removeOverlays(Mazon); map.removeOverlays(Minooka); map.removeOverlays(Morris); map.removeOverlays(South_Wilmington); 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(Braceville);map.removeOverlays(Braceville); map.removeOverlays(Coal_City); map.removeOverlays(Gardner); map.removeOverlays(Mazon); map.removeOverlays(Minooka); map.removeOverlays(Morris); map.removeOverlays(South_Wilmington); map.addOverlays(Braceville); centerByArray(Braceville, false, false); cntMarker += Braceville.length; map.addOverlays(Coal_City); centerByArray(Coal_City, false, false); cntMarker += Coal_City.length; map.addOverlays(Gardner); centerByArray(Gardner, false, false); cntMarker += Gardner.length; map.addOverlays(Mazon); centerByArray(Mazon, false, false); cntMarker += Mazon.length; map.addOverlays(Minooka); centerByArray(Minooka, false, false); cntMarker += Minooka.length; map.addOverlays(Morris); centerByArray(Morris, false, false); cntMarker += Morris.length; map.addOverlays(South_Wilmington); centerByArray(South_Wilmington, false, false); cntMarker += South_Wilmington.length; centerByArray(Braceville,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'); } }