function addMarkers(){ mySelect = document.getElementById('selection'); Bethlehem = [];New_Milford = [];Litchfield = [];Woodbury = [];Washington = [];Washington_Depot = [];Lakeville = [];Kent = [];Northfield = [];Winsted = [];Oakville = [];Thomaston = [];Salisbury = [];South_Kent = [];Torrington = [];Watertown = [];New_Preston = [];mySelect.options[mySelect.options.length] = new Option("Bethlehem schools",'all=Bethlehem'); mySelect.options[mySelect.options.length] = new Option("Kent schools",'all=Kent'); mySelect.options[mySelect.options.length] = new Option("Lakeville schools",'all=Lakeville'); mySelect.options[mySelect.options.length] = new Option("Litchfield schools",'all=Litchfield'); mySelect.options[mySelect.options.length] = new Option("New Milford schools",'all=New_Milford'); mySelect.options[mySelect.options.length] = new Option("New Preston schools",'all=New_Preston'); mySelect.options[mySelect.options.length] = new Option("Northfield schools",'all=Northfield'); mySelect.options[mySelect.options.length] = new Option("Oakville schools",'all=Oakville'); mySelect.options[mySelect.options.length] = new Option("Salisbury schools",'all=Salisbury'); mySelect.options[mySelect.options.length] = new Option("South Kent schools",'all=South_Kent'); mySelect.options[mySelect.options.length] = new Option("Thomaston schools",'all=Thomaston'); mySelect.options[mySelect.options.length] = new Option("Torrington schools",'all=Torrington'); mySelect.options[mySelect.options.length] = new Option("Washington schools",'all=Washington'); mySelect.options[mySelect.options.length] = new Option("Washington Depot schools",'all=Washington_Depot'); mySelect.options[mySelect.options.length] = new Option("Watertown schools",'all=Watertown'); mySelect.options[mySelect.options.length] = new Option("Winsted schools",'all=Winsted'); mySelect.options[mySelect.options.length] = new Option("Woodbury schools",'all=Woodbury'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Bethlehem[Bethlehem.length] = createMarker(new GPoint(-73.20910000,41.63680000),"
The Arch Bridge School
Po Box 370 21 Arch Bridge Road
Bethlehem, CT 06751
Co-ed school, 3-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Arch Bridge School",'Bethlehem=' + Bethlehem.length); New_Milford[New_Milford.length] = createMarker(new GPoint(-73.41263400,41.58564900),"
Canterbury School
101 Aspetuck
New Milford, CT 06776
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Canterbury School",'New_Milford=' + New_Milford.length); New_Milford[New_Milford.length] = createMarker(new GPoint(-73.40994800,41.57129200),"
Connecticut Conservatory Of Th
79 West St
New Milford, CT 06776
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Connecticut Conservatory Of Th",'New_Milford=' + New_Milford.length); Litchfield[Litchfield.length] = createMarker(new GPoint(-73.19950000,41.75260000),"
Connecticut Junior Republic
550 Goshen Rd Po Box 161
Litchfield, CT 06759
All-boys school, 8-8
[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Connecticut Junior Republic",'Litchfield=' + Litchfield.length); Woodbury[Woodbury.length] = createMarker(new GPoint(-73.20484800,41.52477400),"
Creative Arts Studio
122 S Pomperaug Avenue
Woodbury, CT 06798
Co-ed school, NS-PK
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Creative Arts Studio",'Woodbury=' + Woodbury.length); Litchfield[Litchfield.length] = createMarker(new GPoint(-73.19184500,41.75711000),"
The Forman School
12 Norfolk Rd
Litchfield, CT 06759
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Forman School",'Litchfield=' + Litchfield.length); Washington[Washington.length] = createMarker(new GPoint(-73.30192300,41.64738300),"
The Glenholme School
81 Sabbaday Lane
Washington, CT 06793
Co-ed school, 5-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Glenholme School",'Washington=' + Washington.length); Washington[Washington.length] = createMarker(new GPoint(-73.31056500,41.62932900),"
The Gunnery
99 Green Hill Rd
Washington, CT 06793
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Gunnery",'Washington=' + Washington.length); Washington_Depot[Washington_Depot.length] = createMarker(new GPoint(-73.31840400,41.64120000),"
Horace Mann School John Dorr Nature Laboratory
Po Box 290
Washington Depot, CT 06794
Co-ed school, 5-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Horace Mann School John Dorr Nature Laboratory",'Washington_Depot=' + Washington_Depot.length); Lakeville[Lakeville.length] = createMarker(new GPoint(-73.44046900,41.96427000),"
The Hotchkiss School
Po Box 800
Lakeville, CT 06039
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Hotchkiss School",'Lakeville=' + Lakeville.length); Lakeville[Lakeville.length] = createMarker(new GPoint(-73.46703800,41.93744900),"
Indian Mountain School
211 Indian Mountain Road
Lakeville, CT 06039
Co-ed school, PK-9
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Indian Mountain School",'Lakeville=' + Lakeville.length); Kent[Kent.length] = createMarker(new GPoint(-73.47267400,41.72670000),"
Kent School
Po Box 2006 I Macedonia Road
Kent, CT 06757
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Kent School",'Kent=' + Kent.length); Northfield[Northfield.length] = createMarker(new GPoint(-73.10561800,41.69797400),"
Litchfield Montessori School
5 Knife Shop Road
Northfield, CT 06778
Co-ed school, PK-6
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Litchfield Montessori School",'Northfield=' + Northfield.length); Kent[Kent.length] = createMarker(new GPoint(-73.45540300,41.78202900),"
The Marvelwood School
476 Skiff Mountain Rd, PO Box 3001
Kent, CT 06757
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Marvelwood School",'Kent=' + Kent.length); Washington_Depot[Washington_Depot.length] = createMarker(new GPoint(-73.29740700,41.68106300),"
Rumsey Hall School
201 Romford Road
Washington Depot, CT 06794
Co-ed school, K-9
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Rumsey Hall School",'Washington_Depot=' + Washington_Depot.length); Winsted[Winsted.length] = createMarker(new GPoint(-73.06429000,41.92281300),"
St. Anthony School
55 Oak St
Winsted, CT 06098
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Anthony School",'Winsted=' + Winsted.length); Oakville[Oakville.length] = createMarker(new GPoint(-73.08376900,41.59105000),"
St. Mary Magdalen School
140 Buckingham Street
Oakville, CT 06779
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Mary Magdalen School",'Oakville=' + Oakville.length); Thomaston[Thomaston.length] = createMarker(new GPoint(-73.07164100,41.67506700),"
St. Thomas School
30 North Main Street
Thomaston, CT 06787
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Thomas School",'Thomaston=' + Thomaston.length); Salisbury[Salisbury.length] = createMarker(new GPoint(-73.39292900,42.00093800),"
Salisbury School
251 Canaan Road
Salisbury, CT 06068
All-boys school, 9-12
[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Salisbury School",'Salisbury=' + Salisbury.length); South_Kent[South_Kent.length] = createMarker(new GPoint(-73.47548400,41.67641500),"
South Kent School
40 Bulls Bridge Road
South Kent, CT 06785
All-boys school, 9-12
[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("South Kent School",'South_Kent=' + South_Kent.length); Torrington[Torrington.length] = createMarker(new GPoint(-73.12255500,41.80500900),"
St Francis Of Assisi School
360 Prospect Street
Torrington, CT 06790
Co-ed school, 3-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Francis Of Assisi School",'Torrington=' + Torrington.length); Watertown[Watertown.length] = createMarker(new GPoint(-73.11460800,41.60036600),"
St John The Evangelist
780 Main Street
Watertown, CT 06795
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St John The Evangelist",'Watertown=' + Watertown.length); Torrington[Torrington.length] = createMarker(new GPoint(-73.11879000,41.80252000),"
St Peter School
28 Saint John Place
Torrington, CT 06790
Co-ed school, PK-2
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Peter School",'Torrington=' + Torrington.length); Watertown[Watertown.length] = createMarker(new GPoint(-73.12333000,41.60295900),"
The Taft School
110 Woodbury Road
Watertown, CT 06795
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Taft School",'Watertown=' + Watertown.length); Torrington[Torrington.length] = createMarker(new GPoint(-73.09920100,41.80643700),"
Torrington Christian Academy
387 New Harwinton Road
Torrington, CT 06790
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Torrington Christian Academy",'Torrington=' + Torrington.length); Litchfield[Litchfield.length] = createMarker(new GPoint(-73.15012400,41.75766700),"
Touchstone School
11 Country Place
Litchfield, CT 06759
All-girls school, 8-11
[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Touchstone School",'Litchfield=' + Litchfield.length); Lakeville[Lakeville.length] = createMarker(new GPoint(-73.44370000,41.95390000),"
Town Hill School
204 Interlaken Rd Po Box 1596
Lakeville, CT 06039
Co-ed school, PK-4
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Town Hill School",'Lakeville=' + Lakeville.length); New_Preston[New_Preston.length] = createMarker(new GPoint(-73.30120200,41.70256100),"
Washington Montessori School
240 Litchfield Tpke
New Preston, CT 06777
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Washington Montessori School",'New_Preston=' + New_Preston.length); Bethlehem[Bethlehem.length] = createMarker(new GPoint(-73.20730000,41.63960000),"
The Woodhall School
Po Box 550
Bethlehem, CT 06751
All-boys school, 9-12
[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("The Woodhall 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(Kent); map.removeOverlays(Lakeville); map.removeOverlays(Litchfield); map.removeOverlays(New_Milford); map.removeOverlays(New_Preston); map.removeOverlays(Northfield); map.removeOverlays(Oakville); map.removeOverlays(Salisbury); map.removeOverlays(South_Kent); map.removeOverlays(Thomaston); map.removeOverlays(Torrington); map.removeOverlays(Washington); map.removeOverlays(Washington_Depot); map.removeOverlays(Watertown); map.removeOverlays(Winsted); map.removeOverlays(Woodbury); 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(Bethlehem);map.removeOverlays(Bethlehem); map.removeOverlays(Kent); map.removeOverlays(Lakeville); map.removeOverlays(Litchfield); map.removeOverlays(New_Milford); map.removeOverlays(New_Preston); map.removeOverlays(Northfield); map.removeOverlays(Oakville); map.removeOverlays(Salisbury); map.removeOverlays(South_Kent); map.removeOverlays(Thomaston); map.removeOverlays(Torrington); map.removeOverlays(Washington); map.removeOverlays(Washington_Depot); map.removeOverlays(Watertown); map.removeOverlays(Winsted); map.removeOverlays(Woodbury); map.addOverlays(Bethlehem); centerByArray(Bethlehem, false, false); cntMarker += Bethlehem.length; map.addOverlays(Kent); centerByArray(Kent, false, false); cntMarker += Kent.length; map.addOverlays(Lakeville); centerByArray(Lakeville, false, false); cntMarker += Lakeville.length; map.addOverlays(Litchfield); centerByArray(Litchfield, false, false); cntMarker += Litchfield.length; map.addOverlays(New_Milford); centerByArray(New_Milford, false, false); cntMarker += New_Milford.length; map.addOverlays(New_Preston); centerByArray(New_Preston, false, false); cntMarker += New_Preston.length; map.addOverlays(Northfield); centerByArray(Northfield, false, false); cntMarker += Northfield.length; map.addOverlays(Oakville); centerByArray(Oakville, false, false); cntMarker += Oakville.length; map.addOverlays(Salisbury); centerByArray(Salisbury, false, false); cntMarker += Salisbury.length; map.addOverlays(South_Kent); centerByArray(South_Kent, false, false); cntMarker += South_Kent.length; map.addOverlays(Thomaston); centerByArray(Thomaston, false, false); cntMarker += Thomaston.length; map.addOverlays(Torrington); centerByArray(Torrington, false, false); cntMarker += Torrington.length; map.addOverlays(Washington); centerByArray(Washington, false, false); cntMarker += Washington.length; map.addOverlays(Washington_Depot); centerByArray(Washington_Depot, false, false); cntMarker += Washington_Depot.length; map.addOverlays(Watertown); centerByArray(Watertown, false, false); cntMarker += Watertown.length; map.addOverlays(Winsted); centerByArray(Winsted, false, false); cntMarker += Winsted.length; map.addOverlays(Woodbury); centerByArray(Woodbury, false, false); cntMarker += Woodbury.length; centerByArray(Bethlehem,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; }