function addMarkers()
{
mySelect = document.getElementById('selection');
Florida = [];Adams = [];Pittsfield = [];Becket = [];North_Adams = [];Cheshire = [];Clarksburg = [];Dalton = [];Otis = [];Hancock = [];Housatonic = [];Hinsdale = [];Lanesborough = [];Lee = [];Lenox = [];Sheffield = [];Great_Barrington = [];Williamstown = [];Richmond = [];Savoy = [];Stockbridge = [];West_Stockbridge = [];mySelect.options[mySelect.options.length] = new Option("Adams schools",'all=Adams');
mySelect.options[mySelect.options.length] = new Option("Becket schools",'all=Becket');
mySelect.options[mySelect.options.length] = new Option("Cheshire schools",'all=Cheshire');
mySelect.options[mySelect.options.length] = new Option("Clarksburg schools",'all=Clarksburg');
mySelect.options[mySelect.options.length] = new Option("Dalton schools",'all=Dalton');
mySelect.options[mySelect.options.length] = new Option("Florida schools",'all=Florida');
mySelect.options[mySelect.options.length] = new Option("Great Barrington schools",'all=Great_Barrington');
mySelect.options[mySelect.options.length] = new Option("Hancock schools",'all=Hancock');
mySelect.options[mySelect.options.length] = new Option("Hinsdale schools",'all=Hinsdale');
mySelect.options[mySelect.options.length] = new Option("Housatonic schools",'all=Housatonic');
mySelect.options[mySelect.options.length] = new Option("Lanesborough schools",'all=Lanesborough');
mySelect.options[mySelect.options.length] = new Option("Lee schools",'all=Lee');
mySelect.options[mySelect.options.length] = new Option("Lenox schools",'all=Lenox');
mySelect.options[mySelect.options.length] = new Option("North Adams schools",'all=North_Adams');
mySelect.options[mySelect.options.length] = new Option("Otis schools",'all=Otis');
mySelect.options[mySelect.options.length] = new Option("Pittsfield schools",'all=Pittsfield');
mySelect.options[mySelect.options.length] = new Option("Richmond schools",'all=Richmond');
mySelect.options[mySelect.options.length] = new Option("Savoy schools",'all=Savoy');
mySelect.options[mySelect.options.length] = new Option("Sheffield schools",'all=Sheffield');
mySelect.options[mySelect.options.length] = new Option("Stockbridge schools",'all=Stockbridge');
mySelect.options[mySelect.options.length] = new Option("West Stockbridge schools",'all=West_Stockbridge');
mySelect.options[mySelect.options.length] = new Option("Williamstown schools",'all=Williamstown');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Florida[Florida.length] = createMarker(new GPoint(-73.03746796,42.69341660),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Abbott Memorial Elementary School",'Florida=' + Florida.length);
Adams[Adams.length] = createMarker(new GPoint(-73.11667633,42.62806320),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Adams Middle School",'Adams=' + Adams.length);
Pittsfield[Pittsfield.length] = createMarker(new GPoint(-73.22058105,42.45981216),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Allendale Elementary School",'Pittsfield=' + Pittsfield.length);
Becket[Becket.length] = createMarker(new GPoint(-73.08329773,42.33209991),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Becket Washington School",'Becket=' + Becket.length);
Adams[Adams.length] = createMarker(new GPoint(-73.12116500,42.61959300),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Berkshire Arts And Technology Charter School",'Adams=' + Adams.length);
North_Adams[North_Adams.length] = createMarker(new GPoint(-73.15434265,42.69562149),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Brayton Elementary School",'North_Adams=' + North_Adams.length);
North_Adams[North_Adams.length] = createMarker(new GPoint(-73.10505676,42.66504288),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Charles Mccann Vocational Technical High School",'North_Adams=' + North_Adams.length);
Cheshire[Cheshire.length] = createMarker(new GPoint(-73.15903473,42.56225967),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cheshire Elementary School",'Cheshire=' + Cheshire.length);
Clarksburg[Clarksburg.length] = createMarker(new GPoint(-73.11666107,42.74152756),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clarksburg Elementary School",'Clarksburg=' + Clarksburg.length);
Dalton[Dalton.length] = createMarker(new GPoint(-73.17580414,42.47522736),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Craneville Elementary School",'Dalton=' + Dalton.length);
Pittsfield[Pittsfield.length] = createMarker(new GPoint(-73.27373505,42.45129395),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Crosby Elementary School",'Pittsfield=' + Pittsfield.length);
North_Adams[North_Adams.length] = createMarker(new GPoint(-73.09818268,42.67327881),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Drury High School",'North_Adams=' + North_Adams.length);
Pittsfield[Pittsfield.length] = createMarker(new GPoint(-73.22861481,42.43693542),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Egremont Elementary School",'Pittsfield=' + Pittsfield.length);
Otis[Otis.length] = createMarker(new GPoint(-73.10955811,42.23075104),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Farmington River Elementary School",'Otis=' + Otis.length);
North_Adams[North_Adams.length] = createMarker(new GPoint(-73.15589905,42.69839859),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Greylock Elementary School",'North_Adams=' + North_Adams.length);
Hancock[Hancock.length] = createMarker(new GPoint(-73.32437897,42.54315948),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hancock Elementary School",'Hancock=' + Hancock.length);
Pittsfield[Pittsfield.length] = createMarker(new GPoint(-73.22887421,42.44906998),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hibbard Alternative",'Pittsfield=' + Pittsfield.length);
Cheshire[Cheshire.length] = createMarker(new GPoint(-73.11719513,42.59412003),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hoosac Valley High School",'Cheshire=' + Cheshire.length);
Housatonic[Housatonic.length] = createMarker(new GPoint(-73.36746216,42.25497818),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Housatonic Grammar Elementary School",'Housatonic=' + Housatonic.length);
North_Adams[North_Adams.length] = createMarker(new GPoint(-73.09681702,42.69598007),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("J S Sullivan Elementary School",'North_Adams=' + North_Adams.length);
Pittsfield[Pittsfield.length] = createMarker(new GPoint(-73.24543762,42.46691132),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("John T Reid Middle School",'Pittsfield=' + Pittsfield.length);
Hinsdale[Hinsdale.length] = createMarker(new GPoint(-73.11798096,42.44129944),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kittredge Elementary School",'Hinsdale=' + Hinsdale.length);
Lanesborough[Lanesborough.length] = createMarker(new GPoint(-73.22017670,42.51384735),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lanesborough Elementary School",'Lanesborough=' + Lanesborough.length);
Lee[Lee.length] = createMarker(new GPoint(-73.24855804,42.30757523),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lee Elementary School",'Lee=' + Lee.length);
Lee[Lee.length] = createMarker(new GPoint(-73.24057770,42.30645752),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lee Middle/high School",'Lee=' + Lee.length);
Lenox[Lenox.length] = createMarker(new GPoint(-73.25931549,42.35550308),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lenox Memorial High School",'Lenox=' + Lenox.length);
Sheffield[Sheffield.length] = createMarker(new GPoint(-73.35371400,42.11095000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Monterey",'Sheffield=' + Sheffield.length);
Sheffield[Sheffield.length] = createMarker(new GPoint(-73.36840057,42.10229874),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Monterey Elementary School",'Sheffield=' + Sheffield.length);
Great_Barrington[Great_Barrington.length] = createMarker(new GPoint(-73.36145020,42.19551849),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Monument Mt Regional High School",'Great_Barrington=' + Great_Barrington.length);
Great_Barrington[Great_Barrington.length] = createMarker(new GPoint(-73.32966500,42.24572400),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Monument Valley Regional Middle School",'Great_Barrington=' + Great_Barrington.length);
Pittsfield[Pittsfield.length] = createMarker(new GPoint(-73.24492645,42.45751572),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Morningside Community School",'Pittsfield=' + Pittsfield.length);
Lenox[Lenox.length] = createMarker(new GPoint(-73.29638672,42.35658264),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Morris Elementary School",'Lenox=' + Lenox.length);
Sheffield[Sheffield.length] = createMarker(new GPoint(-73.36840057,42.10229874),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mt Everett Regional High School",'Sheffield=' + Sheffield.length);
Williamstown[Williamstown.length] = createMarker(new GPoint(-73.23743439,42.67148972),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mt Greylock Regional High School",'Williamstown=' + Williamstown.length);
Great_Barrington[Great_Barrington.length] = createMarker(new GPoint(-73.32875400,42.24393800),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Muddy Brook Regional Elementary School",'Great_Barrington=' + Great_Barrington.length);
Dalton[Dalton.length] = createMarker(new GPoint(-73.13948822,42.46718216),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Nessacus Regional Middle School",'Dalton=' + Dalton.length);
Sheffield[Sheffield.length] = createMarker(new GPoint(-73.36840057,42.10229874),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("New Marlborough Central Elementary School",'Sheffield=' + Sheffield.length);
Pittsfield[Pittsfield.length] = createMarker(new GPoint(-73.24791718,42.44736481),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pittsfield High School",'Pittsfield=' + Pittsfield.length);
Adams[Adams.length] = createMarker(new GPoint(-73.12106323,42.61887360),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Plunkett Elementary School",'Adams=' + Adams.length);
Richmond[Richmond.length] = createMarker(new GPoint(-73.36726379,42.38989258),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Richmond Consolidated Elementary School",'Richmond=' + Richmond.length);
Pittsfield[Pittsfield.length] = createMarker(new GPoint(-73.26116180,42.48103333),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Robert T. Capeless Elementary School",'Pittsfield=' + Pittsfield.length);
Savoy[Savoy.length] = createMarker(new GPoint(-72.99570465,42.56927872),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Savoy Elementary School",'Savoy=' + Savoy.length);
Great_Barrington[Great_Barrington.length] = createMarker(new GPoint(-73.35896301,42.19263840),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Searles Middle School",'Great_Barrington=' + Great_Barrington.length);
Pittsfield[Pittsfield.length] = createMarker(new GPoint(-73.26574707,42.45528412),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Silvio O Conte Community Elementary School",'Pittsfield=' + Pittsfield.length);
North_Adams[North_Adams.length] = createMarker(new GPoint(-73.10134125,42.68946075),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Silvio O Conte Middle School",'North_Adams=' + North_Adams.length);
Sheffield[Sheffield.length] = createMarker(new GPoint(-73.36840057,42.10229874),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South Egremont Elementary School",'Sheffield=' + Sheffield.length);
Pittsfield[Pittsfield.length] = createMarker(new GPoint(-73.29998779,42.43687820),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Stearns Elementary School",'Pittsfield=' + Pittsfield.length);
Stockbridge[Stockbridge.length] = createMarker(new GPoint(-73.30255890,42.28170013),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Stockbridge Plain Elementary School",'Stockbridge=' + Stockbridge.length);
Pittsfield[Pittsfield.length] = createMarker(new GPoint(-73.27767181,42.45563507),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Taconic High School",'Pittsfield=' + Pittsfield.length);
Pittsfield[Pittsfield.length] = createMarker(new GPoint(-73.24317169,42.43327332),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Theodore Herberg Middle School",'Pittsfield=' + Pittsfield.length);
Sheffield[Sheffield.length] = createMarker(new GPoint(-73.36840057,42.10229874),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Undermountain Elementary School",'Sheffield=' + Sheffield.length);
West_Stockbridge[West_Stockbridge.length] = createMarker(new GPoint(-73.37186432,42.33709717),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Village Elementary School",'West_Stockbridge=' + West_Stockbridge.length);
Dalton[Dalton.length] = createMarker(new GPoint(-73.11375427,42.47332382),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wahconah Regional High School",'Dalton=' + Dalton.length);
Great_Barrington[Great_Barrington.length] = createMarker(new GPoint(-73.36070251,42.19342422),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("William Cullen Bryant Elementary School",'Great_Barrington=' + Great_Barrington.length);
Pittsfield[Pittsfield.length] = createMarker(new GPoint(-73.21044922,42.43598557),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Williams Elementary School",'Pittsfield=' + Pittsfield.length);
Williamstown[Williamstown.length] = createMarker(new GPoint(-73.19915009,42.71496964),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Williamstown Elementary School",'Williamstown=' + Williamstown.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,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(Adams);
map.removeOverlays(Becket);
map.removeOverlays(Cheshire);
map.removeOverlays(Clarksburg);
map.removeOverlays(Dalton);
map.removeOverlays(Florida);
map.removeOverlays(Great_Barrington);
map.removeOverlays(Hancock);
map.removeOverlays(Hinsdale);
map.removeOverlays(Housatonic);
map.removeOverlays(Lanesborough);
map.removeOverlays(Lee);
map.removeOverlays(Lenox);
map.removeOverlays(North_Adams);
map.removeOverlays(Otis);
map.removeOverlays(Pittsfield);
map.removeOverlays(Richmond);
map.removeOverlays(Savoy);
map.removeOverlays(Sheffield);
map.removeOverlays(Stockbridge);
map.removeOverlays(West_Stockbridge);
map.removeOverlays(Williamstown);
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(Florida);map.removeOverlays(Adams);
map.removeOverlays(Becket);
map.removeOverlays(Cheshire);
map.removeOverlays(Clarksburg);
map.removeOverlays(Dalton);
map.removeOverlays(Florida);
map.removeOverlays(Great_Barrington);
map.removeOverlays(Hancock);
map.removeOverlays(Hinsdale);
map.removeOverlays(Housatonic);
map.removeOverlays(Lanesborough);
map.removeOverlays(Lee);
map.removeOverlays(Lenox);
map.removeOverlays(North_Adams);
map.removeOverlays(Otis);
map.removeOverlays(Pittsfield);
map.removeOverlays(Richmond);
map.removeOverlays(Savoy);
map.removeOverlays(Sheffield);
map.removeOverlays(Stockbridge);
map.removeOverlays(West_Stockbridge);
map.removeOverlays(Williamstown);
map.addOverlays(Adams);
centerByArray(Adams, false, false);
cntMarker += Adams.length;
map.addOverlays(Becket);
centerByArray(Becket, false, false);
cntMarker += Becket.length;
map.addOverlays(Cheshire);
centerByArray(Cheshire, false, false);
cntMarker += Cheshire.length;
map.addOverlays(Clarksburg);
centerByArray(Clarksburg, false, false);
cntMarker += Clarksburg.length;
map.addOverlays(Dalton);
centerByArray(Dalton, false, false);
cntMarker += Dalton.length;
map.addOverlays(Florida);
centerByArray(Florida, false, false);
cntMarker += Florida.length;
map.addOverlays(Great_Barrington);
centerByArray(Great_Barrington, false, false);
cntMarker += Great_Barrington.length;
map.addOverlays(Hancock);
centerByArray(Hancock, false, false);
cntMarker += Hancock.length;
map.addOverlays(Hinsdale);
centerByArray(Hinsdale, false, false);
cntMarker += Hinsdale.length;
map.addOverlays(Housatonic);
centerByArray(Housatonic, false, false);
cntMarker += Housatonic.length;
map.addOverlays(Lanesborough);
centerByArray(Lanesborough, false, false);
cntMarker += Lanesborough.length;
map.addOverlays(Lee);
centerByArray(Lee, false, false);
cntMarker += Lee.length;
map.addOverlays(Lenox);
centerByArray(Lenox, false, false);
cntMarker += Lenox.length;
map.addOverlays(North_Adams);
centerByArray(North_Adams, false, false);
cntMarker += North_Adams.length;
map.addOverlays(Otis);
centerByArray(Otis, false, false);
cntMarker += Otis.length;
map.addOverlays(Pittsfield);
centerByArray(Pittsfield, false, false);
cntMarker += Pittsfield.length;
map.addOverlays(Richmond);
centerByArray(Richmond, false, false);
cntMarker += Richmond.length;
map.addOverlays(Savoy);
centerByArray(Savoy, false, false);
cntMarker += Savoy.length;
map.addOverlays(Sheffield);
centerByArray(Sheffield, false, false);
cntMarker += Sheffield.length;
map.addOverlays(Stockbridge);
centerByArray(Stockbridge, false, false);
cntMarker += Stockbridge.length;
map.addOverlays(West_Stockbridge);
centerByArray(West_Stockbridge, false, false);
cntMarker += West_Stockbridge.length;
map.addOverlays(Williamstown);
centerByArray(Williamstown, false, false);
cntMarker += Williamstown.length;
centerByArray(Florida,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');
}
}