function addMarkers(){ mySelect = document.getElementById('selection'); Braintree = [];Amherst = [];Lexington = [];Hanover = [];Roxbury = [];Hadley = [];Attleboro = [];Lowell = [];Plymouth = [];Duxbury = [];Springfield = [];Framingham = [];West_Barnstable = [];mySelect.options[mySelect.options.length] = new Option("Amherst schools",'all=Amherst'); mySelect.options[mySelect.options.length] = new Option("Attleboro schools",'all=Attleboro'); mySelect.options[mySelect.options.length] = new Option("Braintree schools",'all=Braintree'); mySelect.options[mySelect.options.length] = new Option("Duxbury schools",'all=Duxbury'); mySelect.options[mySelect.options.length] = new Option("Framingham schools",'all=Framingham'); mySelect.options[mySelect.options.length] = new Option("Hadley schools",'all=Hadley'); mySelect.options[mySelect.options.length] = new Option("Hanover schools",'all=Hanover'); mySelect.options[mySelect.options.length] = new Option("Lexington schools",'all=Lexington'); mySelect.options[mySelect.options.length] = new Option("Lowell schools",'all=Lowell'); mySelect.options[mySelect.options.length] = new Option("Plymouth schools",'all=Plymouth'); mySelect.options[mySelect.options.length] = new Option("Roxbury schools",'all=Roxbury'); mySelect.options[mySelect.options.length] = new Option("Springfield schools",'all=Springfield'); mySelect.options[mySelect.options.length] = new Option("West Barnstable schools",'all=West_Barnstable'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Braintree[Braintree.length] = createMarker(new GPoint(-71.01411900,42.20850600),"
Alice Burke School Inc
252 Franklin Street
Braintree, MA 02184
Co-ed school, PK-KG
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Alice Burke School Inc",'Braintree=' + Braintree.length); Amherst[Amherst.length] = createMarker(new GPoint(-72.51873100,42.33989000),"
Amherst Montessori School
27 Pomeroy Lane
Amherst, MA 01002
Co-ed school, PK-4
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Amherst Montessori School",'Amherst=' + Amherst.length); Lexington[Lexington.length] = createMarker(new GPoint(-71.21611900,42.43983700),"
Armenian Sisters Academy
6 Eliot Road
Lexington, MA 02421
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Armenian Sisters Academy",'Lexington=' + Lexington.length); Hanover[Hanover.length] = createMarker(new GPoint(-70.81952600,42.11668300),"
Cardinal Cushing Centers, Inc.
405 Washington Street
Hanover, MA 02339
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cardinal Cushing Centers, Inc.",'Hanover=' + Hanover.length); Roxbury[Roxbury.length] = createMarker(new GPoint(-71.08595500,42.32125500),"
Eliot Educational Center
56 Dale Street
Roxbury, MA 02119
Co-ed school, KG-2
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Eliot Educational Center",'Roxbury=' + Roxbury.length); Hadley[Hadley.length] = createMarker(new GPoint(-72.56254200,42.32996800),"
Hartsbrook Waldorf School
193 Bay Road
Hadley, MA 01035
Co-ed school, NS-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Hartsbrook Waldorf School",'Hadley=' + Hadley.length); Attleboro[Attleboro.length] = createMarker(new GPoint(-71.29102700,41.96775400),"
Little Blessings Preschool
841 N Main Street
Attleboro, MA 02703
Co-ed school, NS-PK
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Little Blessings Preschool",'Attleboro=' + Attleboro.length); Lowell[Lowell.length] = createMarker(new GPoint(-71.37163100,42.64680400),"
Merrimack Valley Christian Day
1195 Varnum Avenue
Lowell, MA 01854
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Merrimack Valley Christian Day",'Lowell=' + Lowell.length); Plymouth[Plymouth.length] = createMarker(new GPoint(-70.55881300,41.81264500),"
New Testament Christian School
1120 Long Pond Road
Plymouth, MA 02360
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("New Testament Christian School",'Plymouth=' + Plymouth.length); Duxbury[Duxbury.length] = createMarker(new GPoint(-70.73723200,42.03237300),"
Noahs Ark Day School
136 Summer Street
Duxbury, MA 02332
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Noahs Ark Day School",'Duxbury=' + Duxbury.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); Framingham[Framingham.length] = createMarker(new GPoint(-71.46463200,42.32343200),"
Reed Academy
1 Winch Street
Framingham, MA 01701
All-boys school, 2-11
[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Reed Academy",'Framingham=' + Framingham.length); West_Barnstable[West_Barnstable.length] = createMarker(new GPoint(-70.37330000,41.70030000),"
West Parish Family School
P.o. Box 219
West Barnstable, MA 02668
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("West Parish Family School",'West_Barnstable=' + West_Barnstable.length); map.removeOverlays(Amherst); map.removeOverlays(Attleboro); map.removeOverlays(Braintree); map.removeOverlays(Duxbury); map.removeOverlays(Framingham); map.removeOverlays(Hadley); map.removeOverlays(Hanover); map.removeOverlays(Lexington); map.removeOverlays(Lowell); map.removeOverlays(Plymouth); map.removeOverlays(Roxbury); map.removeOverlays(Springfield); map.removeOverlays(West_Barnstable); setTimeout(function(){map.addOverlays(Amherst)},1000); setTimeout(function(){map.addOverlays(Attleboro)},1000); setTimeout(function(){map.addOverlays(Braintree)},1000); setTimeout(function(){map.addOverlays(Duxbury)},1000); setTimeout(function(){map.addOverlays(Framingham)},1000); setTimeout(function(){map.addOverlays(Hadley)},1000); setTimeout(function(){map.addOverlays(Hanover)},1000); setTimeout(function(){map.addOverlays(Lexington)},1000); setTimeout(function(){map.addOverlays(Lowell)},1000); setTimeout(function(){map.addOverlays(Plymouth)},1000); setTimeout(function(){map.addOverlays(Roxbury)},1000); setTimeout(function(){map.addOverlays(Springfield)},1000); setTimeout(function(){map.addOverlays(West_Barnstable)},1000); maxLng = -70.37330000; maxLat = 42.64680400; minLng = -72.56254200; minLat = 41.70030000; reCenterMap(); } // 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//////' + showArray); map.removeOverlays(Amherst); map.removeOverlays(Attleboro); map.removeOverlays(Braintree); map.removeOverlays(Duxbury); map.removeOverlays(Framingham); map.removeOverlays(Hadley); map.removeOverlays(Hanover); map.removeOverlays(Lexington); map.removeOverlays(Lowell); map.removeOverlays(Plymouth); map.removeOverlays(Roxbury); map.removeOverlays(Springfield); map.removeOverlays(West_Barnstable); 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(Braintree);map.removeOverlays(Amherst); map.removeOverlays(Attleboro); map.removeOverlays(Braintree); map.removeOverlays(Duxbury); map.removeOverlays(Framingham); map.removeOverlays(Hadley); map.removeOverlays(Hanover); map.removeOverlays(Lexington); map.removeOverlays(Lowell); map.removeOverlays(Plymouth); map.removeOverlays(Roxbury); map.removeOverlays(Springfield); map.removeOverlays(West_Barnstable); map.addOverlays(Amherst); centerByArray(Amherst, false, false); cntMarker += Amherst.length; map.addOverlays(Attleboro); centerByArray(Attleboro, false, false); cntMarker += Attleboro.length; map.addOverlays(Braintree); centerByArray(Braintree, false, false); cntMarker += Braintree.length; map.addOverlays(Duxbury); centerByArray(Duxbury, false, false); cntMarker += Duxbury.length; map.addOverlays(Framingham); centerByArray(Framingham, false, false); cntMarker += Framingham.length; map.addOverlays(Hadley); centerByArray(Hadley, false, false); cntMarker += Hadley.length; map.addOverlays(Hanover); centerByArray(Hanover, false, false); cntMarker += Hanover.length; map.addOverlays(Lexington); centerByArray(Lexington, false, false); cntMarker += Lexington.length; map.addOverlays(Lowell); centerByArray(Lowell, false, false); cntMarker += Lowell.length; map.addOverlays(Plymouth); centerByArray(Plymouth, false, false); cntMarker += Plymouth.length; map.addOverlays(Roxbury); centerByArray(Roxbury, false, false); cntMarker += Roxbury.length; map.addOverlays(Springfield); centerByArray(Springfield, false, false); cntMarker += Springfield.length; map.addOverlays(West_Barnstable); centerByArray(West_Barnstable, false, false); cntMarker += West_Barnstable.length; centerByArray(Braintree,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///13254,13051,12953,33576,13248,12887,32497,13542,13654,13254,13051,12953,12896,13643,33576,13591,13248,13706,/all'); //window.open('/map.php?type=2&schools=13254,13051,12953,33576,13248,12887,32497,13542,13654,13254,13051,12953,12896,13643,33576,13591,13248,13706,&school_level=&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; }