function addMarkers(){
mySelect = document.getElementById('selection');
Mansfield = [];Braintree = [];Brookline = [];Quincy = [];Sharon = [];Canton = [];Wellesley = [];Weymouth = [];Milton = [];East_Walpole = [];Walpole = [];Wapole = [];Holbrook = [];Randolph = [];Medfield = [];Dedham = [];Needham = [];Westwood = [];mySelect.options[mySelect.options.length] = new Option("Braintree schools",'all=Braintree');
mySelect.options[mySelect.options.length] = new Option("Brookline schools",'all=Brookline');
mySelect.options[mySelect.options.length] = new Option("Canton schools",'all=Canton');
mySelect.options[mySelect.options.length] = new Option("Dedham schools",'all=Dedham');
mySelect.options[mySelect.options.length] = new Option("East Walpole schools",'all=East_Walpole');
mySelect.options[mySelect.options.length] = new Option("Holbrook schools",'all=Holbrook');
mySelect.options[mySelect.options.length] = new Option("Mansfield schools",'all=Mansfield');
mySelect.options[mySelect.options.length] = new Option("Medfield schools",'all=Medfield');
mySelect.options[mySelect.options.length] = new Option("Milton schools",'all=Milton');
mySelect.options[mySelect.options.length] = new Option("Needham schools",'all=Needham');
mySelect.options[mySelect.options.length] = new Option("Quincy schools",'all=Quincy');
mySelect.options[mySelect.options.length] = new Option("Randolph schools",'all=Randolph');
mySelect.options[mySelect.options.length] = new Option("Sharon schools",'all=Sharon');
mySelect.options[mySelect.options.length] = new Option("Walpole schools",'all=Walpole');
mySelect.options[mySelect.options.length] = new Option("Wapole schools",'all=Wapole');
mySelect.options[mySelect.options.length] = new Option("Wellesley schools",'all=Wellesley');
mySelect.options[mySelect.options.length] = new Option("Westwood schools",'all=Westwood');
mySelect.options[mySelect.options.length] = new Option("Weymouth schools",'all=Weymouth');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Mansfield[Mansfield.length] = createMarker(new GPoint(-71.21716200,42.02970700),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Al-noor Academy High School",'Mansfield=' + Mansfield.length);
Braintree[Braintree.length] = createMarker(new GPoint(-71.00486100,42.22901700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Archbishop Williams High School",'Braintree=' + Braintree.length);
Brookline[Brookline.length] = createMarker(new GPoint(-71.12726800,42.34962600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bay Cove Academy",'Brookline=' + Brookline.length);
Brookline[Brookline.length] = createMarker(new GPoint(-71.12056100,42.34462400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Beacon High School",'Brookline=' + Brookline.length);
Brookline[Brookline.length] = createMarker(new GPoint(-71.11508200,42.34365500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Boston Trinity Academy",'Brookline=' + Brookline.length);
Braintree[Braintree.length] = createMarker(new GPoint(-71.00301500,42.22981400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cardinal Cushing Centers",'Braintree=' + Braintree.length);
Quincy[Quincy.length] = createMarker(new GPoint(-71.00879800,42.25606700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cerebral Palsy Of Massachusett",'Quincy=' + Quincy.length);
Sharon[Sharon.length] = createMarker(new GPoint(-71.17324600,42.13213200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chabad Day School Of Sharon",'Sharon=' + Sharon.length);
Canton[Canton.length] = createMarker(new GPoint(-71.12970000,42.17000000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Clark School East",'Canton=' + Canton.length);
Wellesley[Wellesley.length] = createMarker(new GPoint(-71.28781700,42.29194300),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dana Hall School",'Wellesley=' + Wellesley.length);
Brookline[Brookline.length] = createMarker(new GPoint(-71.13537400,42.30930300),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Dexter School",'Brookline=' + Brookline.length);
Weymouth[Weymouth.length] = createMarker(new GPoint(-70.95855300,42.18830000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("First Baptist Christian School",'Weymouth=' + Weymouth.length);
Milton[Milton.length] = createMarker(new GPoint(-71.05998200,42.25859800),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fontbonne Academy",'Milton=' + Milton.length);
East_Walpole[East_Walpole.length] = createMarker(new GPoint(-71.25350000,42.14480000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("The Home For Little Wanderers/longview Farm",'East_Walpole=' + East_Walpole.length);
Brookline[Brookline.length] = createMarker(new GPoint(-71.11200300,42.34749600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ivy Street School",'Brookline=' + Brookline.length);
Canton[Canton.length] = createMarker(new GPoint(-71.11281900,42.17800600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Judge Rotenberg Center",'Canton=' + Canton.length);
Canton[Canton.length] = createMarker(new GPoint(-71.11316200,42.17914700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Judge Rotenberg Ed Center Inc",'Canton=' + Canton.length);
Walpole[Walpole.length] = createMarker(new GPoint(-71.21520000,42.15440000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("League School",'Walpole=' + Walpole.length);
Wapole[Wapole.length] = createMarker(new GPoint(-71.21520000,42.15440000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("League School Of Greater Boston",'Wapole=' + Wapole.length);
Holbrook[Holbrook.length] = createMarker(new GPoint(-70.97848900,42.15372000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lighthouse Baptist Christian A",'Holbrook=' + Holbrook.length);
Brookline[Brookline.length] = createMarker(new GPoint(-71.13004200,42.33015500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Maimonides School",'Brookline=' + Brookline.length);
Braintree[Braintree.length] = createMarker(new GPoint(-70.97429400,42.18431400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Massasoit School Inc",'Braintree=' + Braintree.length);
Randolph[Randolph.length] = createMarker(new GPoint(-71.05054600,42.20139600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("May Center",'Randolph=' + Randolph.length);
Milton[Milton.length] = createMarker(new GPoint(-71.07054000,42.25648000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Milton Academy",'Milton=' + Milton.length);
Medfield[Medfield.length] = createMarker(new GPoint(-71.34338200,42.28438900),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Montrose School",'Medfield=' + Medfield.length);
Brookline[Brookline.length] = createMarker(new GPoint(-71.11042400,42.34878400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New England Hebrew Academy",'Brookline=' + Brookline.length);
Dedham[Dedham.length] = createMarker(new GPoint(-71.18403500,42.26201300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Noble And Greenough School",'Dedham=' + Dedham.length);
Brookline[Brookline.length] = createMarker(new GPoint(-71.13363200,42.31499500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Park School",'Brookline=' + Brookline.length);
Braintree[Braintree.length] = createMarker(new GPoint(-70.98955900,42.22454400),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Pilgrim Center",'Braintree=' + Braintree.length);
Needham[Needham.length] = createMarker(new GPoint(-71.20567800,42.26916000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("St. Sebastians School",'Needham=' + Needham.length);
Weymouth[Weymouth.length] = createMarker(new GPoint(-70.96511800,42.21528100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Shore Christian Academy",'Weymouth=' + Weymouth.length);
Brookline[Brookline.length] = createMarker(new GPoint(-71.13472000,42.30923600),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Southfield School",'Brookline=' + Brookline.length);
Braintree[Braintree.length] = createMarker(new GPoint(-71.00397400,42.20869700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Thayer Academy",'Braintree=' + Braintree.length);
Dedham[Dedham.length] = createMarker(new GPoint(-71.18461200,42.24486200),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ursuline Academy",'Dedham=' + Dedham.length);
Sharon[Sharon.length] = createMarker(new GPoint(-71.23563600,42.11800800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Victory Christian Academy",'Sharon=' + Sharon.length);
Quincy[Quincy.length] = createMarker(new GPoint(-71.00585500,42.25484000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("The Woodward School",'Quincy=' + Quincy.length);
Westwood[Westwood.length] = createMarker(new GPoint(-71.20022800,42.21542300),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Xaverian Brothers High School",'Westwood=' + Westwood.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,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/////2/' + showArray);
map.removeOverlays(Braintree);
map.removeOverlays(Brookline);
map.removeOverlays(Canton);
map.removeOverlays(Dedham);
map.removeOverlays(East_Walpole);
map.removeOverlays(Holbrook);
map.removeOverlays(Mansfield);
map.removeOverlays(Medfield);
map.removeOverlays(Milton);
map.removeOverlays(Needham);
map.removeOverlays(Quincy);
map.removeOverlays(Randolph);
map.removeOverlays(Sharon);
map.removeOverlays(Walpole);
map.removeOverlays(Wapole);
map.removeOverlays(Wellesley);
map.removeOverlays(Westwood);
map.removeOverlays(Weymouth);
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(Mansfield);map.removeOverlays(Braintree);
map.removeOverlays(Brookline);
map.removeOverlays(Canton);
map.removeOverlays(Dedham);
map.removeOverlays(East_Walpole);
map.removeOverlays(Holbrook);
map.removeOverlays(Mansfield);
map.removeOverlays(Medfield);
map.removeOverlays(Milton);
map.removeOverlays(Needham);
map.removeOverlays(Quincy);
map.removeOverlays(Randolph);
map.removeOverlays(Sharon);
map.removeOverlays(Walpole);
map.removeOverlays(Wapole);
map.removeOverlays(Wellesley);
map.removeOverlays(Westwood);
map.removeOverlays(Weymouth);
map.addOverlays(Braintree);
centerByArray(Braintree, false, false);
cntMarker += Braintree.length;
map.addOverlays(Brookline);
centerByArray(Brookline, false, false);
cntMarker += Brookline.length;
map.addOverlays(Canton);
centerByArray(Canton, false, false);
cntMarker += Canton.length;
map.addOverlays(Dedham);
centerByArray(Dedham, false, false);
cntMarker += Dedham.length;
map.addOverlays(East_Walpole);
centerByArray(East_Walpole, false, false);
cntMarker += East_Walpole.length;
map.addOverlays(Holbrook);
centerByArray(Holbrook, false, false);
cntMarker += Holbrook.length;
map.addOverlays(Mansfield);
centerByArray(Mansfield, false, false);
cntMarker += Mansfield.length;
map.addOverlays(Medfield);
centerByArray(Medfield, false, false);
cntMarker += Medfield.length;
map.addOverlays(Milton);
centerByArray(Milton, false, false);
cntMarker += Milton.length;
map.addOverlays(Needham);
centerByArray(Needham, false, false);
cntMarker += Needham.length;
map.addOverlays(Quincy);
centerByArray(Quincy, false, false);
cntMarker += Quincy.length;
map.addOverlays(Randolph);
centerByArray(Randolph, false, false);
cntMarker += Randolph.length;
map.addOverlays(Sharon);
centerByArray(Sharon, false, false);
cntMarker += Sharon.length;
map.addOverlays(Walpole);
centerByArray(Walpole, false, false);
cntMarker += Walpole.length;
map.addOverlays(Wapole);
centerByArray(Wapole, false, false);
cntMarker += Wapole.length;
map.addOverlays(Wellesley);
centerByArray(Wellesley, false, false);
cntMarker += Wellesley.length;
map.addOverlays(Westwood);
centerByArray(Westwood, false, false);
cntMarker += Westwood.length;
map.addOverlays(Weymouth);
centerByArray(Weymouth, false, false);
cntMarker += Weymouth.length;
centerByArray(Mansfield,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');
//window.open('/map.php?type=1&schools=&school_level=2&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;
}