function addMarkers(){ mySelect = document.getElementById('selection'); Beverly = [];Peabody = [];Bradford = [];North_Andover = [];Lawrence = [];Danvers = [];Methuen = [];Byfield = [];Amesbury = [];Merrimac = [];Manchester = [];Prides_Crossing = [];Andover = [];South_Hamilton = [];Lynn = [];Rowley = [];Middleton = [];mySelect.options[mySelect.options.length] = new Option("Amesbury schools",'all=Amesbury'); mySelect.options[mySelect.options.length] = new Option("Andover schools",'all=Andover'); mySelect.options[mySelect.options.length] = new Option("Beverly schools",'all=Beverly'); mySelect.options[mySelect.options.length] = new Option("Bradford schools",'all=Bradford'); mySelect.options[mySelect.options.length] = new Option("Byfield schools",'all=Byfield'); mySelect.options[mySelect.options.length] = new Option("Danvers schools",'all=Danvers'); mySelect.options[mySelect.options.length] = new Option("Lawrence schools",'all=Lawrence'); mySelect.options[mySelect.options.length] = new Option("Lynn schools",'all=Lynn'); mySelect.options[mySelect.options.length] = new Option("Manchester schools",'all=Manchester'); mySelect.options[mySelect.options.length] = new Option("Merrimac schools",'all=Merrimac'); mySelect.options[mySelect.options.length] = new Option("Methuen schools",'all=Methuen'); mySelect.options[mySelect.options.length] = new Option("Middleton schools",'all=Middleton'); mySelect.options[mySelect.options.length] = new Option("North Andover schools",'all=North_Andover'); mySelect.options[mySelect.options.length] = new Option("Peabody schools",'all=Peabody'); mySelect.options[mySelect.options.length] = new Option("Prides Crossing schools",'all=Prides_Crossing'); mySelect.options[mySelect.options.length] = new Option("Rowley schools",'all=Rowley'); mySelect.options[mySelect.options.length] = new Option("South Hamilton schools",'all=South_Hamilton'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Beverly[Beverly.length] = createMarker(new GPoint(-70.89197000,42.55698300),"
Beverly School For The Deaf
6 Echo Avenue
Beverly, MA 01915
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Beverly School For The Deaf",'Beverly=' + Beverly.length); Peabody[Peabody.length] = createMarker(new GPoint(-70.91876100,42.54075300),"
Bishop Fenwick High School
99 Margin Street
Peabody, MA 01960
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bishop Fenwick High School",'Peabody=' + Peabody.length); Bradford[Bradford.length] = createMarker(new GPoint(-71.10775600,42.74788200),"
Bradford Christian Academy
97 Oxford Avenue
Bradford, MA 01835
Co-ed school, 5-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bradford Christian Academy",'Bradford=' + Bradford.length); North_Andover[North_Andover.length] = createMarker(new GPoint(-71.08288000,42.70741800),"
Brooks School
1160 Great Pond Road
North Andover, MA 01845
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Brooks School",'North_Andover=' + North_Andover.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-71.16988800,42.71237500),"
Central Catholic High School
300 Hampshire Street
Lawrence, MA 01841
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Central Catholic High School",'Lawrence=' + Lawrence.length); Danvers[Danvers.length] = createMarker(new GPoint(-70.94031400,42.60855000),"
Clark School
487 Locust Street
Danvers, MA 01923
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Clark School",'Danvers=' + Danvers.length); Methuen[Methuen.length] = createMarker(new GPoint(-71.22400300,42.74285900),"
Fellowship Christian Academy
1 Fellowship Way
Methuen, MA 01844
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Fellowship Christian Academy",'Methuen=' + Methuen.length); Byfield[Byfield.length] = createMarker(new GPoint(-70.89574900,42.75081000),"
The Governor's Academy
1 Elm
Byfield, MA 01922
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Governor's Academy",'Byfield=' + Byfield.length); Amesbury[Amesbury.length] = createMarker(new GPoint(-70.93540000,42.85380000),"
Harbor Schools Family Servies
194 R Main Street
Amesbury, MA 01913
Co-ed school, Ungraded
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Harbor Schools Family Servies",'Amesbury=' + Amesbury.length); Merrimac[Merrimac.length] = createMarker(new GPoint(-71.00100000,42.83400000),"
Harbor Schools-merrimac Campus
Po Box 275
Merrimac, MA 01860
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Harbor Schools-merrimac Campus",'Merrimac=' + Merrimac.length); Danvers[Danvers.length] = createMarker(new GPoint(-70.92196300,42.56153000),"
Inst Family Life & Learn
78 Liberty
Danvers, MA 01923
Co-ed school, 8-11
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Inst Family Life & Learn",'Danvers=' + Danvers.length); Methuen[Methuen.length] = createMarker(new GPoint(-71.19249300,42.71978500),"
Islamic Academy For Peace
125 Oakland Avenue
Methuen, MA 01844
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Islamic Academy For Peace",'Methuen=' + Methuen.length); Peabody[Peabody.length] = createMarker(new GPoint(-70.99848500,42.55025200),"
Lakeside School
629 Lowell Street
Peabody, MA 01960
All-boys school, 4-9
[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Lakeside School",'Peabody=' + Peabody.length); Manchester[Manchester.length] = createMarker(new GPoint(-70.77218200,42.57528800),"
Landmark Elementary And Middle School
Po Box 1489
Manchester, MA 01944
Co-ed school, 2-9
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Landmark Elementary And Middle School",'Manchester=' + Manchester.length); Manchester[Manchester.length] = createMarker(new GPoint(-70.77218200,42.57528800),"
Landmark Elementary Middle School
P O Box 1489
Manchester, MA 01944
Co-ed school, 2-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Landmark Elementary Middle School",'Manchester=' + Manchester.length); Prides_Crossing[Prides_Crossing.length] = createMarker(new GPoint(-70.82465000,42.55975700),"
Landmark School
429 Hale St Box 227
Prides Crossing, MA 01965
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Landmark School",'Prides_Crossing=' + Prides_Crossing.length); Lawrence[Lawrence.length] = createMarker(new GPoint(-71.16757900,42.71014600),"
Notre Dame High School
207 Hampshire Street
Lawrence, MA 01841
Co-ed school, 9-10
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Notre Dame High School",'Lawrence=' + Lawrence.length); Andover[Andover.length] = createMarker(new GPoint(-71.13486800,42.64848600),"
Phillips Academy Andover
180 Main Street
Andover, MA 01810
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Phillips Academy Andover",'Andover=' + Andover.length); Andover[Andover.length] = createMarker(new GPoint(-71.13504600,42.63190000),"
The Pike School
34 Sunset Rock Road
Andover, MA 01810
Co-ed school, PK-9
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Pike School",'Andover=' + Andover.length); South_Hamilton[South_Hamilton.length] = createMarker(new GPoint(-70.88352900,42.64199400),"
Pingree School
537 Highland Street
South Hamilton, MA 01982
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Pingree School",'South_Hamilton=' + South_Hamilton.length); Methuen[Methuen.length] = createMarker(new GPoint(-71.18316200,42.72754000),"
Presentation Of Mary Academy
209 Lawrence Street
Methuen, MA 01844
All-girls school, 9-12
[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Presentation Of Mary Academy",'Methuen=' + Methuen.length); Methuen[Methuen.length] = createMarker(new GPoint(-71.19594900,42.70452300),"
St. Ann's Home Inc
100a Haverhill Street
Methuen, MA 01844
Co-ed school, NS-NS
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Ann's Home Inc",'Methuen=' + Methuen.length); Danvers[Danvers.length] = createMarker(new GPoint(-70.95355600,42.58197700),"
St. John's Preparatory School
72 Spring Street
Danvers, MA 01923
All-boys school, 9-12
[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("St. John's Preparatory School",'Danvers=' + Danvers.length); Lynn[Lynn.length] = createMarker(new GPoint(-70.95075700,42.46265100),"
St. Marys High School
35 Tremont Street
Lynn, MA 01902
Co-ed school, 7-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Marys High School",'Lynn=' + Lynn.length); Beverly[Beverly.length] = createMarker(new GPoint(-70.88962200,42.56888500),"
Shore Country Day School
545 Cabot Street
Beverly, MA 01915
Co-ed school, PK-9
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Shore Country Day School",'Beverly=' + Beverly.length); Rowley[Rowley.length] = createMarker(new GPoint(-70.87962000,42.73688000),"
Solstice School Day Program
12 Bowlery Drive
Rowley, MA 01969
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Solstice School Day Program",'Rowley=' + Rowley.length); Amesbury[Amesbury.length] = createMarker(new GPoint(-70.91064300,42.84996300),"
Sparhawk School
259 Elm Street
Amesbury, MA 01913
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Sparhawk School",'Amesbury=' + Amesbury.length); Beverly[Beverly.length] = createMarker(new GPoint(-70.84622300,42.57024500),"
The Waring School
35 Standley Street
Beverly, MA 01915
Co-ed school, 6-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Waring School",'Beverly=' + Beverly.length); Middleton[Middleton.length] = createMarker(new GPoint(-71.01280000,42.59520000),"
Wreath School, Inc
Box 130
Middleton, MA 01949
All-boys school, Ungraded
[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Wreath School, Inc",'Middleton=' + Middleton.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(Amesbury); map.removeOverlays(Andover); map.removeOverlays(Beverly); map.removeOverlays(Bradford); map.removeOverlays(Byfield); map.removeOverlays(Danvers); map.removeOverlays(Lawrence); map.removeOverlays(Lynn); map.removeOverlays(Manchester); map.removeOverlays(Merrimac); map.removeOverlays(Methuen); map.removeOverlays(Middleton); map.removeOverlays(North_Andover); map.removeOverlays(Peabody); map.removeOverlays(Prides_Crossing); map.removeOverlays(Rowley); map.removeOverlays(South_Hamilton); 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(Beverly);map.removeOverlays(Amesbury); map.removeOverlays(Andover); map.removeOverlays(Beverly); map.removeOverlays(Bradford); map.removeOverlays(Byfield); map.removeOverlays(Danvers); map.removeOverlays(Lawrence); map.removeOverlays(Lynn); map.removeOverlays(Manchester); map.removeOverlays(Merrimac); map.removeOverlays(Methuen); map.removeOverlays(Middleton); map.removeOverlays(North_Andover); map.removeOverlays(Peabody); map.removeOverlays(Prides_Crossing); map.removeOverlays(Rowley); map.removeOverlays(South_Hamilton); map.addOverlays(Amesbury); centerByArray(Amesbury, false, false); cntMarker += Amesbury.length; map.addOverlays(Andover); centerByArray(Andover, false, false); cntMarker += Andover.length; map.addOverlays(Beverly); centerByArray(Beverly, false, false); cntMarker += Beverly.length; map.addOverlays(Bradford); centerByArray(Bradford, false, false); cntMarker += Bradford.length; map.addOverlays(Byfield); centerByArray(Byfield, false, false); cntMarker += Byfield.length; map.addOverlays(Danvers); centerByArray(Danvers, false, false); cntMarker += Danvers.length; map.addOverlays(Lawrence); centerByArray(Lawrence, false, false); cntMarker += Lawrence.length; map.addOverlays(Lynn); centerByArray(Lynn, false, false); cntMarker += Lynn.length; map.addOverlays(Manchester); centerByArray(Manchester, false, false); cntMarker += Manchester.length; map.addOverlays(Merrimac); centerByArray(Merrimac, false, false); cntMarker += Merrimac.length; map.addOverlays(Methuen); centerByArray(Methuen, false, false); cntMarker += Methuen.length; map.addOverlays(Middleton); centerByArray(Middleton, false, false); cntMarker += Middleton.length; map.addOverlays(North_Andover); centerByArray(North_Andover, false, false); cntMarker += North_Andover.length; map.addOverlays(Peabody); centerByArray(Peabody, false, false); cntMarker += Peabody.length; map.addOverlays(Prides_Crossing); centerByArray(Prides_Crossing, false, false); cntMarker += Prides_Crossing.length; map.addOverlays(Rowley); centerByArray(Rowley, false, false); cntMarker += Rowley.length; map.addOverlays(South_Hamilton); centerByArray(South_Hamilton, false, false); cntMarker += South_Hamilton.length; centerByArray(Beverly,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; }