function addMarkers()
{
mySelect = document.getElementById('selection');
Essex_Junction = [];Huntington = [];Jericho = [];Burlington = [];Richmond = [];South_Burlingto = [];Hinesburg = [];Charlotte = [];Colchester = [];Winooski = [];Milton = [];Shelburne = [];Waterbury = [];Underhill_Ctr = [];Underhill = [];Westford = [];Williston = [];mySelect.options[mySelect.options.length] = new Option("Burlington schools",'all=Burlington');
mySelect.options[mySelect.options.length] = new Option("Charlotte schools",'all=Charlotte');
mySelect.options[mySelect.options.length] = new Option("Colchester schools",'all=Colchester');
mySelect.options[mySelect.options.length] = new Option("Essex Junction schools",'all=Essex_Junction');
mySelect.options[mySelect.options.length] = new Option("Hinesburg schools",'all=Hinesburg');
mySelect.options[mySelect.options.length] = new Option("Huntington schools",'all=Huntington');
mySelect.options[mySelect.options.length] = new Option("Jericho schools",'all=Jericho');
mySelect.options[mySelect.options.length] = new Option("Milton schools",'all=Milton');
mySelect.options[mySelect.options.length] = new Option("Richmond schools",'all=Richmond');
mySelect.options[mySelect.options.length] = new Option("Shelburne schools",'all=Shelburne');
mySelect.options[mySelect.options.length] = new Option("South Burlingto schools",'all=South_Burlingto');
mySelect.options[mySelect.options.length] = new Option("Underhill schools",'all=Underhill');
mySelect.options[mySelect.options.length] = new Option("Underhill Ctr schools",'all=Underhill_Ctr');
mySelect.options[mySelect.options.length] = new Option("Waterbury schools",'all=Waterbury');
mySelect.options[mySelect.options.length] = new Option("Westford schools",'all=Westford');
mySelect.options[mySelect.options.length] = new Option("Williston schools",'all=Williston');
mySelect.options[mySelect.options.length] = new Option("Winooski schools",'all=Winooski');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Essex_Junction[Essex_Junction.length] = createMarker(new GPoint(-73.09010315,44.50180054),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Albert D. Lawton School",'Essex_Junction=' + Essex_Junction.length);
Huntington[Huntington.length] = createMarker(new GPoint(-72.96420288,44.29679489),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Brewster Pierce School",'Huntington=' + Huntington.length);
Jericho[Jericho.length] = createMarker(new GPoint(-72.94553375,44.51982117),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Browns River Middle Usd #17",'Jericho=' + Jericho.length);
Burlington[Burlington.length] = createMarker(new GPoint(-73.22519684,44.48630142),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Burlington S.d.",'Burlington=' + Burlington.length);
Burlington[Burlington.length] = createMarker(new GPoint(-73.23897552,44.49644089),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Burlington Senior High School",'Burlington=' + Burlington.length);
Burlington[Burlington.length] = createMarker(new GPoint(-73.23897552,44.49644089),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Burlington Technical Center",'Burlington=' + Burlington.length);
Burlington[Burlington.length] = createMarker(new GPoint(-73.24230957,44.51310730),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("C. P. Smith School",'Burlington=' + Burlington.length);
Richmond[Richmond.length] = createMarker(new GPoint(-72.99296570,44.41283035),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Camels Hump Middle Usd #17",'Richmond=' + Richmond.length);
South_Burlingto[South_Burlingto.length] = createMarker(new GPoint(-73.16464233,44.47055435),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Chamberlin School",'South_Burlingto=' + South_Burlingto.length);
Burlington[Burlington.length] = createMarker(new GPoint(-73.21411133,44.45695877),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Champlain School",'Burlington=' + Burlington.length);
Hinesburg[Hinesburg.length] = createMarker(new GPoint(-73.10939026,44.34310150),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Champlain Valley Uhsd #15 High School",'Hinesburg=' + Hinesburg.length);
Charlotte[Charlotte.length] = createMarker(new GPoint(-73.23258209,44.31529236),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Charlotte Central School",'Charlotte=' + Charlotte.length);
Essex_Junction[Essex_Junction.length] = createMarker(new GPoint(-73.10340881,44.49789810),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Chittenden Central S.u. Elementary School",'Essex_Junction=' + Essex_Junction.length);
Richmond[Richmond.length] = createMarker(new GPoint(-72.98970032,44.40110016),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Chittenden East S.u. Elementary School",'Richmond=' + Richmond.length);
Hinesburg[Hinesburg.length] = createMarker(new GPoint(-73.11055700,44.34354700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chittenden South Super Unio",'Hinesburg=' + Hinesburg.length);
Colchester[Colchester.length] = createMarker(new GPoint(-73.19779968,44.53929901),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Colchester High School",'Colchester=' + Colchester.length);
Colchester[Colchester.length] = createMarker(new GPoint(-73.19779968,44.53929901),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Colchester Middle School",'Colchester=' + Colchester.length);
Colchester[Colchester.length] = createMarker(new GPoint(-73.14824700,44.54375500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Colchester S.d.",'Colchester=' + Colchester.length);
Burlington[Burlington.length] = createMarker(new GPoint(-73.20776367,44.47596359),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Edmunds Elementary School",'Burlington=' + Burlington.length);
Burlington[Burlington.length] = createMarker(new GPoint(-73.20851898,44.47596359),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Edmunds Middle School",'Burlington=' + Burlington.length);
Burlington[Burlington.length] = createMarker(new GPoint(-73.19407654,44.48173141),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Essential Early Education C Elementary School",'Burlington=' + Burlington.length);
Essex_Junction[Essex_Junction.length] = createMarker(new GPoint(-73.11132812,44.49773788),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Essex Comm. Ed. Center Uhsd #",'Essex_Junction=' + Essex_Junction.length);
Essex_Junction[Essex_Junction.length] = createMarker(new GPoint(-73.05720520,44.51243591),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Essex Elementary School",'Essex_Junction=' + Essex_Junction.length);
Essex_Junction[Essex_Junction.length] = createMarker(new GPoint(-73.11133575,44.49746323),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Essex Jct Regional Technical Center",'Essex_Junction=' + Essex_Junction.length);
Essex_Junction[Essex_Junction.length] = createMarker(new GPoint(-73.05500031,44.50209808),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Essex Middle School",'Essex_Junction=' + Essex_Junction.length);
Essex_Junction[Essex_Junction.length] = createMarker(new GPoint(-73.04929352,44.49990845),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Founders Memorial School",'Essex_Junction=' + Essex_Junction.length);
South_Burlingto[South_Burlingto.length] = createMarker(new GPoint(-73.17883301,44.45484161),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Frederick H. Tuttle Middle School",'South_Burlingto=' + South_Burlingto.length);
Essex_Junction[Essex_Junction.length] = createMarker(new GPoint(-73.12757874,44.48986435),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hiawatha School",'Essex_Junction=' + Essex_Junction.length);
Hinesburg[Hinesburg.length] = createMarker(new GPoint(-73.10964966,44.32646561),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hinesburg Elementary School",'Hinesburg=' + Hinesburg.length);
Winooski[Winooski.length] = createMarker(new GPoint(-73.18234253,44.50109100),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("J. F. Kennedy Elementary School",'Winooski=' + Winooski.length);
Burlington[Burlington.length] = createMarker(new GPoint(-73.25920105,44.51728439),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("J. J. Flynn School",'Burlington=' + Burlington.length);
Jericho[Jericho.length] = createMarker(new GPoint(-72.99266052,44.50619125),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jericho Elementary School",'Jericho=' + Jericho.length);
Burlington[Burlington.length] = createMarker(new GPoint(-73.21715546,44.48446274),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lawrence Barnes School",'Burlington=' + Burlington.length);
Burlington[Burlington.length] = createMarker(new GPoint(-73.25089264,44.51159286),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Lyman C. Hunt Middle School",'Burlington=' + Burlington.length);
Colchester[Colchester.length] = createMarker(new GPoint(-73.19779968,44.53929901),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Malletts Bay School",'Colchester=' + Colchester.length);
Milton[Milton.length] = createMarker(new GPoint(-73.11085510,44.63211060),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Milton Elementary School",'Milton=' + Milton.length);
Milton[Milton.length] = createMarker(new GPoint(-73.11700439,44.62834167),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Milton Junior High School",'Milton=' + Milton.length);
Milton[Milton.length] = createMarker(new GPoint(-73.11700439,44.62834167),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Milton Senior High School",'Milton=' + Milton.length);
Jericho[Jericho.length] = createMarker(new GPoint(-72.96353912,44.48632050),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mt. Mansfield Usd #17 High School",'Jericho=' + Jericho.length);
Burlington[Burlington.length] = createMarker(new GPoint(-73.20317078,44.48024750),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ontop",'Burlington=' + Burlington.length);
South_Burlingto[South_Burlingto.length] = createMarker(new GPoint(-73.21004486,44.43883514),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Orchard School",'South_Burlingto=' + South_Burlingto.length);
Colchester[Colchester.length] = createMarker(new GPoint(-73.19779968,44.53929901),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Porters Point School",'Colchester=' + Colchester.length);
Richmond[Richmond.length] = createMarker(new GPoint(-72.99263000,44.41250229),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Richmond Elementary School",'Richmond=' + Richmond.length);
Shelburne[Shelburne.length] = createMarker(new GPoint(-73.23441315,44.38193512),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Shelburne Community School",'Shelburne=' + Shelburne.length);
Waterbury[Waterbury.length] = createMarker(new GPoint(-72.87898254,44.37323761),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Smilie Memorial School(bolt Elementary School",'Waterbury=' + Waterbury.length);
South_Burlingto[South_Burlingto.length] = createMarker(new GPoint(-73.18053436,44.46537018),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("So. Burlington Central School",'South_Burlingto=' + South_Burlingto.length);
South_Burlingto[South_Burlingto.length] = createMarker(new GPoint(-73.17873383,44.45434952),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("So. Burlington High School",'South_Burlingto=' + South_Burlingto.length);
South_Burlingto[South_Burlingto.length] = createMarker(new GPoint(-73.17873383,44.45434952),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Burlington S.d.",'South_Burlingto=' + South_Burlingto.length);
Essex_Junction[Essex_Junction.length] = createMarker(new GPoint(-73.11490631,44.49256134),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Summit Street School",'Essex_Junction=' + Essex_Junction.length);
Essex_Junction[Essex_Junction.length] = createMarker(new GPoint(-73.11150360,44.49372101),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Thomas Fleming School",'Essex_Junction=' + Essex_Junction.length);
Underhill_Ctr[Underhill_Ctr.length] = createMarker(new GPoint(-72.90045929,44.50737000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Underhill Central School",'Underhill_Ctr=' + Underhill_Ctr.length);
Underhill[Underhill.length] = createMarker(new GPoint(-72.93967438,44.52087402),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Underhill Graded School",'Underhill=' + Underhill.length);
Colchester[Colchester.length] = createMarker(new GPoint(-73.19779968,44.53929901),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Union Memorial School",'Colchester=' + Colchester.length);
Westford[Westford.length] = createMarker(new GPoint(-73.01936340,44.60435486),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Westford Elementary School",'Westford=' + Westford.length);
Burlington[Burlington.length] = createMarker(new GPoint(-73.21334076,44.48786163),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wheeler School",'Burlington=' + Burlington.length);
Williston[Williston.length] = createMarker(new GPoint(-73.07601929,44.43928909),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Williston Schools Elementary School",'Williston=' + Williston.length);
Winooski[Winooski.length] = createMarker(new GPoint(-73.18248749,44.50112915),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Winooski High School",'Winooski=' + Winooski.length);
Winooski[Winooski.length] = createMarker(new GPoint(-73.18248749,44.50112915),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Winooski Middle School",'Winooski=' + Winooski.length);
Colchester[Colchester.length] = createMarker(new GPoint(-73.23753357,44.53639603),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Woodside Juvenile Rehab Center",'Colchester=' + Colchester.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(Burlington);
map.removeOverlays(Charlotte);
map.removeOverlays(Colchester);
map.removeOverlays(Essex_Junction);
map.removeOverlays(Hinesburg);
map.removeOverlays(Huntington);
map.removeOverlays(Jericho);
map.removeOverlays(Milton);
map.removeOverlays(Richmond);
map.removeOverlays(Shelburne);
map.removeOverlays(South_Burlingto);
map.removeOverlays(Underhill);
map.removeOverlays(Underhill_Ctr);
map.removeOverlays(Waterbury);
map.removeOverlays(Westford);
map.removeOverlays(Williston);
map.removeOverlays(Winooski);
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(Essex_Junction);map.removeOverlays(Burlington);
map.removeOverlays(Charlotte);
map.removeOverlays(Colchester);
map.removeOverlays(Essex_Junction);
map.removeOverlays(Hinesburg);
map.removeOverlays(Huntington);
map.removeOverlays(Jericho);
map.removeOverlays(Milton);
map.removeOverlays(Richmond);
map.removeOverlays(Shelburne);
map.removeOverlays(South_Burlingto);
map.removeOverlays(Underhill);
map.removeOverlays(Underhill_Ctr);
map.removeOverlays(Waterbury);
map.removeOverlays(Westford);
map.removeOverlays(Williston);
map.removeOverlays(Winooski);
map.addOverlays(Burlington);
centerByArray(Burlington, false, false);
cntMarker += Burlington.length;
map.addOverlays(Charlotte);
centerByArray(Charlotte, false, false);
cntMarker += Charlotte.length;
map.addOverlays(Colchester);
centerByArray(Colchester, false, false);
cntMarker += Colchester.length;
map.addOverlays(Essex_Junction);
centerByArray(Essex_Junction, false, false);
cntMarker += Essex_Junction.length;
map.addOverlays(Hinesburg);
centerByArray(Hinesburg, false, false);
cntMarker += Hinesburg.length;
map.addOverlays(Huntington);
centerByArray(Huntington, false, false);
cntMarker += Huntington.length;
map.addOverlays(Jericho);
centerByArray(Jericho, false, false);
cntMarker += Jericho.length;
map.addOverlays(Milton);
centerByArray(Milton, false, false);
cntMarker += Milton.length;
map.addOverlays(Richmond);
centerByArray(Richmond, false, false);
cntMarker += Richmond.length;
map.addOverlays(Shelburne);
centerByArray(Shelburne, false, false);
cntMarker += Shelburne.length;
map.addOverlays(South_Burlingto);
centerByArray(South_Burlingto, false, false);
cntMarker += South_Burlingto.length;
map.addOverlays(Underhill);
centerByArray(Underhill, false, false);
cntMarker += Underhill.length;
map.addOverlays(Underhill_Ctr);
centerByArray(Underhill_Ctr, false, false);
cntMarker += Underhill_Ctr.length;
map.addOverlays(Waterbury);
centerByArray(Waterbury, false, false);
cntMarker += Waterbury.length;
map.addOverlays(Westford);
centerByArray(Westford, false, false);
cntMarker += Westford.length;
map.addOverlays(Williston);
centerByArray(Williston, false, false);
cntMarker += Williston.length;
map.addOverlays(Winooski);
centerByArray(Winooski, false, false);
cntMarker += Winooski.length;
centerByArray(Essex_Junction,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');
}
}