function addMarkers() { mySelect = document.getElementById('selection'); Chester = [];Coulterville = [];Evansville = [];Menard = [];Red_Bud = [];Prairie_Du_Rocher = [];Sparta = [];Steeleville = [];Tilden = [];mySelect.options[mySelect.options.length] = new Option("Chester schools",'all=Chester'); mySelect.options[mySelect.options.length] = new Option("Coulterville schools",'all=Coulterville'); mySelect.options[mySelect.options.length] = new Option("Evansville schools",'all=Evansville'); mySelect.options[mySelect.options.length] = new Option("Menard schools",'all=Menard'); mySelect.options[mySelect.options.length] = new Option("Prairie Du Rocher schools",'all=Prairie_Du_Rocher'); mySelect.options[mySelect.options.length] = new Option("Red Bud schools",'all=Red_Bud'); mySelect.options[mySelect.options.length] = new Option("Sparta schools",'all=Sparta'); mySelect.options[mySelect.options.length] = new Option("Steeleville schools",'all=Steeleville'); mySelect.options[mySelect.options.length] = new Option("Tilden schools",'all=Tilden'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Chester[Chester.length] = createMarker(new GPoint(-89.81838226,37.90786743),"
Chester Elementary School
650 Opdyke St
Chester, IL 62233

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Chester Elementary School",'Chester=' + Chester.length); Chester[Chester.length] = createMarker(new GPoint(-89.81360626,37.91929245),"
Chester High School
1901 Swanwick St
Chester, IL 62233

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Chester High School",'Chester=' + Chester.length); Coulterville[Coulterville.length] = createMarker(new GPoint(-89.58840179,38.18600082),"
Coulterville Elementary School
Po Box 396
Coulterville, IL 62237

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Coulterville Elementary School",'Coulterville=' + Coulterville.length); Coulterville[Coulterville.length] = createMarker(new GPoint(-89.58840179,38.18600082),"
Coulterville High School
Po Box 396
Coulterville, IL 62237

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Coulterville High School",'Coulterville=' + Coulterville.length); Coulterville[Coulterville.length] = createMarker(new GPoint(-89.58840179,38.18600082),"
Coulterville Junior High School
Po Box 396
Coulterville, IL 62237

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Coulterville Junior High School",'Coulterville=' + Coulterville.length); Evansville[Evansville.length] = createMarker(new GPoint(-89.93402863,38.09143829),"
Evansville Attendance Center
701 Oak St
Evansville, IL 62242

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Evansville Attendance Center",'Evansville=' + Evansville.length); Menard[Menard.length] = createMarker(new GPoint(-89.83367920,37.90415955),"
Menard Correctional Center
711 Kaskaskia St
Menard, IL 62259

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Menard Correctional Center",'Menard=' + Menard.length); Red_Bud[Red_Bud.length] = createMarker(new GPoint(-89.99250031,38.19929886),"
Monroe/randolph Red Brick School
Po Box 56
Red Bud, IL 62278

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Monroe/randolph Red Brick School",'Red_Bud=' + Red_Bud.length); Evansville[Evansville.length] = createMarker(new GPoint(-89.93151400,38.09127500),"
Perandoe Evansville School
1003 Olive St
Evansville, IL 62242

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Perandoe Evansville School",'Evansville=' + Evansville.length); Prairie_Du_Rocher[Prairie_Du_Rocher.length] = createMarker(new GPoint(-90.09474182,38.07964706),"
Prairie Du Rocher Elementary School
714 Middle St
Prairie Du Rocher, IL 62277

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Prairie Du Rocher Elementary School",'Prairie_Du_Rocher=' + Prairie_Du_Rocher.length); Red_Bud[Red_Bud.length] = createMarker(new GPoint(-89.99557495,38.20216370),"
Red Bud Elementary School
200 Field Dr
Red Bud, IL 62278

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Red Bud Elementary School",'Red_Bud=' + Red_Bud.length); Red_Bud[Red_Bud.length] = createMarker(new GPoint(-89.99567413,38.20463562),"
Red Bud High School
815 Locust St
Red Bud, IL 62278

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Red Bud High School",'Red_Bud=' + Red_Bud.length); Sparta[Sparta.length] = createMarker(new GPoint(-89.70469666,38.13173676),"
Sparta High School
205 W Hood St
Sparta, IL 62286

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Sparta High School",'Sparta=' + Sparta.length); Sparta[Sparta.length] = createMarker(new GPoint(-89.70162900,38.12263100),"
Sparta Primary Attendance Center
119 Legion Dr
Sparta, IL 62286

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Sparta Primary Attendance Center",'Sparta=' + Sparta.length); Sparta[Sparta.length] = createMarker(new GPoint(-89.70327759,38.13293839),"
Sparta-lincoln Middle School
203a Dean Ave
Sparta, IL 62286

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Sparta-lincoln Middle School",'Sparta=' + Sparta.length); Steeleville[Steeleville.length] = createMarker(new GPoint(-89.65877533,38.00328064),"
Steeleville Elementary School
609 S Sparta St
Steeleville, IL 62288

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Steeleville Elementary School",'Steeleville=' + Steeleville.length); Steeleville[Steeleville.length] = createMarker(new GPoint(-89.65877533,38.00215530),"
Steeleville High School
701 S Sparta
Steeleville, IL 62288

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Steeleville High School",'Steeleville=' + Steeleville.length); Tilden[Tilden.length] = createMarker(new GPoint(-89.68350220,38.21229935),"
Tilden Attendance Center
Po Box 394
Tilden, IL 62292

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Tilden Attendance Center",'Tilden=' + Tilden.length); Chester[Chester.length] = createMarker(new GPoint(-89.81050110,37.92430115),"
Trail Wind Elementary School
Po Box 31
Chester, IL 62233

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Trail Wind Elementary School",'Chester=' + Chester.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(Chester); map.removeOverlays(Coulterville); map.removeOverlays(Evansville); map.removeOverlays(Menard); map.removeOverlays(Prairie_Du_Rocher); map.removeOverlays(Red_Bud); map.removeOverlays(Sparta); map.removeOverlays(Steeleville); map.removeOverlays(Tilden); 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(Chester);map.removeOverlays(Chester); map.removeOverlays(Coulterville); map.removeOverlays(Evansville); map.removeOverlays(Menard); map.removeOverlays(Prairie_Du_Rocher); map.removeOverlays(Red_Bud); map.removeOverlays(Sparta); map.removeOverlays(Steeleville); map.removeOverlays(Tilden); map.addOverlays(Chester); centerByArray(Chester, false, false); cntMarker += Chester.length; map.addOverlays(Coulterville); centerByArray(Coulterville, false, false); cntMarker += Coulterville.length; map.addOverlays(Evansville); centerByArray(Evansville, false, false); cntMarker += Evansville.length; map.addOverlays(Menard); centerByArray(Menard, false, false); cntMarker += Menard.length; map.addOverlays(Prairie_Du_Rocher); centerByArray(Prairie_Du_Rocher, false, false); cntMarker += Prairie_Du_Rocher.length; map.addOverlays(Red_Bud); centerByArray(Red_Bud, false, false); cntMarker += Red_Bud.length; map.addOverlays(Sparta); centerByArray(Sparta, false, false); cntMarker += Sparta.length; map.addOverlays(Steeleville); centerByArray(Steeleville, false, false); cntMarker += Steeleville.length; map.addOverlays(Tilden); centerByArray(Tilden, false, false); cntMarker += Tilden.length; centerByArray(Chester,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'); } }