function addMarkers() { mySelect = document.getElementById('selection'); Brownstown = [];Vandalia = [];Ramsey = [];Saint_Elmo = [];St_Elmo = [];mySelect.options[mySelect.options.length] = new Option("Brownstown schools",'all=Brownstown'); mySelect.options[mySelect.options.length] = new Option("Ramsey schools",'all=Ramsey'); mySelect.options[mySelect.options.length] = new Option("Saint Elmo schools",'all=Saint_Elmo'); mySelect.options[mySelect.options.length] = new Option("St Elmo schools",'all=St_Elmo'); mySelect.options[mySelect.options.length] = new Option("Vandalia schools",'all=Vandalia'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Brownstown[Brownstown.length] = createMarker(new GPoint(-88.95901489,38.99266434),"
Brownstown Elementary School
460 W South St
Brownstown, IL 62418

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Brownstown Elementary School",'Brownstown=' + Brownstown.length); Brownstown[Brownstown.length] = createMarker(new GPoint(-88.95522400,38.99079500),"
Brownstown High School
421 S College Ave
Brownstown, IL 62418

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Brownstown High School",'Brownstown=' + Brownstown.length); Brownstown[Brownstown.length] = createMarker(new GPoint(-88.95597839,38.99219131),"
Brownstown Junior High School
421 S College Ave
Brownstown, IL 62418

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Brownstown Junior High School",'Brownstown=' + Brownstown.length); Vandalia[Vandalia.length] = createMarker(new GPoint(-89.10485077,38.97265244),"
Focus Junior Safe School
1805 W Fletcher St
Vandalia, IL 62471

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Focus Junior Safe School",'Vandalia=' + Vandalia.length); Vandalia[Vandalia.length] = createMarker(new GPoint(-89.10968018,38.96616364),"
Jefferson Primary School
1500 W Jefferson St
Vandalia, IL 62471

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Jefferson Primary School",'Vandalia=' + Vandalia.length); Vandalia[Vandalia.length] = createMarker(new GPoint(-89.09646606,38.96776199),"
Lincoln Elementary School
525 W Lincoln St
Vandalia, IL 62471

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Vandalia=' + Vandalia.length); Vandalia[Vandalia.length] = createMarker(new GPoint(-89.10485077,38.97265244),"
New Approach School
1805 W Fletcher St
Vandalia, IL 62471

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("New Approach School",'Vandalia=' + Vandalia.length); Vandalia[Vandalia.length] = createMarker(new GPoint(-89.10037231,38.97190094),"
Okaw Area Vocational Center
1109 N 8th St
Vandalia, IL 62471

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Okaw Area Vocational Center",'Vandalia=' + Vandalia.length); Ramsey[Ramsey.length] = createMarker(new GPoint(-89.11270905,39.14112473),"
Ramsey Elementary School
610 W 6th St
Ramsey, IL 62080

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Ramsey Elementary School",'Ramsey=' + Ramsey.length); Ramsey[Ramsey.length] = createMarker(new GPoint(-89.11373901,39.14116287),"
Ramsey High School
716 W 6th St
Ramsey, IL 62080

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Ramsey High School",'Ramsey=' + Ramsey.length); Saint_Elmo[Saint_Elmo.length] = createMarker(new GPoint(-88.85425568,39.02516174),"
St Elmo Elementary School
519 W 2nd St
Saint Elmo, IL 62458

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("St Elmo Elementary School",'Saint_Elmo=' + Saint_Elmo.length); St_Elmo[St_Elmo.length] = createMarker(new GPoint(-88.85167694,39.03523636),"
St Elmo Junior High School
300 W 12th St
St Elmo, IL 62458

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("St Elmo Junior High School",'St_Elmo=' + St_Elmo.length); Saint_Elmo[Saint_Elmo.length] = createMarker(new GPoint(-88.85167694,39.03523636),"
St Elmo Senior High School
300 W. 12th Street
Saint Elmo, IL 62458

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Elmo Senior High School",'Saint_Elmo=' + Saint_Elmo.length); Vandalia[Vandalia.length] = createMarker(new GPoint(-89.10037231,38.97190094),"
Vandalia Community High School
1109 N 8th St
Vandalia, IL 62471

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Vandalia Community High School",'Vandalia=' + Vandalia.length); Vandalia[Vandalia.length] = createMarker(new GPoint(-89.10250092,38.94309998),"
Vandalia Correctional Center
Po Box 500
Vandalia, IL 62471

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Vandalia Correctional Center",'Vandalia=' + Vandalia.length); Vandalia[Vandalia.length] = createMarker(new GPoint(-89.10330963,38.97503662),"
Vandalia Elementary School
1017 W Fletcher St
Vandalia, IL 62471

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Vandalia Elementary School",'Vandalia=' + Vandalia.length); Vandalia[Vandalia.length] = createMarker(new GPoint(-89.10322571,38.97503662),"
Vandalia Junior High School
1011 W Fletcher St
Vandalia, IL 62471

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Vandalia Junior High School",'Vandalia=' + Vandalia.length); Vandalia[Vandalia.length] = createMarker(new GPoint(-89.10250092,38.94309998),"
Vandalia Work Camp High School
Po Box 500
Vandalia, IL 62471

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Vandalia Work Camp High School",'Vandalia=' + Vandalia.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(Brownstown); map.removeOverlays(Ramsey); map.removeOverlays(Saint_Elmo); map.removeOverlays(St_Elmo); map.removeOverlays(Vandalia); 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(Brownstown);map.removeOverlays(Brownstown); map.removeOverlays(Ramsey); map.removeOverlays(Saint_Elmo); map.removeOverlays(St_Elmo); map.removeOverlays(Vandalia); map.addOverlays(Brownstown); centerByArray(Brownstown, false, false); cntMarker += Brownstown.length; map.addOverlays(Ramsey); centerByArray(Ramsey, false, false); cntMarker += Ramsey.length; map.addOverlays(Saint_Elmo); centerByArray(Saint_Elmo, false, false); cntMarker += Saint_Elmo.length; map.addOverlays(St_Elmo); centerByArray(St_Elmo, false, false); cntMarker += St_Elmo.length; map.addOverlays(Vandalia); centerByArray(Vandalia, false, false); cntMarker += Vandalia.length; centerByArray(Brownstown,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'); } }