function addMarkers(){ mySelect = document.getElementById('selection'); W_Springfield = [];West_Springfield = [];Springfield = [];Palmer = [];Chicopee = [];Holyoke = [];Westfield = [];Wilbraham = [];Longmeadow = [];mySelect.options[mySelect.options.length] = new Option("Chicopee schools",'all=Chicopee'); mySelect.options[mySelect.options.length] = new Option("Holyoke schools",'all=Holyoke'); mySelect.options[mySelect.options.length] = new Option("Longmeadow schools",'all=Longmeadow'); mySelect.options[mySelect.options.length] = new Option("Palmer schools",'all=Palmer'); mySelect.options[mySelect.options.length] = new Option("Springfield schools",'all=Springfield'); mySelect.options[mySelect.options.length] = new Option("W Springfield schools",'all=W_Springfield'); mySelect.options[mySelect.options.length] = new Option("West Springfield schools",'all=West_Springfield'); mySelect.options[mySelect.options.length] = new Option("Westfield schools",'all=Westfield'); mySelect.options[mySelect.options.length] = new Option("Wilbraham schools",'all=Wilbraham'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); W_Springfield[W_Springfield.length] = createMarker(new GPoint(-72.64717700,42.13122500),"
Bible Bapist Academy
575 Morgan Rd
W. Springfield, MA 01089
Co-ed school, KG-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bible Bapist Academy",'W_Springfield=' + W_Springfield.length); West_Springfield[West_Springfield.length] = createMarker(new GPoint(-72.63338000,42.16047900),"
Brightside
2112 Riverdale Street
West Springfield, MA 01089
Co-ed school, 3-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Brightside",'West_Springfield=' + West_Springfield.length); Springfield[Springfield.length] = createMarker(new GPoint(-72.54178000,42.09922500),"
Cathedral High School
260 Surrey Road
Springfield, MA 01118
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cathedral High School",'Springfield=' + Springfield.length); Palmer[Palmer.length] = createMarker(new GPoint(-72.33133500,42.16919600),"
Faith Baptist Christian Academy
251 Shearer Street
Palmer, MA 01069
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Faith Baptist Christian Academy",'Palmer=' + Palmer.length); Chicopee[Chicopee.length] = createMarker(new GPoint(-72.60471400,42.14583300),"
Holyoke Catholic High School
134 Springfield Street
Chicopee, MA 01013
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Holyoke Catholic High School",'Chicopee=' + Chicopee.length); Holyoke[Holyoke.length] = createMarker(new GPoint(-72.60443700,42.20358300),"
Holyoke Street School
130 Race Street
Holyoke, MA 01040
Co-ed school, 6-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Holyoke Street School",'Holyoke=' + Holyoke.length); Springfield[Springfield.length] = createMarker(new GPoint(-72.57624000,42.09797200),"
The Macduffie School
1 Ames Hill Drive
Springfield, MA 01105
Co-ed school, 6-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Macduffie School",'Springfield=' + Springfield.length); Springfield[Springfield.length] = createMarker(new GPoint(-72.49542300,42.11342400),"
Mill Pond
91 Old Acre Rd
Springfield, MA 01129
Co-ed school, Nursery
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Mill Pond",'Springfield=' + Springfield.length); Holyoke[Holyoke.length] = createMarker(new GPoint(-72.59541300,42.20499600),"
Neari School
70 N Summer Street
Holyoke, MA 01040
Co-ed school, 4-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Neari School",'Holyoke=' + Holyoke.length); West_Springfield[West_Springfield.length] = createMarker(new GPoint(-72.62271900,42.13830400),"
Pace School
69 Capital Drive
West Springfield, MA 01089
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Pace School",'West_Springfield=' + West_Springfield.length); Springfield[Springfield.length] = createMarker(new GPoint(-72.51653300,42.10400100),"
Pioneer Valley Christian School
965 Plumtree Road
Springfield, MA 01119
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Pioneer Valley Christian School",'Springfield=' + Springfield.length); Holyoke[Holyoke.length] = createMarker(new GPoint(-72.61129000,42.20477900),"
Springdale Education Center
317 Maple Street Ste 2
Holyoke, MA 01040
Co-ed school, 3-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Springdale Education Center",'Holyoke=' + Holyoke.length); Westfield[Westfield.length] = createMarker(new GPoint(-72.74699900,42.12531900),"
St Mary High School
27 Bartlett Street
Westfield, MA 01085
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Mary High School",'Westfield=' + Westfield.length); Chicopee[Chicopee.length] = createMarker(new GPoint(-72.59176900,42.13743800),"
Valley West School
269 Moore Street
Chicopee, MA 01013
Co-ed school, 1-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Valley West School",'Chicopee=' + Chicopee.length); Westfield[Westfield.length] = createMarker(new GPoint(-72.73492600,42.18410800),"
White Oak School
533 North Road
Westfield, MA 01085
Co-ed school, 5-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("White Oak School",'Westfield=' + Westfield.length); Wilbraham[Wilbraham.length] = createMarker(new GPoint(-72.43129700,42.12520700),"
Wilbraham And Monson Academy
423 Main Street
Wilbraham, MA 01095
Co-ed school, 6-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Wilbraham And Monson Academy",'Wilbraham=' + Wilbraham.length); Longmeadow[Longmeadow.length] = createMarker(new GPoint(-72.57744600,42.03095700),"
Willie Ross School For Deaf
32 Norway Street
Longmeadow, MA 01106
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Willie Ross School For Deaf",'Longmeadow=' + Longmeadow.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,11); /* 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/////2/' + showArray); map.removeOverlays(Chicopee); map.removeOverlays(Holyoke); map.removeOverlays(Longmeadow); map.removeOverlays(Palmer); map.removeOverlays(Springfield); map.removeOverlays(W_Springfield); map.removeOverlays(West_Springfield); map.removeOverlays(Westfield); map.removeOverlays(Wilbraham); 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(W_Springfield);map.removeOverlays(Chicopee); map.removeOverlays(Holyoke); map.removeOverlays(Longmeadow); map.removeOverlays(Palmer); map.removeOverlays(Springfield); map.removeOverlays(W_Springfield); map.removeOverlays(West_Springfield); map.removeOverlays(Westfield); map.removeOverlays(Wilbraham); map.addOverlays(Chicopee); centerByArray(Chicopee, false, false); cntMarker += Chicopee.length; map.addOverlays(Holyoke); centerByArray(Holyoke, false, false); cntMarker += Holyoke.length; map.addOverlays(Longmeadow); centerByArray(Longmeadow, false, false); cntMarker += Longmeadow.length; map.addOverlays(Palmer); centerByArray(Palmer, false, false); cntMarker += Palmer.length; map.addOverlays(Springfield); centerByArray(Springfield, false, false); cntMarker += Springfield.length; map.addOverlays(W_Springfield); centerByArray(W_Springfield, false, false); cntMarker += W_Springfield.length; map.addOverlays(West_Springfield); centerByArray(West_Springfield, false, false); cntMarker += West_Springfield.length; map.addOverlays(Westfield); centerByArray(Westfield, false, false); cntMarker += Westfield.length; map.addOverlays(Wilbraham); centerByArray(Wilbraham, false, false); cntMarker += Wilbraham.length; centerByArray(W_Springfield,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'); //window.open('/map.php?type=1&schools=&school_level=2&radius=&zipcode=&school_type_search=&school_type_code='); } } function createMarker(point, label, icon) { var marker = new GMarker(point, icon); var html = label; GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); return marker; }