function addMarkers(){ mySelect = document.getElementById('selection'); Concord = [];Wolfeboro = [];Canaan = [];Manchester = [];Dublin = [];Rindge = [];Plymouth = [];Meriden = [];New_Hampton = [];Exeter = [];Andover = [];Nashua = [];Tilton = [];Bethlehem = [];mySelect.options[mySelect.options.length] = new Option("Andover schools",'all=Andover'); mySelect.options[mySelect.options.length] = new Option("Bethlehem schools",'all=Bethlehem'); mySelect.options[mySelect.options.length] = new Option("Canaan schools",'all=Canaan'); mySelect.options[mySelect.options.length] = new Option("Concord schools",'all=Concord'); mySelect.options[mySelect.options.length] = new Option("Dublin schools",'all=Dublin'); mySelect.options[mySelect.options.length] = new Option("Exeter schools",'all=Exeter'); mySelect.options[mySelect.options.length] = new Option("Manchester schools",'all=Manchester'); mySelect.options[mySelect.options.length] = new Option("Meriden schools",'all=Meriden'); mySelect.options[mySelect.options.length] = new Option("Nashua schools",'all=Nashua'); mySelect.options[mySelect.options.length] = new Option("New Hampton schools",'all=New_Hampton'); mySelect.options[mySelect.options.length] = new Option("Plymouth schools",'all=Plymouth'); mySelect.options[mySelect.options.length] = new Option("Rindge schools",'all=Rindge'); mySelect.options[mySelect.options.length] = new Option("Tilton schools",'all=Tilton'); mySelect.options[mySelect.options.length] = new Option("Wolfeboro schools",'all=Wolfeboro'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Concord[Concord.length] = createMarker(new GPoint(-71.52390000,43.20925000),"
Bear Hill School
4 Gully Rd
Concord, NH 03301
Co-ed school, PK-7
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bear Hill School",'Concord=' + Concord.length); Wolfeboro[Wolfeboro.length] = createMarker(new GPoint(-71.20656600,43.58173400),"
Brewster Academy
80 Academy Drive
Wolfeboro, NH 03894
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Brewster Academy",'Wolfeboro=' + Wolfeboro.length); Canaan[Canaan.length] = createMarker(new GPoint(-72.03647300,43.67651000),"
Cardigan Mountain School
62 Alumni Drive
Canaan, NH 03741
All-boys school, 6-9
[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Cardigan Mountain School",'Canaan=' + Canaan.length); Manchester[Manchester.length] = createMarker(new GPoint(-71.45984400,43.03459600),"
The Derryfield School
2108 River Road
Manchester, NH 03104
Co-ed school, 6-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Derryfield School",'Manchester=' + Manchester.length); Dublin[Dublin.length] = createMarker(new GPoint(-72.06392000,42.91224000),"
Dublin School
Po Box 522 18 Lehmann Way
Dublin, NH 03444
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Dublin School",'Dublin=' + Dublin.length); Rindge[Rindge.length] = createMarker(new GPoint(-71.93974400,42.74027300),"
Hampshire Country School
28 Patey Circle
Rindge, NH 03461
All-boys school, 5-12
[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Hampshire Country School",'Rindge=' + Rindge.length); Plymouth[Plymouth.length] = createMarker(new GPoint(-71.70660000,43.76040000),"
Holderness School
Po Box 1879
Plymouth, NH 03264
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Holderness School",'Plymouth=' + Plymouth.length); Meriden[Meriden.length] = createMarker(new GPoint(-72.26790300,43.53522800),"
Kimball Union Academy
Po Box 188 57 Main Street
Meriden, NH 03770
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Kimball Union Academy",'Meriden=' + Meriden.length); New_Hampton[New_Hampton.length] = createMarker(new GPoint(-71.65213800,43.60572300),"
New Hampton School
70 Main Street
New Hampton, NH 03256
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("New Hampton School",'New_Hampton=' + New_Hampton.length); Exeter[Exeter.length] = createMarker(new GPoint(-70.95234600,42.98133900),"
Phillips Exeter Academy
20 Main Street
Exeter, NH 03833
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Phillips Exeter Academy",'Exeter=' + Exeter.length); Andover[Andover.length] = createMarker(new GPoint(-71.82311900,43.43669500),"
Proctor Academy
Po Box 500 Main St
Andover, NH 03216
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Proctor Academy",'Andover=' + Andover.length); Nashua[Nashua.length] = createMarker(new GPoint(-71.47356700,42.77123100),"
St. Christopher School
20 Cushing Ave
Nashua, NH 03064
Co-ed school, PK-6
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Christopher School",'Nashua=' + Nashua.length); Tilton[Tilton.length] = createMarker(new GPoint(-71.58892100,43.44429700),"
Tilton School
30 School Street
Tilton, NH 03276
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Tilton School",'Tilton=' + Tilton.length); Bethlehem[Bethlehem.length] = createMarker(new GPoint(-71.75714900,44.28107900),"
The White Mountain School
371 W Farm Road
Bethlehem, NH 03574
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The White Mountain School",'Bethlehem=' + Bethlehem.length); map.removeOverlays(Andover); map.removeOverlays(Bethlehem); map.removeOverlays(Canaan); map.removeOverlays(Concord); map.removeOverlays(Dublin); map.removeOverlays(Exeter); map.removeOverlays(Manchester); map.removeOverlays(Meriden); map.removeOverlays(Nashua); map.removeOverlays(New_Hampton); map.removeOverlays(Plymouth); map.removeOverlays(Rindge); map.removeOverlays(Tilton); map.removeOverlays(Wolfeboro); setTimeout(function(){map.addOverlays(Andover)},1000); setTimeout(function(){map.addOverlays(Bethlehem)},1000); setTimeout(function(){map.addOverlays(Canaan)},1000); setTimeout(function(){map.addOverlays(Concord)},1000); setTimeout(function(){map.addOverlays(Dublin)},1000); setTimeout(function(){map.addOverlays(Exeter)},1000); setTimeout(function(){map.addOverlays(Manchester)},1000); setTimeout(function(){map.addOverlays(Meriden)},1000); setTimeout(function(){map.addOverlays(Nashua)},1000); setTimeout(function(){map.addOverlays(New_Hampton)},1000); setTimeout(function(){map.addOverlays(Plymouth)},1000); setTimeout(function(){map.addOverlays(Rindge)},1000); setTimeout(function(){map.addOverlays(Tilton)},1000); setTimeout(function(){map.addOverlays(Wolfeboro)},1000); maxLng = -70.95234600; maxLat = 44.28107900; minLng = -72.26790300; minLat = 42.74027300; 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(Andover); map.removeOverlays(Bethlehem); map.removeOverlays(Canaan); map.removeOverlays(Concord); map.removeOverlays(Dublin); map.removeOverlays(Exeter); map.removeOverlays(Manchester); map.removeOverlays(Meriden); map.removeOverlays(Nashua); map.removeOverlays(New_Hampton); map.removeOverlays(Plymouth); map.removeOverlays(Rindge); map.removeOverlays(Tilton); map.removeOverlays(Wolfeboro); 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(Concord);map.removeOverlays(Andover); map.removeOverlays(Bethlehem); map.removeOverlays(Canaan); map.removeOverlays(Concord); map.removeOverlays(Dublin); map.removeOverlays(Exeter); map.removeOverlays(Manchester); map.removeOverlays(Meriden); map.removeOverlays(Nashua); map.removeOverlays(New_Hampton); map.removeOverlays(Plymouth); map.removeOverlays(Rindge); map.removeOverlays(Tilton); map.removeOverlays(Wolfeboro); map.addOverlays(Andover); centerByArray(Andover, false, false); cntMarker += Andover.length; map.addOverlays(Bethlehem); centerByArray(Bethlehem, false, false); cntMarker += Bethlehem.length; map.addOverlays(Canaan); centerByArray(Canaan, false, false); cntMarker += Canaan.length; map.addOverlays(Concord); centerByArray(Concord, false, false); cntMarker += Concord.length; map.addOverlays(Dublin); centerByArray(Dublin, false, false); cntMarker += Dublin.length; map.addOverlays(Exeter); centerByArray(Exeter, false, false); cntMarker += Exeter.length; map.addOverlays(Manchester); centerByArray(Manchester, false, false); cntMarker += Manchester.length; map.addOverlays(Meriden); centerByArray(Meriden, false, false); cntMarker += Meriden.length; map.addOverlays(Nashua); centerByArray(Nashua, false, false); cntMarker += Nashua.length; map.addOverlays(New_Hampton); centerByArray(New_Hampton, false, false); cntMarker += New_Hampton.length; map.addOverlays(Plymouth); centerByArray(Plymouth, false, false); cntMarker += Plymouth.length; map.addOverlays(Rindge); centerByArray(Rindge, false, false); cntMarker += Rindge.length; map.addOverlays(Tilton); centerByArray(Tilton, false, false); cntMarker += Tilton.length; map.addOverlays(Wolfeboro); centerByArray(Wolfeboro, false, false); cntMarker += Wolfeboro.length; centerByArray(Concord,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///16768,16818,16686,16707,16761,16813,16731,16816,16721,16715,16820,16681,16686,16674,16790,16715,/all'); //window.open('/map.php?type=2&schools=16768,16818,16686,16707,16761,16813,16731,16816,16721,16715,16820,16681,16686,16674,16790,16715,&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; }