function addMarkers() { mySelect = document.getElementById('selection'); Montgomery = [];Bristol = [];Plano = [];Oswego = [];Yorkville = [];Newark = [];Millbrook = [];mySelect.options[mySelect.options.length] = new Option("Bristol schools",'all=Bristol'); mySelect.options[mySelect.options.length] = new Option("Millbrook schools",'all=Millbrook'); mySelect.options[mySelect.options.length] = new Option("Montgomery schools",'all=Montgomery'); mySelect.options[mySelect.options.length] = new Option("Newark schools",'all=Newark'); mySelect.options[mySelect.options.length] = new Option("Oswego schools",'all=Oswego'); mySelect.options[mySelect.options.length] = new Option("Plano schools",'all=Plano'); mySelect.options[mySelect.options.length] = new Option("Yorkville schools",'all=Yorkville'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Montgomery[Montgomery.length] = createMarker(new GPoint(-88.33861542,41.70965958),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Boulder Hill Elementary School",'Montgomery=' + Montgomery.length); Bristol[Bristol.length] = createMarker(new GPoint(-88.41390228,41.69599915),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bristol Grade School",'Bristol=' + Bristol.length); Plano[Plano.length] = createMarker(new GPoint(-88.53717041,41.65630722),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Centennial Elementary School",'Plano=' + Plano.length); Oswego[Oswego.length] = createMarker(new GPoint(-88.29894200,41.69468500),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Churchill Elementary School",'Oswego=' + Oswego.length); Yorkville[Yorkville.length] = createMarker(new GPoint(-88.44398499,41.63575745),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Circle Center Intermediate",'Yorkville=' + Yorkville.length); Oswego[Oswego.length] = createMarker(new GPoint(-88.34185028,41.68439484),"",iconRd); mySelect.options[mySelect.options.length] = new Option("East View Elementary School",'Oswego=' + Oswego.length); Oswego[Oswego.length] = createMarker(new GPoint(-88.36254120,41.69471359),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Fox Chase Elementary School",'Oswego=' + Oswego.length); Oswego[Oswego.length] = createMarker(new GPoint(-88.33713531,41.68169022),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Kendall Co Opportunity School",'Oswego=' + Oswego.length); Montgomery[Montgomery.length] = createMarker(new GPoint(-88.39719000,41.71605600),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lakewood Creek Elementary School",'Montgomery=' + Montgomery.length); Newark[Newark.length] = createMarker(new GPoint(-88.48208618,41.47862625),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lisbon Grade School",'Newark=' + Newark.length); Montgomery[Montgomery.length] = createMarker(new GPoint(-88.32846832,41.71183395),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Long Beach Elementary School",'Montgomery=' + Montgomery.length); Millbrook[Millbrook.length] = createMarker(new GPoint(-88.55370331,41.59930038),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Millbrook Junior High School",'Millbrook=' + Millbrook.length); Newark[Newark.length] = createMarker(new GPoint(-88.57888794,41.54097748),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Newark Community High School",'Newark=' + Newark.length); Newark[Newark.length] = createMarker(new GPoint(-88.55110168,41.53150177),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Newark Elementary School",'Newark=' + Newark.length); Oswego[Oswego.length] = createMarker(new GPoint(-88.33021545,41.70556641),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Old Post Elementary School",'Oswego=' + Oswego.length); Oswego[Oswego.length] = createMarker(new GPoint(-88.27547500,41.70004000),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Oswego East High School",'Oswego=' + Oswego.length); Oswego[Oswego.length] = createMarker(new GPoint(-88.34194946,41.68375015),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Oswego High School",'Oswego=' + Oswego.length); Oswego[Oswego.length] = createMarker(new GPoint(-88.35154724,41.68290710),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Oswego High School Roe Safe School",'Oswego=' + Oswego.length); Plano[Plano.length] = createMarker(new GPoint(-88.53540039,41.67110443),"",iconRd); mySelect.options[mySelect.options.length] = new Option("P H Miller Elementary School",'Plano=' + Plano.length); Plano[Plano.length] = createMarker(new GPoint(-88.54590607,41.66453552),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Plano High School",'Plano=' + Plano.length); Plano[Plano.length] = createMarker(new GPoint(-88.54590607,41.66453552),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Plano High School Pace Safe School",'Plano=' + Plano.length); Plano[Plano.length] = createMarker(new GPoint(-88.53233337,41.65593338),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Plano Middle School",'Plano=' + Plano.length); Oswego[Oswego.length] = createMarker(new GPoint(-88.34178200,41.64127400),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Prairie Point Elementary School",'Oswego=' + Oswego.length); Oswego[Oswego.length] = createMarker(new GPoint(-88.33512878,41.69549561),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Thompson Junior High School",'Oswego=' + Oswego.length); Oswego[Oswego.length] = createMarker(new GPoint(-88.34801483,41.68022919),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Traughber Junior High School",'Oswego=' + Oswego.length); Yorkville[Yorkville.length] = createMarker(new GPoint(-88.44787598,41.64899063),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Yorkville Grade School",'Yorkville=' + Yorkville.length); Yorkville[Yorkville.length] = createMarker(new GPoint(-88.45147705,41.65124512),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Yorkville High School",'Yorkville=' + Yorkville.length); Yorkville[Yorkville.length] = createMarker(new GPoint(-88.45147705,41.65124512),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Yorkville High School Roe Safe School",'Yorkville=' + Yorkville.length); Yorkville[Yorkville.length] = createMarker(new GPoint(-88.44864600,41.63481200),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Yorkville Intermediate School",'Yorkville=' + Yorkville.length); Yorkville[Yorkville.length] = createMarker(new GPoint(-88.45111084,41.65029907),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Yorkville Middle School",'Yorkville=' + Yorkville.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(Bristol); map.removeOverlays(Millbrook); map.removeOverlays(Montgomery); map.removeOverlays(Newark); map.removeOverlays(Oswego); map.removeOverlays(Plano); map.removeOverlays(Yorkville); 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(Montgomery);map.removeOverlays(Bristol); map.removeOverlays(Millbrook); map.removeOverlays(Montgomery); map.removeOverlays(Newark); map.removeOverlays(Oswego); map.removeOverlays(Plano); map.removeOverlays(Yorkville); map.addOverlays(Bristol); centerByArray(Bristol, false, false); cntMarker += Bristol.length; map.addOverlays(Millbrook); centerByArray(Millbrook, false, false); cntMarker += Millbrook.length; map.addOverlays(Montgomery); centerByArray(Montgomery, false, false); cntMarker += Montgomery.length; map.addOverlays(Newark); centerByArray(Newark, false, false); cntMarker += Newark.length; map.addOverlays(Oswego); centerByArray(Oswego, false, false); cntMarker += Oswego.length; map.addOverlays(Plano); centerByArray(Plano, false, false); cntMarker += Plano.length; map.addOverlays(Yorkville); centerByArray(Yorkville, false, false); cntMarker += Yorkville.length; centerByArray(Montgomery,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'); } }