function addMarkers() { mySelect = document.getElementById('selection'); Lawrenceville = [];Bridgeport = [];Sumner = [];mySelect.options[mySelect.options.length] = new Option("Bridgeport schools",'all=Bridgeport'); mySelect.options[mySelect.options.length] = new Option("Lawrenceville schools",'all=Lawrenceville'); mySelect.options[mySelect.options.length] = new Option("Sumner schools",'all=Sumner'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Lawrenceville[Lawrenceville.length] = createMarker(new GPoint(-87.68882751,38.72723770),"
Arlington Elementary School
1609 Lexington Ave
Lawrenceville, IL 62439

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Arlington Elementary School",'Lawrenceville=' + Lawrenceville.length); Bridgeport[Bridgeport.length] = createMarker(new GPoint(-87.76127625,38.71440125),"
Bridgeport Grade School
1300 N Main St
Bridgeport, IL 62417

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bridgeport Grade School",'Bridgeport=' + Bridgeport.length); Lawrenceville[Lawrenceville.length] = createMarker(new GPoint(-87.65270233,38.73889923),"
Brookside Elementary School
R R 3 Box 216
Lawrenceville, IL 62439

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Brookside Elementary School",'Lawrenceville=' + Lawrenceville.length); Lawrenceville[Lawrenceville.length] = createMarker(new GPoint(-87.68227386,38.72451019),"
Central Elementary School
1307 11th St
Lawrenceville, IL 62439

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Lawrenceville=' + Lawrenceville.length); Sumner[Sumner.length] = createMarker(new GPoint(-87.84030151,38.75690079),"
Lawrence Correctional Center
Po Box 1000
Sumner, IL 62466

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Lawrence Correctional Center",'Sumner=' + Sumner.length); Lawrenceville[Lawrenceville.length] = createMarker(new GPoint(-87.67946625,38.73085785),"
Lawrenceville High School
503 8th St
Lawrenceville, IL 62439

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Lawrenceville High School",'Lawrenceville=' + Lawrenceville.length); Lawrenceville[Lawrenceville.length] = createMarker(new GPoint(-87.68227386,38.72344208),"
Lincoln Elementary School
1413 11th St
Lawrenceville, IL 62439

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Lawrenceville=' + Lawrenceville.length); Lawrenceville[Lawrenceville.length] = createMarker(new GPoint(-87.69594574,38.72179413),"
Parkside Elementary School
1900 Cedar St
Lawrenceville, IL 62439

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Parkside Elementary School",'Lawrenceville=' + Lawrenceville.length); Lawrenceville[Lawrenceville.length] = createMarker(new GPoint(-87.68988037,38.72119141),"
Parkview Junior High School
1802 Cedar St
Lawrenceville, IL 62439

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Parkview Junior High School",'Lawrenceville=' + Lawrenceville.length); Sumner[Sumner.length] = createMarker(new GPoint(-87.84030151,38.75690079),"
Petty Elementary School
Rr 2 Box 227
Sumner, IL 62466

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Petty Elementary School",'Sumner=' + Sumner.length); Bridgeport[Bridgeport.length] = createMarker(new GPoint(-87.75727844,38.71208954),"
Red Hill High School
908 Church St
Bridgeport, IL 62417

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Red Hill High School",'Bridgeport=' + Bridgeport.length); Lawrenceville[Lawrenceville.length] = createMarker(new GPoint(-87.68227386,38.73063660),"
Safe School Roe12 Lawrence Cnty
511 11th St
Lawrenceville, IL 62439

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Safe School Roe12 Lawrence Cnty",'Lawrenceville=' + Lawrenceville.length); Sumner[Sumner.length] = createMarker(new GPoint(-87.86179352,38.71465683),"
Sumner Attendance Center
110 W Locust St
Sumner, IL 62466

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Sumner Attendance Center",'Sumner=' + Sumner.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(Bridgeport); map.removeOverlays(Lawrenceville); map.removeOverlays(Sumner); 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(Lawrenceville);map.removeOverlays(Bridgeport); map.removeOverlays(Lawrenceville); map.removeOverlays(Sumner); map.addOverlays(Bridgeport); centerByArray(Bridgeport, false, false); cntMarker += Bridgeport.length; map.addOverlays(Lawrenceville); centerByArray(Lawrenceville, false, false); cntMarker += Lawrenceville.length; map.addOverlays(Sumner); centerByArray(Sumner, false, false); cntMarker += Sumner.length; centerByArray(Lawrenceville,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'); } }