function addMarkers(){ mySelect = document.getElementById('selection'); Pike = [];Bethlehem = [];Rumney = [];Plymouth = [];Canaan = [];Littleton = [];Lyme = [];Lebanon = [];West_Lebanon = [];Hanover = [];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("Hanover schools",'all=Hanover'); mySelect.options[mySelect.options.length] = new Option("Lebanon schools",'all=Lebanon'); mySelect.options[mySelect.options.length] = new Option("Littleton schools",'all=Littleton'); mySelect.options[mySelect.options.length] = new Option("Lyme schools",'all=Lyme'); mySelect.options[mySelect.options.length] = new Option("Pike schools",'all=Pike'); mySelect.options[mySelect.options.length] = new Option("Plymouth schools",'all=Plymouth'); mySelect.options[mySelect.options.length] = new Option("Rumney schools",'all=Rumney'); mySelect.options[mySelect.options.length] = new Option("West Lebanon schools",'all=West_Lebanon'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Pike[Pike.length] = createMarker(new GPoint(-71.98800000,44.03420000),"
Becket School
Po Box 299
Pike, NH 03780
Co-ed school, 6-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Becket School",'Pike=' + Pike.length); Bethlehem[Bethlehem.length] = createMarker(new GPoint(-71.68756800,44.27928000),"
Bethlehem Christian School
Po Box 303
Bethlehem, NH 03574
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bethlehem Christian School",'Bethlehem=' + Bethlehem.length); Rumney[Rumney.length] = createMarker(new GPoint(-71.70650000,43.76030000),"
Bodhi Tree Montessori School
Po Box 425
Rumney, NH 03266
Co-ed school, PK-6
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bodhi Tree Montessori School",'Rumney=' + Rumney.length); Plymouth[Plymouth.length] = createMarker(new GPoint(-71.75035800,43.75731300),"
Calvary Christian School
115 Yeaton Road
Plymouth, NH 03264
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Calvary Christian School",'Plymouth=' + Plymouth.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); Littleton[Littleton.length] = createMarker(new GPoint(-71.79120000,44.31330000),"
The Children S House
Po Box 138
Littleton, NH 03561
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Children S House",'Littleton=' + Littleton.length); Lyme[Lyme.length] = createMarker(new GPoint(-72.18047700,43.77955600),"
Crossroads Academy
95 Dartmouth College Highway
Lyme, NH 03768
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Crossroads Academy",'Lyme=' + Lyme.length); Lebanon[Lebanon.length] = createMarker(new GPoint(-72.27109000,43.68483700),"
Dhmc Child Care Center
1 Medical Center Drive
Lebanon, NH 03756
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Dhmc Child Care Center",'Lebanon=' + Lebanon.length); West_Lebanon[West_Lebanon.length] = createMarker(new GPoint(-72.30819300,43.65426300),"
Estabrook School
101 Maple Street
West Lebanon, NH 03784
Co-ed school, 1-6
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Estabrook School",'West_Lebanon=' + West_Lebanon.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); Rumney[Rumney.length] = createMarker(new GPoint(-71.81287900,43.80474500),"
The Hunter School
Po Box 600
Rumney, NH 03266
Co-ed school, 1-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Hunter School",'Rumney=' + Rumney.length); Hanover[Hanover.length] = createMarker(new GPoint(-72.25810000,43.70980000),"
The Montessori Children's School
Po Box 5606
Hanover, NH 03755
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Montessori Children's School",'Hanover=' + Hanover.length); West_Lebanon[West_Lebanon.length] = createMarker(new GPoint(-72.30720000,43.64770000),"
Montessori Discovery School
Po Box 5348 44 Maple Street
West Lebanon, NH 03784
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Montessori Discovery School",'West_Lebanon=' + West_Lebanon.length); Plymouth[Plymouth.length] = createMarker(new GPoint(-71.70660000,43.76040000),"
Montessori School Of Plymouth
Po Box 618
Plymouth, NH 03264
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Montessori School Of Plymouth",'Plymouth=' + Plymouth.length); Rumney[Rumney.length] = createMarker(new GPoint(-71.87360000,43.79750000),"
Montview Nursery & Kindergarten
Route 25
Rumney, NH 03266
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Montview Nursery & Kindergarten",'Rumney=' + Rumney.length); Plymouth[Plymouth.length] = createMarker(new GPoint(-71.70660000,43.76040000),"
Mount Prospect Academy
Po Box 58
Plymouth, NH 03264
All-boys school, 7-12
[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Mount Prospect Academy",'Plymouth=' + Plymouth.length); West_Lebanon[West_Lebanon.length] = createMarker(new GPoint(-72.29353000,43.68595100),"
New Life Christian Academy
407 N. Main St.
West Lebanon, NH 03784
Co-ed school, KG-6
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("New Life Christian Academy",'West_Lebanon=' + West_Lebanon.length); Plymouth[Plymouth.length] = createMarker(new GPoint(-71.68816600,43.75779700),"
Plymouth State University Cd & Fc
Msc 46
Plymouth, NH 03264
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Plymouth State University Cd & Fc",'Plymouth=' + Plymouth.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); } // 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/////3/' + showArray); map.removeOverlays(Bethlehem); map.removeOverlays(Canaan); map.removeOverlays(Hanover); map.removeOverlays(Lebanon); map.removeOverlays(Littleton); map.removeOverlays(Lyme); map.removeOverlays(Pike); map.removeOverlays(Plymouth); map.removeOverlays(Rumney); map.removeOverlays(West_Lebanon); 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(Pike);map.removeOverlays(Bethlehem); map.removeOverlays(Canaan); map.removeOverlays(Hanover); map.removeOverlays(Lebanon); map.removeOverlays(Littleton); map.removeOverlays(Lyme); map.removeOverlays(Pike); map.removeOverlays(Plymouth); map.removeOverlays(Rumney); map.removeOverlays(West_Lebanon); map.addOverlays(Bethlehem); centerByArray(Bethlehem, false, false); cntMarker += Bethlehem.length; map.addOverlays(Canaan); centerByArray(Canaan, false, false); cntMarker += Canaan.length; map.addOverlays(Hanover); centerByArray(Hanover, false, false); cntMarker += Hanover.length; map.addOverlays(Lebanon); centerByArray(Lebanon, false, false); cntMarker += Lebanon.length; map.addOverlays(Littleton); centerByArray(Littleton, false, false); cntMarker += Littleton.length; map.addOverlays(Lyme); centerByArray(Lyme, false, false); cntMarker += Lyme.length; map.addOverlays(Pike); centerByArray(Pike, false, false); cntMarker += Pike.length; map.addOverlays(Plymouth); centerByArray(Plymouth, false, false); cntMarker += Plymouth.length; map.addOverlays(Rumney); centerByArray(Rumney, false, false); cntMarker += Rumney.length; map.addOverlays(West_Lebanon); centerByArray(West_Lebanon, false, false); cntMarker += West_Lebanon.length; centerByArray(Pike,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=3&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; }