function addMarkers(){
mySelect = document.getElementById('selection');
Morrisville = [];Montpelier = [];Burlington = [];Rutland = [];Saint_Johnsbury = [];Springfield = [];South_Burlington = [];Newport = [];Winooski = [];Brattleboro = [];Bennington = [];Middlebury = [];Barton = [];mySelect.options[mySelect.options.length] = new Option("Barton schools",'all=Barton');
mySelect.options[mySelect.options.length] = new Option("Bennington schools",'all=Bennington');
mySelect.options[mySelect.options.length] = new Option("Brattleboro schools",'all=Brattleboro');
mySelect.options[mySelect.options.length] = new Option("Burlington schools",'all=Burlington');
mySelect.options[mySelect.options.length] = new Option("Middlebury schools",'all=Middlebury');
mySelect.options[mySelect.options.length] = new Option("Montpelier schools",'all=Montpelier');
mySelect.options[mySelect.options.length] = new Option("Morrisville schools",'all=Morrisville');
mySelect.options[mySelect.options.length] = new Option("Newport schools",'all=Newport');
mySelect.options[mySelect.options.length] = new Option("Rutland schools",'all=Rutland');
mySelect.options[mySelect.options.length] = new Option("Saint Johnsbury schools",'all=Saint_Johnsbury');
mySelect.options[mySelect.options.length] = new Option("South Burlington schools",'all=South_Burlington');
mySelect.options[mySelect.options.length] = new Option("Springfield schools",'all=Springfield');
mySelect.options[mySelect.options.length] = new Option("Winooski schools",'all=Winooski');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Morrisville[Morrisville.length] = createMarker(new GPoint(-72.61311300,44.55585400),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bishop John A. Marshall School",'Morrisville=' + Morrisville.length);
Montpelier[Montpelier.length] = createMarker(new GPoint(-72.57493100,44.25748600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central Vermont Catholic School - St Michael Campus",'Montpelier=' + Montpelier.length);
Burlington[Burlington.length] = createMarker(new GPoint(-73.21118600,44.46316500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christ The King School",'Burlington=' + Burlington.length);
Rutland[Rutland.length] = createMarker(new GPoint(-72.97120900,43.60396300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christ The King School",'Rutland=' + Rutland.length);
Saint_Johnsbury[Saint_Johnsbury.length] = createMarker(new GPoint(-72.01761200,44.42055700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Good Shepherd Catholic School",'Saint_Johnsbury=' + Saint_Johnsbury.length);
Springfield[Springfield.length] = createMarker(new GPoint(-72.48005200,43.30018200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Family Catholic School",'Springfield=' + Springfield.length);
Burlington[Burlington.length] = createMarker(new GPoint(-73.19866400,44.48204500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mater Christi School",'Burlington=' + Burlington.length);
Rutland[Rutland.length] = createMarker(new GPoint(-72.98538600,43.60297500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mount St Joseph Academy",'Rutland=' + Rutland.length);
South_Burlington[South_Burlington.length] = createMarker(new GPoint(-73.20044400,44.45381800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rice Memorial High School",'South_Burlington=' + South_Burlington.length);
Newport[Newport.length] = createMarker(new GPoint(-72.21667700,44.93084100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sacred Heart School",'Newport=' + Newport.length);
Winooski[Winooski.length] = createMarker(new GPoint(-73.18746400,44.49639900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Francis Xavier School",'Winooski=' + Winooski.length);
Brattleboro[Brattleboro.length] = createMarker(new GPoint(-72.55829800,42.85605900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Michael R.c. School",'Brattleboro=' + Brattleboro.length);
Bennington[Bennington.length] = createMarker(new GPoint(-73.19461200,42.88203600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The School Of Sacred Heart St Francis De Sales",'Bennington=' + Bennington.length);
Burlington[Burlington.length] = createMarker(new GPoint(-73.21435500,44.48381100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Joseph School",'Burlington=' + Burlington.length);
Middlebury[Middlebury.length] = createMarker(new GPoint(-73.17484700,44.01191300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Mary's School",'Middlebury=' + Middlebury.length);
Barton[Barton.length] = createMarker(new GPoint(-72.17513400,44.74776300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Pauls School",'Barton=' + Barton.length);
map.removeOverlays(Barton);
map.removeOverlays(Bennington);
map.removeOverlays(Brattleboro);
map.removeOverlays(Burlington);
map.removeOverlays(Middlebury);
map.removeOverlays(Montpelier);
map.removeOverlays(Morrisville);
map.removeOverlays(Newport);
map.removeOverlays(Rutland);
map.removeOverlays(Saint_Johnsbury);
map.removeOverlays(South_Burlington);
map.removeOverlays(Springfield);
map.removeOverlays(Winooski);
setTimeout(function(){map.addOverlays(Barton)},1000);
setTimeout(function(){map.addOverlays(Bennington)},1000);
setTimeout(function(){map.addOverlays(Brattleboro)},1000);
setTimeout(function(){map.addOverlays(Burlington)},1000);
setTimeout(function(){map.addOverlays(Middlebury)},1000);
setTimeout(function(){map.addOverlays(Montpelier)},1000);
setTimeout(function(){map.addOverlays(Morrisville)},1000);
setTimeout(function(){map.addOverlays(Newport)},1000);
setTimeout(function(){map.addOverlays(Rutland)},1000);
setTimeout(function(){map.addOverlays(Saint_Johnsbury)},1000);
setTimeout(function(){map.addOverlays(South_Burlington)},1000);
setTimeout(function(){map.addOverlays(Springfield)},1000);
setTimeout(function(){map.addOverlays(Winooski)},1000);
maxLng = -72.01761200;
maxLat = 44.93084100;
minLng = -73.21435500;
minLat = 42.85605900;
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(Barton);
map.removeOverlays(Bennington);
map.removeOverlays(Brattleboro);
map.removeOverlays(Burlington);
map.removeOverlays(Middlebury);
map.removeOverlays(Montpelier);
map.removeOverlays(Morrisville);
map.removeOverlays(Newport);
map.removeOverlays(Rutland);
map.removeOverlays(Saint_Johnsbury);
map.removeOverlays(South_Burlington);
map.removeOverlays(Springfield);
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(Morrisville);map.removeOverlays(Barton);
map.removeOverlays(Bennington);
map.removeOverlays(Brattleboro);
map.removeOverlays(Burlington);
map.removeOverlays(Middlebury);
map.removeOverlays(Montpelier);
map.removeOverlays(Morrisville);
map.removeOverlays(Newport);
map.removeOverlays(Rutland);
map.removeOverlays(Saint_Johnsbury);
map.removeOverlays(South_Burlington);
map.removeOverlays(Springfield);
map.removeOverlays(Winooski);
map.addOverlays(Barton);
centerByArray(Barton, false, false);
cntMarker += Barton.length;
map.addOverlays(Bennington);
centerByArray(Bennington, false, false);
cntMarker += Bennington.length;
map.addOverlays(Brattleboro);
centerByArray(Brattleboro, false, false);
cntMarker += Brattleboro.length;
map.addOverlays(Burlington);
centerByArray(Burlington, false, false);
cntMarker += Burlington.length;
map.addOverlays(Middlebury);
centerByArray(Middlebury, false, false);
cntMarker += Middlebury.length;
map.addOverlays(Montpelier);
centerByArray(Montpelier, false, false);
cntMarker += Montpelier.length;
map.addOverlays(Morrisville);
centerByArray(Morrisville, false, false);
cntMarker += Morrisville.length;
map.addOverlays(Newport);
centerByArray(Newport, false, false);
cntMarker += Newport.length;
map.addOverlays(Rutland);
centerByArray(Rutland, false, false);
cntMarker += Rutland.length;
map.addOverlays(Saint_Johnsbury);
centerByArray(Saint_Johnsbury, false, false);
cntMarker += Saint_Johnsbury.length;
map.addOverlays(South_Burlington);
centerByArray(South_Burlington, false, false);
cntMarker += South_Burlington.length;
map.addOverlays(Springfield);
centerByArray(Springfield, false, false);
cntMarker += Springfield.length;
map.addOverlays(Winooski);
centerByArray(Winooski, false, false);
cntMarker += Winooski.length;
centerByArray(Morrisville,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///27949,27968,27988,27973,27975,27913,27941,27986,27989,27987,27902,27974,27914,27923,27930,27983,/all');
//window.open('/map.php?type=2&schools=27949,27968,27988,27973,27975,27913,27941,27986,27989,27987,27902,27974,27914,27923,27930,27983,&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;
}