function addMarkers(){ mySelect = document.getElementById('selection'); Wakefield = [];Wellesley = [];Arlington = [];Milton = [];Cambridge = [];Woburn = [];Roslindale = [];Pittsfield = [];Newton = [];Greenfield = [];Braintree = [];Needham = [];Boston = [];Millis = [];mySelect.options[mySelect.options.length] = new Option("Arlington schools",'all=Arlington'); mySelect.options[mySelect.options.length] = new Option("Boston schools",'all=Boston'); mySelect.options[mySelect.options.length] = new Option("Braintree schools",'all=Braintree'); mySelect.options[mySelect.options.length] = new Option("Cambridge schools",'all=Cambridge'); mySelect.options[mySelect.options.length] = new Option("Greenfield schools",'all=Greenfield'); mySelect.options[mySelect.options.length] = new Option("Millis schools",'all=Millis'); mySelect.options[mySelect.options.length] = new Option("Milton schools",'all=Milton'); mySelect.options[mySelect.options.length] = new Option("Needham schools",'all=Needham'); mySelect.options[mySelect.options.length] = new Option("Newton schools",'all=Newton'); mySelect.options[mySelect.options.length] = new Option("Pittsfield schools",'all=Pittsfield'); mySelect.options[mySelect.options.length] = new Option("Roslindale schools",'all=Roslindale'); mySelect.options[mySelect.options.length] = new Option("Wakefield schools",'all=Wakefield'); mySelect.options[mySelect.options.length] = new Option("Wellesley schools",'all=Wellesley'); mySelect.options[mySelect.options.length] = new Option("Woburn schools",'all=Woburn'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Wakefield[Wakefield.length] = createMarker(new GPoint(-71.07125700,42.50704700),"
Canterbury Childrens Center
5 Bryant Street
Wakefield, MA 01880
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Canterbury Childrens Center",'Wakefield=' + Wakefield.length); Wellesley[Wellesley.length] = createMarker(new GPoint(-71.28781700,42.29194300),"
Dana Hall School
45 Dana Road
Wellesley, MA 02482
All-girls school, 6-12
[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Dana Hall School",'Wellesley=' + Wellesley.length); Arlington[Arlington.length] = createMarker(new GPoint(-71.14110800,42.40722400),"
Dearborn Academy
34 Winter St
Arlington, MA 02474
Co-ed school, 1-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Dearborn Academy",'Arlington=' + Arlington.length); Milton[Milton.length] = createMarker(new GPoint(-71.05998200,42.25859800),"
Fontbonne Academy
930 Brook Road
Milton, MA 02186
All-girls school, 9-12
[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Fontbonne Academy",'Milton=' + Milton.length); Cambridge[Cambridge.length] = createMarker(new GPoint(-71.10457700,42.36308000),"
James F. Farr Academy
71 Pearl Street
Cambridge, MA 02139
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("James F. Farr Academy",'Cambridge=' + Cambridge.length); Woburn[Woburn.length] = createMarker(new GPoint(-71.12802000,42.49603800),"
Little Folks Day School
600 West Cummings Park
Woburn, MA 01801
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Little Folks Day School",'Woburn=' + Woburn.length); Roslindale[Roslindale.length] = createMarker(new GPoint(-71.12236500,42.29205700),"
Little Peoples Playhouse
4019 Washington Street
Roslindale, MA 02131
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Little Peoples Playhouse",'Roslindale=' + Roslindale.length); Pittsfield[Pittsfield.length] = createMarker(new GPoint(-73.24139200,42.42711400),"
Miss Hall's School
492 Holmes Road
Pittsfield, MA 01201
All-girls school, 9-12
[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Miss Hall's School",'Pittsfield=' + Pittsfield.length); Newton[Newton.length] = createMarker(new GPoint(-71.19058500,42.34404900),"
Newton Country Day School
785 Centre Street
Newton, MA 02458
All-girls school, 5-12
[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Newton Country Day School",'Newton=' + Newton.length); Wellesley[Wellesley.length] = createMarker(new GPoint(-71.26268700,42.32456100),"
St. John The Evangelist School
9 Ledyard Street
Wellesley, MA 02481
Co-ed school, PK-6
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. John The Evangelist School",'Wellesley=' + Wellesley.length); Greenfield[Greenfield.length] = createMarker(new GPoint(-72.58266700,42.61255900),"
Stoneleigh Burnham School
574 Bernardston Road
Greenfield, MA 01301
All-girls school, 7-12
[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Stoneleigh Burnham School",'Greenfield=' + Greenfield.length); Braintree[Braintree.length] = createMarker(new GPoint(-71.00397400,42.20869700),"
Thayer Academy
745 Washington Street
Braintree, MA 02184
Co-ed school, 6-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Thayer Academy",'Braintree=' + Braintree.length); Needham[Needham.length] = createMarker(new GPoint(-71.27041600,42.25977100),"
Walker Home And School
1968 Central Ave
Needham, MA 02492
Co-ed school, NS-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Walker Home And School",'Needham=' + Needham.length); Boston[Boston.length] = createMarker(new GPoint(-71.10685800,42.34094200),"
The Winsor School
103 Pilgrim Road
Boston, MA 02215
All-girls school, 5-12
[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("The Winsor School",'Boston=' + Boston.length); Millis[Millis.length] = createMarker(new GPoint(-71.36623300,42.14397500),"
Woodside Montessori Academy
350 Village Street
Millis, MA 02054
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Woodside Montessori Academy",'Millis=' + Millis.length); map.removeOverlays(Arlington); map.removeOverlays(Boston); map.removeOverlays(Braintree); map.removeOverlays(Cambridge); map.removeOverlays(Greenfield); map.removeOverlays(Millis); map.removeOverlays(Milton); map.removeOverlays(Needham); map.removeOverlays(Newton); map.removeOverlays(Pittsfield); map.removeOverlays(Roslindale); map.removeOverlays(Wakefield); map.removeOverlays(Wellesley); map.removeOverlays(Woburn); setTimeout(function(){map.addOverlays(Arlington)},1000); setTimeout(function(){map.addOverlays(Boston)},1000); setTimeout(function(){map.addOverlays(Braintree)},1000); setTimeout(function(){map.addOverlays(Cambridge)},1000); setTimeout(function(){map.addOverlays(Greenfield)},1000); setTimeout(function(){map.addOverlays(Millis)},1000); setTimeout(function(){map.addOverlays(Milton)},1000); setTimeout(function(){map.addOverlays(Needham)},1000); setTimeout(function(){map.addOverlays(Newton)},1000); setTimeout(function(){map.addOverlays(Pittsfield)},1000); setTimeout(function(){map.addOverlays(Roslindale)},1000); setTimeout(function(){map.addOverlays(Wakefield)},1000); setTimeout(function(){map.addOverlays(Wellesley)},1000); setTimeout(function(){map.addOverlays(Woburn)},1000); maxLng = -71.00397400; maxLat = 42.61255900; minLng = -73.24139200; minLat = 42.14397500; 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(Arlington); map.removeOverlays(Boston); map.removeOverlays(Braintree); map.removeOverlays(Cambridge); map.removeOverlays(Greenfield); map.removeOverlays(Millis); map.removeOverlays(Milton); map.removeOverlays(Needham); map.removeOverlays(Newton); map.removeOverlays(Pittsfield); map.removeOverlays(Roslindale); map.removeOverlays(Wakefield); map.removeOverlays(Wellesley); map.removeOverlays(Woburn); 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(Wakefield);map.removeOverlays(Arlington); map.removeOverlays(Boston); map.removeOverlays(Braintree); map.removeOverlays(Cambridge); map.removeOverlays(Greenfield); map.removeOverlays(Millis); map.removeOverlays(Milton); map.removeOverlays(Needham); map.removeOverlays(Newton); map.removeOverlays(Pittsfield); map.removeOverlays(Roslindale); map.removeOverlays(Wakefield); map.removeOverlays(Wellesley); map.removeOverlays(Woburn); map.addOverlays(Arlington); centerByArray(Arlington, false, false); cntMarker += Arlington.length; map.addOverlays(Boston); centerByArray(Boston, false, false); cntMarker += Boston.length; map.addOverlays(Braintree); centerByArray(Braintree, false, false); cntMarker += Braintree.length; map.addOverlays(Cambridge); centerByArray(Cambridge, false, false); cntMarker += Cambridge.length; map.addOverlays(Greenfield); centerByArray(Greenfield, false, false); cntMarker += Greenfield.length; map.addOverlays(Millis); centerByArray(Millis, false, false); cntMarker += Millis.length; map.addOverlays(Milton); centerByArray(Milton, false, false); cntMarker += Milton.length; map.addOverlays(Needham); centerByArray(Needham, false, false); cntMarker += Needham.length; map.addOverlays(Newton); centerByArray(Newton, false, false); cntMarker += Newton.length; map.addOverlays(Pittsfield); centerByArray(Pittsfield, false, false); cntMarker += Pittsfield.length; map.addOverlays(Roslindale); centerByArray(Roslindale, false, false); cntMarker += Roslindale.length; map.addOverlays(Wakefield); centerByArray(Wakefield, false, false); cntMarker += Wakefield.length; map.addOverlays(Wellesley); centerByArray(Wellesley, false, false); cntMarker += Wellesley.length; map.addOverlays(Woburn); centerByArray(Woburn, false, false); cntMarker += Woburn.length; centerByArray(Wakefield,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///13000,13500,13457,13091,30643,13032,13201,13161,12997,13000,13500,13457,13533,13495,13201,35296,12948,12997,13361,13631,/all'); //window.open('/map.php?type=2&schools=13000,13500,13457,13091,30643,13032,13201,13161,12997,13000,13500,13457,13533,13495,13201,35296,12948,12997,13361,13631,&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; }