function addMarkers() { mySelect = document.getElementById('selection'); Westport = [];East_Hartford = [];Hartford = [];East_Haven = [];Ridgefield = [];Simsbury = [];Bridgeport = [];Darien = [];Fairfield = [];Old_Greenwich = [];Waterbury = [];Enfield = [];Meriden = [];Windham = [];mySelect.options[mySelect.options.length] = new Option("Bridgeport schools",'all=Bridgeport'); mySelect.options[mySelect.options.length] = new Option("Darien schools",'all=Darien'); mySelect.options[mySelect.options.length] = new Option("East Hartford schools",'all=East_Hartford'); mySelect.options[mySelect.options.length] = new Option("East Haven schools",'all=East_Haven'); mySelect.options[mySelect.options.length] = new Option("Enfield schools",'all=Enfield'); mySelect.options[mySelect.options.length] = new Option("Fairfield schools",'all=Fairfield'); mySelect.options[mySelect.options.length] = new Option("Hartford schools",'all=Hartford'); mySelect.options[mySelect.options.length] = new Option("Meriden schools",'all=Meriden'); mySelect.options[mySelect.options.length] = new Option("Old Greenwich schools",'all=Old_Greenwich'); mySelect.options[mySelect.options.length] = new Option("Ridgefield schools",'all=Ridgefield'); mySelect.options[mySelect.options.length] = new Option("Simsbury schools",'all=Simsbury'); mySelect.options[mySelect.options.length] = new Option("Waterbury schools",'all=Waterbury'); mySelect.options[mySelect.options.length] = new Option("Westport schools",'all=Westport'); mySelect.options[mySelect.options.length] = new Option("Windham schools",'all=Windham'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Westport[Westport.length] = createMarker(new GPoint(-73.33345795,41.15649414),"
",iconBl); mySelect.options[mySelect.options.length] = new Option("Bedford Middle School",'Westport=' + Westport.length); East_Hartford[East_Hartford.length] = createMarker(new GPoint(-72.61250305,41.74739838),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Ct International Baccalaureate Academy",'East_Hartford=' + East_Hartford.length); Hartford[Hartford.length] = createMarker(new GPoint(-72.67183685,41.74010086),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Dwight School",'Hartford=' + Hartford.length); East_Haven[East_Haven.length] = createMarker(new GPoint(-72.87572479,41.27516556),"",iconRd); mySelect.options[mySelect.options.length] = new Option("East Haven Academy",'East_Haven=' + East_Haven.length); Ridgefield[Ridgefield.length] = createMarker(new GPoint(-73.49275208,41.27688599),"",iconBl); mySelect.options[mySelect.options.length] = new Option("East Ridge Middle School",'Ridgefield=' + Ridgefield.length); Hartford[Hartford.length] = createMarker(new GPoint(-72.68684387,41.75120544),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Hartford Magnet Middle School",'Hartford=' + Hartford.length); Simsbury[Simsbury.length] = createMarker(new GPoint(-72.81320190,41.88375854),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Henry James Memorial School",'Simsbury=' + Simsbury.length); Bridgeport[Bridgeport.length] = createMarker(new GPoint(-73.16510773,41.19975281),"",iconRd); mySelect.options[mySelect.options.length] = new Option("High Horizons School",'Bridgeport=' + Bridgeport.length); Darien[Darien.length] = createMarker(new GPoint(-73.49791718,41.07268524),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Middlesex Middle School",'Darien=' + Darien.length); Fairfield[Fairfield.length] = createMarker(new GPoint(-73.29335785,41.14029694),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mill Hill School",'Fairfield=' + Fairfield.length); Bridgeport[Bridgeport.length] = createMarker(new GPoint(-73.16510773,41.19975281),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Multicultural Magnet School",'Bridgeport=' + Bridgeport.length); Old_Greenwich[Old_Greenwich.length] = createMarker(new GPoint(-73.56306458,41.02019882),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Old Greenwich School",'Old_Greenwich=' + Old_Greenwich.length); Waterbury[Waterbury.length] = createMarker(new GPoint(-73.02712250,41.59275055),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Regan School",'Waterbury=' + Waterbury.length); Hartford[Hartford.length] = createMarker(new GPoint(-72.68174744,41.79474258),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Simpson-waverly School",'Hartford=' + Hartford.length); Enfield[Enfield.length] = createMarker(new GPoint(-72.59425354,41.99375534),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Thomas G. Alcorn School",'Enfield=' + Enfield.length); Meriden[Meriden.length] = createMarker(new GPoint(-72.77889600,41.51826600),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Thomas Hooker School",'Meriden=' + Meriden.length); Windham[Windham.length] = createMarker(new GPoint(-72.15239716,41.69729996),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Windham Center School",'Windham=' + Windham.length); map.removeOverlays(Bridgeport); map.removeOverlays(Darien); map.removeOverlays(East_Hartford); map.removeOverlays(East_Haven); map.removeOverlays(Enfield); map.removeOverlays(Fairfield); map.removeOverlays(Hartford); map.removeOverlays(Meriden); map.removeOverlays(Old_Greenwich); map.removeOverlays(Ridgefield); map.removeOverlays(Simsbury); map.removeOverlays(Waterbury); map.removeOverlays(Westport); map.removeOverlays(Windham); setTimeout(function(){map.addOverlays(Bridgeport)},1000); setTimeout(function(){map.addOverlays(Darien)},1000); setTimeout(function(){map.addOverlays(East_Hartford)},1000); setTimeout(function(){map.addOverlays(East_Haven)},1000); setTimeout(function(){map.addOverlays(Enfield)},1000); setTimeout(function(){map.addOverlays(Fairfield)},1000); setTimeout(function(){map.addOverlays(Hartford)},1000); setTimeout(function(){map.addOverlays(Meriden)},1000); setTimeout(function(){map.addOverlays(Old_Greenwich)},1000); setTimeout(function(){map.addOverlays(Ridgefield)},1000); setTimeout(function(){map.addOverlays(Simsbury)},1000); setTimeout(function(){map.addOverlays(Waterbury)},1000); setTimeout(function(){map.addOverlays(Westport)},1000); setTimeout(function(){map.addOverlays(Windham)},1000); maxLng = -72.15239716; maxLat = 41.99375534; minLng = -73.56306458; minLat = 41.02019882; 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,10); /* 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(Bridgeport); map.removeOverlays(Darien); map.removeOverlays(East_Hartford); map.removeOverlays(East_Haven); map.removeOverlays(Enfield); map.removeOverlays(Fairfield); map.removeOverlays(Hartford); map.removeOverlays(Meriden); map.removeOverlays(Old_Greenwich); map.removeOverlays(Ridgefield); map.removeOverlays(Simsbury); map.removeOverlays(Waterbury); map.removeOverlays(Westport); map.removeOverlays(Windham); 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(Westport);map.removeOverlays(Bridgeport); map.removeOverlays(Darien); map.removeOverlays(East_Hartford); map.removeOverlays(East_Haven); map.removeOverlays(Enfield); map.removeOverlays(Fairfield); map.removeOverlays(Hartford); map.removeOverlays(Meriden); map.removeOverlays(Old_Greenwich); map.removeOverlays(Ridgefield); map.removeOverlays(Simsbury); map.removeOverlays(Waterbury); map.removeOverlays(Westport); map.removeOverlays(Windham); map.addOverlays(Bridgeport); centerByArray(Bridgeport, false, false); cntMarker += Bridgeport.length; map.addOverlays(Darien); centerByArray(Darien, false, false); cntMarker += Darien.length; map.addOverlays(East_Hartford); centerByArray(East_Hartford, false, false); cntMarker += East_Hartford.length; map.addOverlays(East_Haven); centerByArray(East_Haven, false, false); cntMarker += East_Haven.length; map.addOverlays(Enfield); centerByArray(Enfield, false, false); cntMarker += Enfield.length; map.addOverlays(Fairfield); centerByArray(Fairfield, false, false); cntMarker += Fairfield.length; map.addOverlays(Hartford); centerByArray(Hartford, false, false); cntMarker += Hartford.length; map.addOverlays(Meriden); centerByArray(Meriden, false, false); cntMarker += Meriden.length; map.addOverlays(Old_Greenwich); centerByArray(Old_Greenwich, false, false); cntMarker += Old_Greenwich.length; map.addOverlays(Ridgefield); centerByArray(Ridgefield, false, false); cntMarker += Ridgefield.length; map.addOverlays(Simsbury); centerByArray(Simsbury, false, false); cntMarker += Simsbury.length; map.addOverlays(Waterbury); centerByArray(Waterbury, false, false); cntMarker += Waterbury.length; map.addOverlays(Westport); centerByArray(Westport, false, false); cntMarker += Westport.length; map.addOverlays(Windham); centerByArray(Windham, false, false); cntMarker += Windham.length; centerByArray(Westport,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///118136,15521,15721,16086,16117,16323,15437,15434,15563,15586,15606,15696,15711,127627,15646,16265,16351,/all'); } }