function addMarkers(){
mySelect = document.getElementById('selection');
Milford = [];Avon = [];Bloomfield = [];Simsbury = [];Madison = [];Woodbridge = [];Greenwich = [];Washington_Depot = [];Meriden = [];Westport = [];Stamford = [];Windsor = [];Kensington = [];New_Canaan = [];Mansfield = [];Plainville = [];Branford = [];Pomfret = [];West_Hartford = [];Hamden = [];Stratford = [];Salisbury = [];New_Britain = [];Jewett_City = [];Suffield = [];Middletown = [];New_Haven = [];mySelect.options[mySelect.options.length] = new Option("Avon schools",'all=Avon');
mySelect.options[mySelect.options.length] = new Option("Bloomfield schools",'all=Bloomfield');
mySelect.options[mySelect.options.length] = new Option("Branford schools",'all=Branford');
mySelect.options[mySelect.options.length] = new Option("Greenwich schools",'all=Greenwich');
mySelect.options[mySelect.options.length] = new Option("Hamden schools",'all=Hamden');
mySelect.options[mySelect.options.length] = new Option("Jewett City schools",'all=Jewett_City');
mySelect.options[mySelect.options.length] = new Option("Kensington schools",'all=Kensington');
mySelect.options[mySelect.options.length] = new Option("Madison schools",'all=Madison');
mySelect.options[mySelect.options.length] = new Option("Mansfield schools",'all=Mansfield');
mySelect.options[mySelect.options.length] = new Option("Meriden schools",'all=Meriden');
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("New Britain schools",'all=New_Britain');
mySelect.options[mySelect.options.length] = new Option("New Canaan schools",'all=New_Canaan');
mySelect.options[mySelect.options.length] = new Option("New Haven schools",'all=New_Haven');
mySelect.options[mySelect.options.length] = new Option("Plainville schools",'all=Plainville');
mySelect.options[mySelect.options.length] = new Option("Pomfret schools",'all=Pomfret');
mySelect.options[mySelect.options.length] = new Option("Salisbury schools",'all=Salisbury');
mySelect.options[mySelect.options.length] = new Option("Simsbury schools",'all=Simsbury');
mySelect.options[mySelect.options.length] = new Option("Stamford schools",'all=Stamford');
mySelect.options[mySelect.options.length] = new Option("Stratford schools",'all=Stratford');
mySelect.options[mySelect.options.length] = new Option("Suffield schools",'all=Suffield');
mySelect.options[mySelect.options.length] = new Option("Washington Depot schools",'all=Washington_Depot');
mySelect.options[mySelect.options.length] = new Option("West Hartford schools",'all=West_Hartford');
mySelect.options[mySelect.options.length] = new Option("Westport schools",'all=Westport');
mySelect.options[mySelect.options.length] = new Option("Windsor schools",'all=Windsor');
mySelect.options[mySelect.options.length] = new Option("Woodbridge schools",'all=Woodbridge');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Milford[Milford.length] = createMarker(new GPoint(-73.06204500,41.22420200),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Academy Of Our Lady Of Mercy, Lauralton Hall",'Milford=' + Milford.length);
Avon[Avon.length] = createMarker(new GPoint(-72.83650200,41.78126100),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Avon Old Farms School",'Avon=' + Avon.length);
Bloomfield[Bloomfield.length] = createMarker(new GPoint(-72.74247500,41.82763600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Bess And Paul Sigel Hebrew Academy",'Bloomfield=' + Bloomfield.length);
Simsbury[Simsbury.length] = createMarker(new GPoint(-72.82983300,41.84995900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Cobb School Montessori",'Simsbury=' + Simsbury.length);
Madison[Madison.length] = createMarker(new GPoint(-72.63500200,41.32544100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Country School",'Madison=' + Madison.length);
Simsbury[Simsbury.length] = createMarker(new GPoint(-72.83537300,41.84930200),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ethel Walker School",'Simsbury=' + Simsbury.length);
Woodbridge[Woodbridge.length] = createMarker(new GPoint(-73.00532200,41.33781600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ezra Academy",'Woodbridge=' + Woodbridge.length);
Greenwich[Greenwich.length] = createMarker(new GPoint(-73.62525700,41.04169300),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Greenwich Academy",'Greenwich=' + Greenwich.length);
Washington_Depot[Washington_Depot.length] = createMarker(new GPoint(-73.31840400,41.64120000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Horace Mann School John Dorr Nature Laboratory",'Washington_Depot=' + Washington_Depot.length);
Meriden[Meriden.length] = createMarker(new GPoint(-72.80789000,41.51122100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kinder Garden Learning Center",'Meriden=' + Meriden.length);
Westport[Westport.length] = createMarker(new GPoint(-73.36719700,41.13714300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Landmark Academy",'Westport=' + Westport.length);
Stamford[Stamford.length] = createMarker(new GPoint(-73.60117100,41.13926100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Long Ridge School",'Stamford=' + Stamford.length);
Windsor[Windsor.length] = createMarker(new GPoint(-72.64108700,41.83868400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Loomis Chaffee School",'Windsor=' + Windsor.length);
Kensington[Kensington.length] = createMarker(new GPoint(-72.79402400,41.64290300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mooreland Hill School",'Kensington=' + Kensington.length);
New_Canaan[New_Canaan.length] = createMarker(new GPoint(-73.49400000,41.14990000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Canaan Country School",'New_Canaan=' + New_Canaan.length);
Mansfield[Mansfield.length] = createMarker(new GPoint(-72.23489700,41.73088900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Oak Grove Montessori Elem/pres",'Mansfield=' + Mansfield.length);
Plainville[Plainville.length] = createMarker(new GPoint(-72.86085500,41.67293000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Penny's Playground Of Learning",'Plainville=' + Plainville.length);
Branford[Branford.length] = createMarker(new GPoint(-72.76914800,41.28230300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Pine Brook School",'Branford=' + Branford.length);
Pomfret[Pomfret.length] = createMarker(new GPoint(-71.95916200,41.89777900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Rectory School",'Pomfret=' + Pomfret.length);
West_Hartford[West_Hartford.length] = createMarker(new GPoint(-72.77817700,41.79048000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Renbrook School",'West_Hartford=' + West_Hartford.length);
Washington_Depot[Washington_Depot.length] = createMarker(new GPoint(-73.29740700,41.68106300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rumsey Hall School",'Washington_Depot=' + Washington_Depot.length);
Hamden[Hamden.length] = createMarker(new GPoint(-72.93215300,41.36503700),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sacred Heart Academy",'Hamden=' + Hamden.length);
Stratford[Stratford.length] = createMarker(new GPoint(-73.12910400,41.19001300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. James School",'Stratford=' + Stratford.length);
Salisbury[Salisbury.length] = createMarker(new GPoint(-73.39292900,42.00093800),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Salisbury School",'Salisbury=' + Salisbury.length);
New_Britain[New_Britain.length] = createMarker(new GPoint(-72.77917700,41.65843600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Joseph School",'New_Britain=' + New_Britain.length);
Jewett_City[Jewett_City.length] = createMarker(new GPoint(-71.98077600,41.60876900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Mary Elementary School",'Jewett_City=' + Jewett_City.length);
Greenwich[Greenwich.length] = createMarker(new GPoint(-73.60428000,41.07172900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Stanwich School",'Greenwich=' + Greenwich.length);
Suffield[Suffield.length] = createMarker(new GPoint(-72.65005200,41.98544000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Suffield Academy",'Suffield=' + Suffield.length);
Stamford[Stamford.length] = createMarker(new GPoint(-73.55241900,41.14210200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Villa Maria School",'Stamford=' + Stamford.length);
Middletown[Middletown.length] = createMarker(new GPoint(-72.62082800,41.53384600),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Xavier High School",'Middletown=' + Middletown.length);
New_Haven[New_Haven.length] = createMarker(new GPoint(-72.93149700,41.30343600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Yale Child Study Center School",'New_Haven=' + New_Haven.length);
map.removeOverlays(Avon);
map.removeOverlays(Bloomfield);
map.removeOverlays(Branford);
map.removeOverlays(Greenwich);
map.removeOverlays(Hamden);
map.removeOverlays(Jewett_City);
map.removeOverlays(Kensington);
map.removeOverlays(Madison);
map.removeOverlays(Mansfield);
map.removeOverlays(Meriden);
map.removeOverlays(Middletown);
map.removeOverlays(Milford);
map.removeOverlays(New_Britain);
map.removeOverlays(New_Canaan);
map.removeOverlays(New_Haven);
map.removeOverlays(Plainville);
map.removeOverlays(Pomfret);
map.removeOverlays(Salisbury);
map.removeOverlays(Simsbury);
map.removeOverlays(Stamford);
map.removeOverlays(Stratford);
map.removeOverlays(Suffield);
map.removeOverlays(Washington_Depot);
map.removeOverlays(West_Hartford);
map.removeOverlays(Westport);
map.removeOverlays(Windsor);
map.removeOverlays(Woodbridge);
setTimeout(function(){map.addOverlays(Avon)},1000);
setTimeout(function(){map.addOverlays(Bloomfield)},1000);
setTimeout(function(){map.addOverlays(Branford)},1000);
setTimeout(function(){map.addOverlays(Greenwich)},1000);
setTimeout(function(){map.addOverlays(Hamden)},1000);
setTimeout(function(){map.addOverlays(Jewett_City)},1000);
setTimeout(function(){map.addOverlays(Kensington)},1000);
setTimeout(function(){map.addOverlays(Madison)},1000);
setTimeout(function(){map.addOverlays(Mansfield)},1000);
setTimeout(function(){map.addOverlays(Meriden)},1000);
setTimeout(function(){map.addOverlays(Middletown)},1000);
setTimeout(function(){map.addOverlays(Milford)},1000);
setTimeout(function(){map.addOverlays(New_Britain)},1000);
setTimeout(function(){map.addOverlays(New_Canaan)},1000);
setTimeout(function(){map.addOverlays(New_Haven)},1000);
setTimeout(function(){map.addOverlays(Plainville)},1000);
setTimeout(function(){map.addOverlays(Pomfret)},1000);
setTimeout(function(){map.addOverlays(Salisbury)},1000);
setTimeout(function(){map.addOverlays(Simsbury)},1000);
setTimeout(function(){map.addOverlays(Stamford)},1000);
setTimeout(function(){map.addOverlays(Stratford)},1000);
setTimeout(function(){map.addOverlays(Suffield)},1000);
setTimeout(function(){map.addOverlays(Washington_Depot)},1000);
setTimeout(function(){map.addOverlays(West_Hartford)},1000);
setTimeout(function(){map.addOverlays(Westport)},1000);
setTimeout(function(){map.addOverlays(Windsor)},1000);
setTimeout(function(){map.addOverlays(Woodbridge)},1000);
maxLng = -71.95916200;
maxLat = 42.00093800;
minLng = -73.62525700;
minLat = 41.04169300;
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(Avon);
map.removeOverlays(Bloomfield);
map.removeOverlays(Branford);
map.removeOverlays(Greenwich);
map.removeOverlays(Hamden);
map.removeOverlays(Jewett_City);
map.removeOverlays(Kensington);
map.removeOverlays(Madison);
map.removeOverlays(Mansfield);
map.removeOverlays(Meriden);
map.removeOverlays(Middletown);
map.removeOverlays(Milford);
map.removeOverlays(New_Britain);
map.removeOverlays(New_Canaan);
map.removeOverlays(New_Haven);
map.removeOverlays(Plainville);
map.removeOverlays(Pomfret);
map.removeOverlays(Salisbury);
map.removeOverlays(Simsbury);
map.removeOverlays(Stamford);
map.removeOverlays(Stratford);
map.removeOverlays(Suffield);
map.removeOverlays(Washington_Depot);
map.removeOverlays(West_Hartford);
map.removeOverlays(Westport);
map.removeOverlays(Windsor);
map.removeOverlays(Woodbridge);
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(Milford);map.removeOverlays(Avon);
map.removeOverlays(Bloomfield);
map.removeOverlays(Branford);
map.removeOverlays(Greenwich);
map.removeOverlays(Hamden);
map.removeOverlays(Jewett_City);
map.removeOverlays(Kensington);
map.removeOverlays(Madison);
map.removeOverlays(Mansfield);
map.removeOverlays(Meriden);
map.removeOverlays(Middletown);
map.removeOverlays(Milford);
map.removeOverlays(New_Britain);
map.removeOverlays(New_Canaan);
map.removeOverlays(New_Haven);
map.removeOverlays(Plainville);
map.removeOverlays(Pomfret);
map.removeOverlays(Salisbury);
map.removeOverlays(Simsbury);
map.removeOverlays(Stamford);
map.removeOverlays(Stratford);
map.removeOverlays(Suffield);
map.removeOverlays(Washington_Depot);
map.removeOverlays(West_Hartford);
map.removeOverlays(Westport);
map.removeOverlays(Windsor);
map.removeOverlays(Woodbridge);
map.addOverlays(Avon);
centerByArray(Avon, false, false);
cntMarker += Avon.length;
map.addOverlays(Bloomfield);
centerByArray(Bloomfield, false, false);
cntMarker += Bloomfield.length;
map.addOverlays(Branford);
centerByArray(Branford, false, false);
cntMarker += Branford.length;
map.addOverlays(Greenwich);
centerByArray(Greenwich, false, false);
cntMarker += Greenwich.length;
map.addOverlays(Hamden);
centerByArray(Hamden, false, false);
cntMarker += Hamden.length;
map.addOverlays(Jewett_City);
centerByArray(Jewett_City, false, false);
cntMarker += Jewett_City.length;
map.addOverlays(Kensington);
centerByArray(Kensington, false, false);
cntMarker += Kensington.length;
map.addOverlays(Madison);
centerByArray(Madison, false, false);
cntMarker += Madison.length;
map.addOverlays(Mansfield);
centerByArray(Mansfield, false, false);
cntMarker += Mansfield.length;
map.addOverlays(Meriden);
centerByArray(Meriden, false, false);
cntMarker += Meriden.length;
map.addOverlays(Middletown);
centerByArray(Middletown, false, false);
cntMarker += Middletown.length;
map.addOverlays(Milford);
centerByArray(Milford, false, false);
cntMarker += Milford.length;
map.addOverlays(New_Britain);
centerByArray(New_Britain, false, false);
cntMarker += New_Britain.length;
map.addOverlays(New_Canaan);
centerByArray(New_Canaan, false, false);
cntMarker += New_Canaan.length;
map.addOverlays(New_Haven);
centerByArray(New_Haven, false, false);
cntMarker += New_Haven.length;
map.addOverlays(Plainville);
centerByArray(Plainville, false, false);
cntMarker += Plainville.length;
map.addOverlays(Pomfret);
centerByArray(Pomfret, false, false);
cntMarker += Pomfret.length;
map.addOverlays(Salisbury);
centerByArray(Salisbury, false, false);
cntMarker += Salisbury.length;
map.addOverlays(Simsbury);
centerByArray(Simsbury, false, false);
cntMarker += Simsbury.length;
map.addOverlays(Stamford);
centerByArray(Stamford, false, false);
cntMarker += Stamford.length;
map.addOverlays(Stratford);
centerByArray(Stratford, false, false);
cntMarker += Stratford.length;
map.addOverlays(Suffield);
centerByArray(Suffield, false, false);
cntMarker += Suffield.length;
map.addOverlays(Washington_Depot);
centerByArray(Washington_Depot, false, false);
cntMarker += Washington_Depot.length;
map.addOverlays(West_Hartford);
centerByArray(West_Hartford, false, false);
cntMarker += West_Hartford.length;
map.addOverlays(Westport);
centerByArray(Westport, false, false);
cntMarker += Westport.length;
map.addOverlays(Windsor);
centerByArray(Windsor, false, false);
cntMarker += Windsor.length;
map.addOverlays(Woodbridge);
centerByArray(Woodbridge, false, false);
cntMarker += Woodbridge.length;
centerByArray(Milford,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///35784,35605,35607,5433,5610,5271,5400,5428,5451,5319,5557,5432,5429,5381,5561,5602,35605,35607,5519,5395,5567,5410,5638,5502,5400,5611,5657,5428,5566,5319,5574,5592,5556,35606,5432,5429,5643,5320,/all');
//window.open('/map.php?type=2&schools=35784,35605,35607,5433,5610,5271,5400,5428,5451,5319,5557,5432,5429,5381,5561,5602,35605,35607,5519,5395,5567,5410,5638,5502,5400,5611,5657,5428,5566,5319,5574,5592,5556,35606,5432,5429,5643,5320,&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;
}