function addMarkers() { mySelect = document.getElementById('selection'); Bellevue = [];Willard = [];Norwalk = [];Monroeville = [];Collins = [];New_Haven = [];New_London = [];New = [];Greenwich = [];Wakeman = [];mySelect.options[mySelect.options.length] = new Option("Bellevue schools",'all=Bellevue'); mySelect.options[mySelect.options.length] = new Option("Collins schools",'all=Collins'); mySelect.options[mySelect.options.length] = new Option("Greenwich schools",'all=Greenwich'); mySelect.options[mySelect.options.length] = new Option("Monroeville schools",'all=Monroeville'); mySelect.options[mySelect.options.length] = new Option("New schools",'all=New'); mySelect.options[mySelect.options.length] = new Option("New Haven schools",'all=New_Haven'); mySelect.options[mySelect.options.length] = new Option("New London schools",'all=New_London'); mySelect.options[mySelect.options.length] = new Option("Norwalk schools",'all=Norwalk'); mySelect.options[mySelect.options.length] = new Option("Wakeman schools",'all=Wakeman'); mySelect.options[mySelect.options.length] = new Option("Willard schools",'all=Willard'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Bellevue[Bellevue.length] = createMarker(new GPoint(-82.83838654,41.27458954),"
",iconBl); mySelect.options[mySelect.options.length] = new Option("Bellevue Junior High School",'Bellevue=' + Bellevue.length); Willard[Willard.length] = createMarker(new GPoint(-82.72893524,41.05633545),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Willard=' + Willard.length); Norwalk[Norwalk.length] = createMarker(new GPoint(-82.60446930,41.22697067),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Gerken Center Preschool",'Norwalk=' + Norwalk.length); Monroeville[Monroeville.length] = createMarker(new GPoint(-82.67999268,41.10503769),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Greenfield Elementary School",'Monroeville=' + Monroeville.length); Collins[Collins.length] = createMarker(new GPoint(-82.48995209,41.17543793),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hartland Elementary School",'Collins=' + Collins.length); Norwalk[Norwalk.length] = createMarker(new GPoint(-82.61681366,41.24863815),"",iconRd); mySelect.options[mySelect.options.length] = new Option("League Elementary School",'Norwalk=' + Norwalk.length); Bellevue[Bellevue.length] = createMarker(new GPoint(-82.76554108,41.26032257),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lyme Elementary School",'Bellevue=' + Bellevue.length); Norwalk[Norwalk.length] = createMarker(new GPoint(-82.61131500,41.24435700),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Main Street School",'Norwalk=' + Norwalk.length); Norwalk[Norwalk.length] = createMarker(new GPoint(-82.59916687,41.25149918),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Maplehurst Elementary School",'Norwalk=' + Norwalk.length); Monroeville[Monroeville.length] = createMarker(new GPoint(-82.70141602,41.24603271),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Monroeville Elementary School",'Monroeville=' + Monroeville.length); Monroeville[Monroeville.length] = createMarker(new GPoint(-82.70141602,41.24603271),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Monroeville High School",'Monroeville=' + Monroeville.length); New_Haven[New_Haven.length] = createMarker(new GPoint(-82.68160248,41.03160095),"",iconRd); mySelect.options[mySelect.options.length] = new Option("New Haven Elementary School",'New_Haven=' + New_Haven.length); New_London[New_London.length] = createMarker(new GPoint(-82.39337921,41.07436371),"",iconRd); mySelect.options[mySelect.options.length] = new Option("New London Elementary School",'New_London=' + New_London.length); New_London[New_London.length] = createMarker(new GPoint(-82.39337921,41.07436371),"",iconGr); mySelect.options[mySelect.options.length] = new Option("New London High School",'New_London=' + New_London.length); New_London[New_London.length] = createMarker(new GPoint(-82.39337921,41.07436371),"",iconBl); mySelect.options[mySelect.options.length] = new Option("New London Middle School",'New_London=' + New_London.length); New[New.length] = createMarker(new GPoint(-10.00000000,10.00000000),"",iconRd); mySelect.options[mySelect.options.length] = new Option("New London Public Preschool",'New=' + New.length); Norwalk[Norwalk.length] = createMarker(new GPoint(-82.61170197,41.22463989),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Norwalk High School",'Norwalk=' + Norwalk.length); Norwalk[Norwalk.length] = createMarker(new GPoint(-82.60980225,41.22987747),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Norwalk Middle School",'Norwalk=' + Norwalk.length); Norwalk[Norwalk.length] = createMarker(new GPoint(-82.62181854,41.23820877),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pleasant Elementary School",'Norwalk=' + Norwalk.length); Willard[Willard.length] = createMarker(new GPoint(-82.78231812,41.04876709),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Richmond Elementary School",'Willard=' + Willard.length); Bellevue[Bellevue.length] = createMarker(new GPoint(-82.82240295,41.27304077),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Ridge Elementary School",'Bellevue=' + Bellevue.length); Bellevue[Bellevue.length] = createMarker(new GPoint(-82.83740234,41.28556061),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Shumaker Elementary School",'Bellevue=' + Bellevue.length); Greenwich[Greenwich.length] = createMarker(new GPoint(-82.51786400,41.02989100),"",iconRd); mySelect.options[mySelect.options.length] = new Option("South Central Elementary School",'Greenwich=' + Greenwich.length); Greenwich[Greenwich.length] = createMarker(new GPoint(-82.51904297,41.05002594),"",iconGr); mySelect.options[mySelect.options.length] = new Option("South Central High School",'Greenwich=' + Greenwich.length); Wakeman[Wakeman.length] = createMarker(new GPoint(-82.39936829,41.25274658),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wakeman Elementary School",'Wakeman=' + Wakeman.length); Collins[Collins.length] = createMarker(new GPoint(-82.49311829,41.24824142),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Western Reserve Elementary School",'Collins=' + Collins.length); Collins[Collins.length] = createMarker(new GPoint(-82.48570251,41.24050140),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Western Reserve High School",'Collins=' + Collins.length); Collins[Collins.length] = createMarker(new GPoint(-82.44772339,41.24705505),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Western Reserve Middle School",'Collins=' + Collins.length); Willard[Willard.length] = createMarker(new GPoint(-82.72599792,41.06679916),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Willard High School",'Willard=' + Willard.length); Willard[Willard.length] = createMarker(new GPoint(-82.73228455,41.04606247),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Willard Middle School",'Willard=' + Willard.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(Bellevue); map.removeOverlays(Collins); map.removeOverlays(Greenwich); map.removeOverlays(Monroeville); map.removeOverlays(New); map.removeOverlays(New_Haven); map.removeOverlays(New_London); map.removeOverlays(Norwalk); map.removeOverlays(Wakeman); map.removeOverlays(Willard); 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(Bellevue);map.removeOverlays(Bellevue); map.removeOverlays(Collins); map.removeOverlays(Greenwich); map.removeOverlays(Monroeville); map.removeOverlays(New); map.removeOverlays(New_Haven); map.removeOverlays(New_London); map.removeOverlays(Norwalk); map.removeOverlays(Wakeman); map.removeOverlays(Willard); map.addOverlays(Bellevue); centerByArray(Bellevue, false, false); cntMarker += Bellevue.length; map.addOverlays(Collins); centerByArray(Collins, false, false); cntMarker += Collins.length; map.addOverlays(Greenwich); centerByArray(Greenwich, false, false); cntMarker += Greenwich.length; map.addOverlays(Monroeville); centerByArray(Monroeville, false, false); cntMarker += Monroeville.length; map.addOverlays(New); centerByArray(New, false, false); cntMarker += New.length; map.addOverlays(New_Haven); centerByArray(New_Haven, false, false); cntMarker += New_Haven.length; map.addOverlays(New_London); centerByArray(New_London, false, false); cntMarker += New_London.length; map.addOverlays(Norwalk); centerByArray(Norwalk, false, false); cntMarker += Norwalk.length; map.addOverlays(Wakeman); centerByArray(Wakeman, false, false); cntMarker += Wakeman.length; map.addOverlays(Willard); centerByArray(Willard, false, false); cntMarker += Willard.length; centerByArray(Bellevue,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'); } }