function addMarkers() { mySelect = document.getElementById('selection'); Benld = [];Brighton = [];Bunker_Hill = [];Carlinville = [];Gillespie = [];Girard = [];Medora = [];Mount_Olive = [];Palmyra = [];Shipman = [];Piasa = [];Staunton = [];Virden = [];mySelect.options[mySelect.options.length] = new Option("Benld schools",'all=Benld'); mySelect.options[mySelect.options.length] = new Option("Brighton schools",'all=Brighton'); mySelect.options[mySelect.options.length] = new Option("Bunker Hill schools",'all=Bunker_Hill'); mySelect.options[mySelect.options.length] = new Option("Carlinville schools",'all=Carlinville'); mySelect.options[mySelect.options.length] = new Option("Gillespie schools",'all=Gillespie'); mySelect.options[mySelect.options.length] = new Option("Girard schools",'all=Girard'); mySelect.options[mySelect.options.length] = new Option("Medora schools",'all=Medora'); mySelect.options[mySelect.options.length] = new Option("Mount Olive schools",'all=Mount_Olive'); mySelect.options[mySelect.options.length] = new Option("Palmyra schools",'all=Palmyra'); mySelect.options[mySelect.options.length] = new Option("Piasa schools",'all=Piasa'); mySelect.options[mySelect.options.length] = new Option("Shipman schools",'all=Shipman'); mySelect.options[mySelect.options.length] = new Option("Staunton schools",'all=Staunton'); mySelect.options[mySelect.options.length] = new Option("Virden schools",'all=Virden'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Benld[Benld.length] = createMarker(new GPoint(-89.80651855,39.08926392),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Benld Elementary School",'Benld=' + Benld.length); Brighton[Brighton.length] = createMarker(new GPoint(-90.14389801,39.03530121),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Brighton North Elementary School",'Brighton=' + Brighton.length); Brighton[Brighton.length] = createMarker(new GPoint(-90.14389801,39.03530121),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Brighton West Elementary School",'Brighton=' + Brighton.length); Bunker_Hill[Bunker_Hill.length] = createMarker(new GPoint(-89.96017456,39.04068756),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Bunker Hill High School",'Bunker_Hill=' + Bunker_Hill.length); Carlinville[Carlinville.length] = createMarker(new GPoint(-89.87877655,39.28469467),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Carlinville Early Childhood Center",'Carlinville=' + Carlinville.length); Carlinville[Carlinville.length] = createMarker(new GPoint(-89.89294434,39.27956390),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Carlinville High School",'Carlinville=' + Carlinville.length); Carlinville[Carlinville.length] = createMarker(new GPoint(-89.88707733,39.28723526),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Carlinville Intermediate School",'Carlinville=' + Carlinville.length); Carlinville[Carlinville.length] = createMarker(new GPoint(-89.89162445,39.27951431),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Carlinville Middle School",'Carlinville=' + Carlinville.length); Carlinville[Carlinville.length] = createMarker(new GPoint(-89.95661926,39.21340179),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Carlinville Primary School",'Carlinville=' + Carlinville.length); Gillespie[Gillespie.length] = createMarker(new GPoint(-89.82671356,39.12936401),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Gillespie High School",'Gillespie=' + Gillespie.length); Gillespie[Gillespie.length] = createMarker(new GPoint(-89.82524109,39.12627029),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Gillespie Middle School",'Gillespie=' + Gillespie.length); Girard[Girard.length] = createMarker(new GPoint(-89.78077698,39.45028687),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Girard Community Unit Elementary School",'Girard=' + Girard.length); Girard[Girard.length] = createMarker(new GPoint(-89.78077698,39.45028687),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Girard High School",'Girard=' + Girard.length); Girard[Girard.length] = createMarker(new GPoint(-89.78077698,39.45028687),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Girard Middle School",'Girard=' + Girard.length); Medora[Medora.length] = createMarker(new GPoint(-90.15750122,39.19599915),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Medora Elementary School",'Medora=' + Medora.length); Bunker_Hill[Bunker_Hill.length] = createMarker(new GPoint(-89.94818115,39.04276276),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Meissner Elementary School",'Bunker_Hill=' + Bunker_Hill.length); Mount_Olive[Mount_Olive.length] = createMarker(new GPoint(-89.73587036,39.07243729),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mt Olive Elementary School",'Mount_Olive=' + Mount_Olive.length); Mount_Olive[Mount_Olive.length] = createMarker(new GPoint(-89.73587036,39.07243729),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Mt Olive High School",'Mount_Olive=' + Mount_Olive.length); Palmyra[Palmyra.length] = createMarker(new GPoint(-89.99610138,39.42457962),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Northwestern Elementary School",'Palmyra=' + Palmyra.length); Palmyra[Palmyra.length] = createMarker(new GPoint(-89.99607086,39.42344666),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Northwestern High School",'Palmyra=' + Palmyra.length); Palmyra[Palmyra.length] = createMarker(new GPoint(-89.99607086,39.42344666),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Northwestern Junior High School",'Palmyra=' + Palmyra.length); Carlinville[Carlinville.length] = createMarker(new GPoint(-89.88177490,39.28043747),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Roe Adult Learning Center Macoupin",'Carlinville=' + Carlinville.length); Carlinville[Carlinville.length] = createMarker(new GPoint(-89.88134766,39.28066254),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Roe Safe Sch Macoupin",'Carlinville=' + Carlinville.length); Shipman[Shipman.length] = createMarker(new GPoint(-89.99929810,39.13660049),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Shipman Elementary School",'Shipman=' + Shipman.length); Carlinville[Carlinville.length] = createMarker(new GPoint(-89.88174438,39.27841949),"",iconRd); mySelect.options[mySelect.options.length] = new Option("South Elementary School",'Carlinville=' + Carlinville.length); Piasa[Piasa.length] = createMarker(new GPoint(-90.13670349,39.13570023),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Southwestern High School",'Piasa=' + Piasa.length); Piasa[Piasa.length] = createMarker(new GPoint(-90.13670349,39.13570023),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Southwestern Middle School",'Piasa=' + Piasa.length); Gillespie[Gillespie.length] = createMarker(new GPoint(-89.82524109,39.12627029),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Special Education Building",'Gillespie=' + Gillespie.length); Staunton[Staunton.length] = createMarker(new GPoint(-89.79467773,39.01924896),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Staunton Elementary School",'Staunton=' + Staunton.length); Staunton[Staunton.length] = createMarker(new GPoint(-89.79467773,39.01924896),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Staunton High School",'Staunton=' + Staunton.length); Staunton[Staunton.length] = createMarker(new GPoint(-89.79467773,39.01924896),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Staunton Junior High School",'Staunton=' + Staunton.length); Virden[Virden.length] = createMarker(new GPoint(-89.77021790,39.50663757),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Virden Elementary School",'Virden=' + Virden.length); Virden[Virden.length] = createMarker(new GPoint(-89.77021790,39.50663757),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Virden High School",'Virden=' + Virden.length); Virden[Virden.length] = createMarker(new GPoint(-89.77021790,39.50663757),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Virden Middle School",'Virden=' + Virden.length); Bunker_Hill[Bunker_Hill.length] = createMarker(new GPoint(-89.95419312,39.03766251),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wolf Ridge Educational Center",'Bunker_Hill=' + Bunker_Hill.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(Benld); map.removeOverlays(Brighton); map.removeOverlays(Bunker_Hill); map.removeOverlays(Carlinville); map.removeOverlays(Gillespie); map.removeOverlays(Girard); map.removeOverlays(Medora); map.removeOverlays(Mount_Olive); map.removeOverlays(Palmyra); map.removeOverlays(Piasa); map.removeOverlays(Shipman); map.removeOverlays(Staunton); map.removeOverlays(Virden); 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(Benld);map.removeOverlays(Benld); map.removeOverlays(Brighton); map.removeOverlays(Bunker_Hill); map.removeOverlays(Carlinville); map.removeOverlays(Gillespie); map.removeOverlays(Girard); map.removeOverlays(Medora); map.removeOverlays(Mount_Olive); map.removeOverlays(Palmyra); map.removeOverlays(Piasa); map.removeOverlays(Shipman); map.removeOverlays(Staunton); map.removeOverlays(Virden); map.addOverlays(Benld); centerByArray(Benld, false, false); cntMarker += Benld.length; map.addOverlays(Brighton); centerByArray(Brighton, false, false); cntMarker += Brighton.length; map.addOverlays(Bunker_Hill); centerByArray(Bunker_Hill, false, false); cntMarker += Bunker_Hill.length; map.addOverlays(Carlinville); centerByArray(Carlinville, false, false); cntMarker += Carlinville.length; map.addOverlays(Gillespie); centerByArray(Gillespie, false, false); cntMarker += Gillespie.length; map.addOverlays(Girard); centerByArray(Girard, false, false); cntMarker += Girard.length; map.addOverlays(Medora); centerByArray(Medora, false, false); cntMarker += Medora.length; map.addOverlays(Mount_Olive); centerByArray(Mount_Olive, false, false); cntMarker += Mount_Olive.length; map.addOverlays(Palmyra); centerByArray(Palmyra, false, false); cntMarker += Palmyra.length; map.addOverlays(Piasa); centerByArray(Piasa, false, false); cntMarker += Piasa.length; map.addOverlays(Shipman); centerByArray(Shipman, false, false); cntMarker += Shipman.length; map.addOverlays(Staunton); centerByArray(Staunton, false, false); cntMarker += Staunton.length; map.addOverlays(Virden); centerByArray(Virden, false, false); cntMarker += Virden.length; centerByArray(Benld,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'); } }