function addMarkers(){ mySelect = document.getElementById('selection'); Plymouth = [];Hanover = [];Brockton = [];Hingham = [];Middleboro = [];Rockland = [];East_Bridgewater = [];West_Bridgewater = [];Kingston = [];Marion = [];mySelect.options[mySelect.options.length] = new Option("Brockton schools",'all=Brockton'); mySelect.options[mySelect.options.length] = new Option("East Bridgewater schools",'all=East_Bridgewater'); mySelect.options[mySelect.options.length] = new Option("Hanover schools",'all=Hanover'); mySelect.options[mySelect.options.length] = new Option("Hingham schools",'all=Hingham'); mySelect.options[mySelect.options.length] = new Option("Kingston schools",'all=Kingston'); mySelect.options[mySelect.options.length] = new Option("Marion schools",'all=Marion'); mySelect.options[mySelect.options.length] = new Option("Middleboro schools",'all=Middleboro'); mySelect.options[mySelect.options.length] = new Option("Plymouth schools",'all=Plymouth'); mySelect.options[mySelect.options.length] = new Option("Rockland schools",'all=Rockland'); mySelect.options[mySelect.options.length] = new Option("West Bridgewater schools",'all=West_Bridgewater'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Plymouth[Plymouth.length] = createMarker(new GPoint(-70.58658800,41.85841600),"
The Baird Center
900 Ship Pond Road
Plymouth, MA 02360
All-boys school, 3-11
[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("The Baird Center",'Plymouth=' + Plymouth.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); Brockton[Brockton.length] = createMarker(new GPoint(-70.99375100,42.09404800),"
Cardinal Spellman High School
738 Court Street
Brockton, MA 02302
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cardinal Spellman High School",'Brockton=' + Brockton.length); Hingham[Hingham.length] = createMarker(new GPoint(-70.89261500,42.24897900),"
Derby Academy
56 Burditt Avenue
Hingham, MA 02043
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Derby Academy",'Hingham=' + Hingham.length); Plymouth[Plymouth.length] = createMarker(new GPoint(-70.73633600,41.93145000),"
Fellowship Christian Academy
267 Carver Rd
Plymouth, MA 02360
Co-ed school, PK-9
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Fellowship Christian Academy",'Plymouth=' + Plymouth.length); Middleboro[Middleboro.length] = createMarker(new GPoint(-70.89460000,41.88850000),"
Fl Chamberlain School
Po Box 778 1 Pleasant Street
Middleboro, MA 02346
Co-ed school, 7-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Fl Chamberlain School",'Middleboro=' + Middleboro.length); Rockland[Rockland.length] = createMarker(new GPoint(-70.90507500,42.09468700),"
The Master's Academy
525 Beech Street
Rockland, MA 02370
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Master's Academy",'Rockland=' + Rockland.length); Brockton[Brockton.length] = createMarker(new GPoint(-71.00370700,42.06277700),"
May Center For Education And Neurorehabilitation
596 Summer Street
Brockton, MA 02302
Co-ed school, 1-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("May Center For Education And Neurorehabilitation",'Brockton=' + Brockton.length); East_Bridgewater[East_Bridgewater.length] = createMarker(new GPoint(-70.99285900,42.08584500),"
Metro South Academy
450 Pleasant Street
East Bridgewater, MA 02333
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Metro South Academy",'East_Bridgewater=' + East_Bridgewater.length); West_Bridgewater[West_Bridgewater.length] = createMarker(new GPoint(-71.00908400,42.03479500),"
New England Baptist Academy
560 North Main Street
West Bridgewater, MA 02379
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("New England Baptist Academy",'West_Bridgewater=' + West_Bridgewater.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); Hingham[Hingham.length] = createMarker(new GPoint(-70.88396900,42.18415800),"
Notre Dame Academy School
1073 Main Street
Hingham, MA 02043
All-girls school, 9-12
[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Notre Dame Academy School",'Hingham=' + Hingham.length); Plymouth[Plymouth.length] = createMarker(new GPoint(-70.65915000,41.94330400),"
Radius Pediatric Center Day School At Plymouth
123 South Street
Plymouth, MA 02360
Co-ed school, 6-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Radius Pediatric Center Day School At Plymouth",'Plymouth=' + Plymouth.length); Kingston[Kingston.length] = createMarker(new GPoint(-70.73514200,41.94566300),"
Sacred Heart High School
399 Bishops Highway
Kingston, MA 02364
Co-ed school, 7-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Sacred Heart High School",'Kingston=' + Kingston.length); Middleboro[Middleboro.length] = createMarker(new GPoint(-70.97796800,41.93272400),"
Southeast Alternative School
49 Plymouth Street
Middleboro, MA 02346
Co-ed school, 8-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Southeast Alternative School",'Middleboro=' + Middleboro.length); Marion[Marion.length] = createMarker(new GPoint(-70.76793000,41.70749600),"
Tabor Academy
66 Spring Street
Marion, MA 02738
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Tabor Academy",'Marion=' + Marion.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(Brockton); map.removeOverlays(East_Bridgewater); map.removeOverlays(Hanover); map.removeOverlays(Hingham); map.removeOverlays(Kingston); map.removeOverlays(Marion); map.removeOverlays(Middleboro); map.removeOverlays(Plymouth); map.removeOverlays(Rockland); map.removeOverlays(West_Bridgewater); 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(Plymouth);map.removeOverlays(Brockton); map.removeOverlays(East_Bridgewater); map.removeOverlays(Hanover); map.removeOverlays(Hingham); map.removeOverlays(Kingston); map.removeOverlays(Marion); map.removeOverlays(Middleboro); map.removeOverlays(Plymouth); map.removeOverlays(Rockland); map.removeOverlays(West_Bridgewater); map.addOverlays(Brockton); centerByArray(Brockton, false, false); cntMarker += Brockton.length; map.addOverlays(East_Bridgewater); centerByArray(East_Bridgewater, false, false); cntMarker += East_Bridgewater.length; map.addOverlays(Hanover); centerByArray(Hanover, false, false); cntMarker += Hanover.length; map.addOverlays(Hingham); centerByArray(Hingham, false, false); cntMarker += Hingham.length; map.addOverlays(Kingston); centerByArray(Kingston, false, false); cntMarker += Kingston.length; map.addOverlays(Marion); centerByArray(Marion, false, false); cntMarker += Marion.length; map.addOverlays(Middleboro); centerByArray(Middleboro, false, false); cntMarker += Middleboro.length; map.addOverlays(Plymouth); centerByArray(Plymouth, false, false); cntMarker += Plymouth.length; map.addOverlays(Rockland); centerByArray(Rockland, false, false); cntMarker += Rockland.length; map.addOverlays(West_Bridgewater); centerByArray(West_Bridgewater, false, false); cntMarker += West_Bridgewater.length; centerByArray(Plymouth,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; }