function addMarkers() { mySelect = document.getElementById('selection'); Atwood = [];Bement = [];Mansfield = [];Cerro_Gordo = [];Weldon = [];De_Land = [];Monticello = [];White_Heath = [];mySelect.options[mySelect.options.length] = new Option("Atwood schools",'all=Atwood'); mySelect.options[mySelect.options.length] = new Option("Bement schools",'all=Bement'); mySelect.options[mySelect.options.length] = new Option("Cerro Gordo schools",'all=Cerro_Gordo'); mySelect.options[mySelect.options.length] = new Option("De Land schools",'all=De_Land'); mySelect.options[mySelect.options.length] = new Option("Mansfield schools",'all=Mansfield'); mySelect.options[mySelect.options.length] = new Option("Monticello schools",'all=Monticello'); mySelect.options[mySelect.options.length] = new Option("Weldon schools",'all=Weldon'); mySelect.options[mySelect.options.length] = new Option("White Heath schools",'all=White_Heath'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Atwood[Atwood.length] = createMarker(new GPoint(-88.44429779,39.81340027),"
Atwood Hammond High School
Po Box 890
Atwood, IL 61913

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Atwood Hammond High School",'Atwood=' + Atwood.length); Atwood[Atwood.length] = createMarker(new GPoint(-88.44429779,39.81340027),"
Atwood-hammond Elementary School
Po Box 860
Atwood, IL 61913

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Atwood-hammond Elementary School",'Atwood=' + Atwood.length); Bement[Bement.length] = createMarker(new GPoint(-88.56876373,39.92190552),"
Bement Elementary School
201 S Champaign St
Bement, IL 61813

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bement Elementary School",'Bement=' + Bement.length); Bement[Bement.length] = createMarker(new GPoint(-88.56876373,39.92190552),"
Bement High School
201 S Champaign St
Bement, IL 61813

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bement High School",'Bement=' + Bement.length); Bement[Bement.length] = createMarker(new GPoint(-88.56876373,39.92190552),"
Bement Middle School
201 S Champaign St
Bement, IL 61813

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Bement Middle School",'Bement=' + Bement.length); Mansfield[Mansfield.length] = createMarker(new GPoint(-88.52510071,40.21039963),"
Blue Ridge Junior High School
Po Box 69
Mansfield, IL 61854

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Blue Ridge Junior High School",'Mansfield=' + Mansfield.length); Mansfield[Mansfield.length] = createMarker(new GPoint(-88.52510071,40.21039963),"
Blue Ridge Mansfield Elementary School
250 Mckinley St
Mansfield, IL 61854

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Blue Ridge Mansfield Elementary School",'Mansfield=' + Mansfield.length); Cerro_Gordo[Cerro_Gordo.length] = createMarker(new GPoint(-88.72090149,39.87720108),"
Cerro Gordo Elementary School
Po Box 66
Cerro Gordo, IL 61818

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Cerro Gordo Elementary School",'Cerro_Gordo=' + Cerro_Gordo.length); Cerro_Gordo[Cerro_Gordo.length] = createMarker(new GPoint(-88.72090149,39.87720108),"
Cerro Gordo High School
Po Box 79
Cerro Gordo, IL 61818

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cerro Gordo High School",'Cerro_Gordo=' + Cerro_Gordo.length); Cerro_Gordo[Cerro_Gordo.length] = createMarker(new GPoint(-88.72090149,39.87720108),"
Cerro Gordo Middle School
Po Box 79
Cerro Gordo, IL 61818

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Cerro Gordo Middle School",'Cerro_Gordo=' + Cerro_Gordo.length); Weldon[Weldon.length] = createMarker(new GPoint(-88.68857574,40.12311554),"
Deland-weldon Elementary School
2311 N 300 E Rd
Weldon, IL 61882

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Deland-weldon Elementary School",'Weldon=' + Weldon.length); De_Land[De_Land.length] = createMarker(new GPoint(-88.64540100,40.12549973),"
Deland-weldon High School
304 E Il Rte 10
De Land, IL 61839

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Deland-weldon High School",'De_Land=' + De_Land.length); Weldon[Weldon.length] = createMarker(new GPoint(-88.68857574,40.12311554),"
Deland-weldon Middle School
2311 N 300 E Rd
Weldon, IL 61882

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Deland-weldon Middle School",'Weldon=' + Weldon.length); Monticello[Monticello.length] = createMarker(new GPoint(-88.57370900,40.02528500),"
Lincoln Elementary School
700 N Buchanan St
Monticello, IL 61856

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Monticello=' + Monticello.length); Monticello[Monticello.length] = createMarker(new GPoint(-88.57250214,40.02510071),"
Monticello High School
1 Sage Dr
Monticello, IL 61856

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Monticello High School",'Monticello=' + Monticello.length); Monticello[Monticello.length] = createMarker(new GPoint(-88.57370900,40.02528500),"
Monticello Middle School
2015 E Washington
Monticello, IL 61856

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Monticello Middle School",'Monticello=' + Monticello.length); Monticello[Monticello.length] = createMarker(new GPoint(-88.57250214,40.02510071),"
Washington School
3 Sage Dr
Monticello, IL 61856

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Washington School",'Monticello=' + Monticello.length); White_Heath[White_Heath.length] = createMarker(new GPoint(-88.50119781,40.10269928),"
White Heath Elementary School
300 W High St
White Heath, IL 61884

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("White Heath Elementary School",'White_Heath=' + White_Heath.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(Atwood); map.removeOverlays(Bement); map.removeOverlays(Cerro_Gordo); map.removeOverlays(De_Land); map.removeOverlays(Mansfield); map.removeOverlays(Monticello); map.removeOverlays(Weldon); map.removeOverlays(White_Heath); 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(Atwood);map.removeOverlays(Atwood); map.removeOverlays(Bement); map.removeOverlays(Cerro_Gordo); map.removeOverlays(De_Land); map.removeOverlays(Mansfield); map.removeOverlays(Monticello); map.removeOverlays(Weldon); map.removeOverlays(White_Heath); map.addOverlays(Atwood); centerByArray(Atwood, false, false); cntMarker += Atwood.length; map.addOverlays(Bement); centerByArray(Bement, false, false); cntMarker += Bement.length; map.addOverlays(Cerro_Gordo); centerByArray(Cerro_Gordo, false, false); cntMarker += Cerro_Gordo.length; map.addOverlays(De_Land); centerByArray(De_Land, false, false); cntMarker += De_Land.length; map.addOverlays(Mansfield); centerByArray(Mansfield, false, false); cntMarker += Mansfield.length; map.addOverlays(Monticello); centerByArray(Monticello, false, false); cntMarker += Monticello.length; map.addOverlays(Weldon); centerByArray(Weldon, false, false); cntMarker += Weldon.length; map.addOverlays(White_Heath); centerByArray(White_Heath, false, false); cntMarker += White_Heath.length; centerByArray(Atwood,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'); } }