function addMarkers(){ mySelect = document.getElementById('selection'); Baltic = [];Milford = [];Waterford = [];S_Glastonbury = [];Bristol = [];Thompson = [];Middletown = [];Norwalk = [];Taftville = [];Manchester = [];Trumbull = [];Greenwich = [];mySelect.options[mySelect.options.length] = new Option("Baltic schools",'all=Baltic'); mySelect.options[mySelect.options.length] = new Option("Bristol schools",'all=Bristol'); mySelect.options[mySelect.options.length] = new Option("Greenwich schools",'all=Greenwich'); mySelect.options[mySelect.options.length] = new Option("Manchester schools",'all=Manchester'); mySelect.options[mySelect.options.length] = new Option("Middletown schools",'all=Middletown'); mySelect.options[mySelect.options.length] = new Option("Milford schools",'all=Milford'); mySelect.options[mySelect.options.length] = new Option("Norwalk schools",'all=Norwalk'); mySelect.options[mySelect.options.length] = new Option("S Glastonbury schools",'all=S_Glastonbury'); mySelect.options[mySelect.options.length] = new Option("Taftville schools",'all=Taftville'); mySelect.options[mySelect.options.length] = new Option("Thompson schools",'all=Thompson'); mySelect.options[mySelect.options.length] = new Option("Trumbull schools",'all=Trumbull'); mySelect.options[mySelect.options.length] = new Option("Waterford schools",'all=Waterford'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Baltic[Baltic.length] = createMarker(new GPoint(-72.08453500,41.61682500),"
Academy Of The Holy Family
54 W Main St. Box 691
Baltic, CT 06330
All-girls school, 9-12
[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Academy Of The Holy Family",'Baltic=' + Baltic.length); Milford[Milford.length] = createMarker(new GPoint(-73.06204500,41.22420200),"
Academy Of Our Lady Of Mercy, Lauralton Hall
200 High Street
Milford, CT 06460
All-girls school, 9-12
[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Academy Of Our Lady Of Mercy, Lauralton Hall",'Milford=' + Milford.length); Waterford[Waterford.length] = createMarker(new GPoint(-72.17974800,41.40238000),"
Baptist Bible Academy
1144 Hartford Tpke
Waterford, CT 06385
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Baptist Bible Academy",'Waterford=' + Waterford.length); S_Glastonbury[S_Glastonbury.length] = createMarker(new GPoint(-72.57350000,41.66190000),"
Freeman's Montessori School
Po Box 161
S Glastonbury, CT 06073
Co-ed school, PK-KG
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Freeman's Montessori School",'S_Glastonbury=' + S_Glastonbury.length); Bristol[Bristol.length] = createMarker(new GPoint(-72.94919900,41.67369600),"
Immanuel Lutheran School
154 Meadow Street
Bristol, CT 06010
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Immanuel Lutheran School",'Bristol=' + Bristol.length); Thompson[Thompson.length] = createMarker(new GPoint(-71.86126400,41.96046100),"
Marianapolis Preparatory School
PO Box 304 26 Chase Road
Thompson, CT 06277
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Marianapolis Preparatory School",'Thompson=' + Thompson.length); Middletown[Middletown.length] = createMarker(new GPoint(-72.67520300,41.53135400),"
Mercy High School
1740 Randolph Road
Middletown, CT 06457
All-girls school, 9-12
[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mercy High School",'Middletown=' + Middletown.length); Norwalk[Norwalk.length] = createMarker(new GPoint(-73.45238300,41.13320600),"
Parkway Christian Academy Happy Time Nursery
260 New Canaan Avenue
Norwalk, CT 06850
Co-ed school, 5-5
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Parkway Christian Academy Happy Time Nursery",'Norwalk=' + Norwalk.length); Taftville[Taftville.length] = createMarker(new GPoint(-72.05512800,41.56765900),"
Sacred Heart School
15 Hunters Avenue
Taftville, CT 06380
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Sacred Heart School",'Taftville=' + Taftville.length); Manchester[Manchester.length] = createMarker(new GPoint(-72.52103700,41.76144300),"
St Bridget School
74 Main Street
Manchester, CT 06042
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Bridget School",'Manchester=' + Manchester.length); Trumbull[Trumbull.length] = createMarker(new GPoint(-73.22346100,41.23866300),"
St Theresas School
55 Rosemond Ter
Trumbull, CT 06611
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Theresas School",'Trumbull=' + Trumbull.length); Greenwich[Greenwich.length] = createMarker(new GPoint(-73.63433900,41.03860100),"
Westchester Fairfield Hebrew Academy
270 Lake Avenue
Greenwich, CT 06830
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Westchester Fairfield Hebrew Academy",'Greenwich=' + Greenwich.length); map.removeOverlays(Baltic); map.removeOverlays(Bristol); map.removeOverlays(Greenwich); map.removeOverlays(Manchester); map.removeOverlays(Middletown); map.removeOverlays(Milford); map.removeOverlays(Norwalk); map.removeOverlays(S_Glastonbury); map.removeOverlays(Taftville); map.removeOverlays(Thompson); map.removeOverlays(Trumbull); map.removeOverlays(Waterford); setTimeout(function(){map.addOverlays(Baltic)},1000); setTimeout(function(){map.addOverlays(Bristol)},1000); setTimeout(function(){map.addOverlays(Greenwich)},1000); setTimeout(function(){map.addOverlays(Manchester)},1000); setTimeout(function(){map.addOverlays(Middletown)},1000); setTimeout(function(){map.addOverlays(Milford)},1000); setTimeout(function(){map.addOverlays(Norwalk)},1000); setTimeout(function(){map.addOverlays(S_Glastonbury)},1000); setTimeout(function(){map.addOverlays(Taftville)},1000); setTimeout(function(){map.addOverlays(Thompson)},1000); setTimeout(function(){map.addOverlays(Trumbull)},1000); setTimeout(function(){map.addOverlays(Waterford)},1000); maxLng = -71.86126400; maxLat = 41.96046100; minLng = -73.63433900; minLat = 41.03860100; 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(Baltic); map.removeOverlays(Bristol); map.removeOverlays(Greenwich); map.removeOverlays(Manchester); map.removeOverlays(Middletown); map.removeOverlays(Milford); map.removeOverlays(Norwalk); map.removeOverlays(S_Glastonbury); map.removeOverlays(Taftville); map.removeOverlays(Thompson); map.removeOverlays(Trumbull); map.removeOverlays(Waterford); 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(Baltic);map.removeOverlays(Baltic); map.removeOverlays(Bristol); map.removeOverlays(Greenwich); map.removeOverlays(Manchester); map.removeOverlays(Middletown); map.removeOverlays(Milford); map.removeOverlays(Norwalk); map.removeOverlays(S_Glastonbury); map.removeOverlays(Taftville); map.removeOverlays(Thompson); map.removeOverlays(Trumbull); map.removeOverlays(Waterford); map.addOverlays(Baltic); centerByArray(Baltic, false, false); cntMarker += Baltic.length; map.addOverlays(Bristol); centerByArray(Bristol, false, false); cntMarker += Bristol.length; map.addOverlays(Greenwich); centerByArray(Greenwich, false, false); cntMarker += Greenwich.length; map.addOverlays(Manchester); centerByArray(Manchester, false, false); cntMarker += Manchester.length; map.addOverlays(Middletown); centerByArray(Middletown, false, false); cntMarker += Middletown.length; map.addOverlays(Milford); centerByArray(Milford, false, false); cntMarker += Milford.length; map.addOverlays(Norwalk); centerByArray(Norwalk, false, false); cntMarker += Norwalk.length; map.addOverlays(S_Glastonbury); centerByArray(S_Glastonbury, false, false); cntMarker += S_Glastonbury.length; map.addOverlays(Taftville); centerByArray(Taftville, false, false); cntMarker += Taftville.length; map.addOverlays(Thompson); centerByArray(Thompson, false, false); cntMarker += Thompson.length; map.addOverlays(Trumbull); centerByArray(Trumbull, false, false); cntMarker += Trumbull.length; map.addOverlays(Waterford); centerByArray(Waterford, false, false); cntMarker += Waterford.length; centerByArray(Baltic,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///5272,5386,5271,5384,5278,5362,20541,5476,5420,5327,5440,5546,5278,/all'); //window.open('/map.php?type=2&schools=5272,5386,5271,5384,5278,5362,20541,5476,5420,5327,5440,5546,5278,&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; }