function addMarkers(){ mySelect = document.getElementById('selection'); Lenox = [];Pittsfield = [];Housatonic = [];Stockbridge = [];Great_Barrington = [];Lee = [];New_Marlborough = [];Williamstown = [];Dalton = [];Adams = [];mySelect.options[mySelect.options.length] = new Option("Adams schools",'all=Adams'); mySelect.options[mySelect.options.length] = new Option("Dalton schools",'all=Dalton'); mySelect.options[mySelect.options.length] = new Option("Great Barrington schools",'all=Great_Barrington'); mySelect.options[mySelect.options.length] = new Option("Housatonic schools",'all=Housatonic'); mySelect.options[mySelect.options.length] = new Option("Lee schools",'all=Lee'); mySelect.options[mySelect.options.length] = new Option("Lenox schools",'all=Lenox'); mySelect.options[mySelect.options.length] = new Option("New Marlborough schools",'all=New_Marlborough'); mySelect.options[mySelect.options.length] = new Option("Pittsfield schools",'all=Pittsfield'); mySelect.options[mySelect.options.length] = new Option("Stockbridge schools",'all=Stockbridge'); mySelect.options[mySelect.options.length] = new Option("Williamstown schools",'all=Williamstown'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Lenox[Lenox.length] = createMarker(new GPoint(-73.27200000,42.35750000),"
Berkshire Christian Schools
Po Box 1980
Lenox, MA 01240
Co-ed school, PK-10
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Berkshire Christian Schools",'Lenox=' + Lenox.length); Lenox[Lenox.length] = createMarker(new GPoint(-73.26246900,42.35982000),"
Berkshire Country Day School
PO Box 867
Lenox, MA 01240
Co-ed school, NS-9
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Berkshire Country Day School",'Lenox=' + Lenox.length); Pittsfield[Pittsfield.length] = createMarker(new GPoint(-73.24990000,42.44920000),"
Berkshire Hills Sda School
Po Box 2959
Pittsfield, MA 01202
Co-ed school, 3-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Berkshire Hills Sda School",'Pittsfield=' + Pittsfield.length); Housatonic[Housatonic.length] = createMarker(new GPoint(-73.36648900,42.23037600),"
Berkshire Meadows
249 North Plain Rd
Housatonic, MA 01236
Co-ed school, NS-NS
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Berkshire Meadows",'Housatonic=' + Housatonic.length); Stockbridge[Stockbridge.length] = createMarker(new GPoint(-73.31410000,42.29020000),"
Desisto School
Rte 183
Stockbridge, MA 01262
Co-ed school, Ungraded
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Desisto School",'Stockbridge=' + Stockbridge.length); Great_Barrington[Great_Barrington.length] = createMarker(new GPoint(-73.29733000,42.18531300),"
Eagleton School
446 Monterey Rd
Great Barrington, MA 01230
All-boys school, 4-12
[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Eagleton School",'Great_Barrington=' + Great_Barrington.length); Lee[Lee.length] = createMarker(new GPoint(-73.24875800,42.30868300),"
Frontline Church School
160 High Street
Lee, MA 01238
Co-ed school, 1-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Frontline Church School",'Lee=' + Lee.length); Great_Barrington[Great_Barrington.length] = createMarker(new GPoint(-73.40440900,42.19045900),"
Great Barrington Rudolf Steiner School
35 W Plain Road
Great Barrington, MA 01230
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Great Barrington Rudolf Steiner School",'Great_Barrington=' + Great_Barrington.length); Pittsfield[Pittsfield.length] = createMarker(new GPoint(-73.24990000,42.44920000),"
Hillcrest Educatnl Ctrs, Highp
P.o. Box 4699
Pittsfield, MA 01202
All-boys school, NS-NS
[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Hillcrest Educatnl Ctrs, Highp",'Pittsfield=' + Pittsfield.length); Pittsfield[Pittsfield.length] = createMarker(new GPoint(-73.24990000,42.44920000),"
Hillcrest-brookside
P.o.box 183
Pittsfield, MA 01202
All-boys school, NS-NS
[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Hillcrest-brookside",'Pittsfield=' + Pittsfield.length); Pittsfield[Pittsfield.length] = createMarker(new GPoint(-73.25422100,42.44740800),"
Housatonic Academy
Po Box 4699
Pittsfield, MA 01202
Co-ed school, 4-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Housatonic Academy",'Pittsfield=' + Pittsfield.length); New_Marlborough[New_Marlborough.length] = createMarker(new GPoint(-73.23043100,42.11991900),"
Kolburne School
343 Nm Southfield Road
New Marlborough, MA 01230
Co-ed school, 3-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Kolburne School",'New_Marlborough=' + New_Marlborough.length); Williamstown[Williamstown.length] = createMarker(new GPoint(-73.20570800,42.69589000),"
Pine Cobble School
163 Gale Road
Williamstown, MA 01267
Co-ed school, PK-9
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Pine Cobble School",'Williamstown=' + Williamstown.length); Pittsfield[Pittsfield.length] = createMarker(new GPoint(-73.23621500,42.44361100),"
Sacred Heart School
1 Meadow Lane
Pittsfield, MA 01201
Co-ed school, K-4
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Sacred Heart School",'Pittsfield=' + Pittsfield.length); Dalton[Dalton.length] = createMarker(new GPoint(-73.16884100,42.47409600),"
St. Agnes School
30 Carson Avenue
Dalton, MA 01226
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Agnes School",'Dalton=' + Dalton.length); Pittsfield[Pittsfield.length] = createMarker(new GPoint(-73.25507600,42.44360900),"
Sinai Academy Of The Berkshires
199 South Street
Pittsfield, MA 01201
Co-ed school, PK-5
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Sinai Academy Of The Berkshires",'Pittsfield=' + Pittsfield.length); Pittsfield[Pittsfield.length] = createMarker(new GPoint(-73.26579400,42.45348300),"
St Mark Middle School
400 Columbus Avenue Ste 1
Pittsfield, MA 01201
Co-ed school, K-7
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Mark Middle School",'Pittsfield=' + Pittsfield.length); Lee[Lee.length] = createMarker(new GPoint(-73.24342200,42.30666100),"
St Mary's School
115 Orchard Street
Lee, MA 01238
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Mary's School",'Lee=' + Lee.length); Adams[Adams.length] = createMarker(new GPoint(-73.11417700,42.62496300),"
St Stanislaus Kostka School
108 Summer Street
Adams, MA 01220
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Stanislaus Kostka School",'Adams=' + Adams.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/////1/' + showArray); map.removeOverlays(Adams); map.removeOverlays(Dalton); map.removeOverlays(Great_Barrington); map.removeOverlays(Housatonic); map.removeOverlays(Lee); map.removeOverlays(Lenox); map.removeOverlays(New_Marlborough); map.removeOverlays(Pittsfield); map.removeOverlays(Stockbridge); map.removeOverlays(Williamstown); 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(Lenox);map.removeOverlays(Adams); map.removeOverlays(Dalton); map.removeOverlays(Great_Barrington); map.removeOverlays(Housatonic); map.removeOverlays(Lee); map.removeOverlays(Lenox); map.removeOverlays(New_Marlborough); map.removeOverlays(Pittsfield); map.removeOverlays(Stockbridge); map.removeOverlays(Williamstown); map.addOverlays(Adams); centerByArray(Adams, false, false); cntMarker += Adams.length; map.addOverlays(Dalton); centerByArray(Dalton, false, false); cntMarker += Dalton.length; map.addOverlays(Great_Barrington); centerByArray(Great_Barrington, false, false); cntMarker += Great_Barrington.length; map.addOverlays(Housatonic); centerByArray(Housatonic, false, false); cntMarker += Housatonic.length; map.addOverlays(Lee); centerByArray(Lee, false, false); cntMarker += Lee.length; map.addOverlays(Lenox); centerByArray(Lenox, false, false); cntMarker += Lenox.length; map.addOverlays(New_Marlborough); centerByArray(New_Marlborough, false, false); cntMarker += New_Marlborough.length; map.addOverlays(Pittsfield); centerByArray(Pittsfield, false, false); cntMarker += Pittsfield.length; map.addOverlays(Stockbridge); centerByArray(Stockbridge, false, false); cntMarker += Stockbridge.length; map.addOverlays(Williamstown); centerByArray(Williamstown, false, false); cntMarker += Williamstown.length; centerByArray(Lenox,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=1&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; }