function addMarkers(){
mySelect = document.getElementById('selection');
Boston = [];West_Roxbury = [];Jamaica_Plain = [];Charlestown = [];School_location_is_in_Boston = [];Brighton = [];Allston = [];Dorchester = [];Hyde_Park = [];Roslindale = [];East_Boston = [];mySelect.options[mySelect.options.length] = new Option("Allston schools",'all=Allston');
mySelect.options[mySelect.options.length] = new Option("Boston schools",'all=Boston');
mySelect.options[mySelect.options.length] = new Option("Brighton schools",'all=Brighton');
mySelect.options[mySelect.options.length] = new Option("Charlestown schools",'all=Charlestown');
mySelect.options[mySelect.options.length] = new Option("Dorchester schools",'all=Dorchester');
mySelect.options[mySelect.options.length] = new Option("East Boston schools",'all=East_Boston');
mySelect.options[mySelect.options.length] = new Option("Hyde Park schools",'all=Hyde_Park');
mySelect.options[mySelect.options.length] = new Option("Jamaica Plain schools",'all=Jamaica_Plain');
mySelect.options[mySelect.options.length] = new Option("Roslindale schools",'all=Roslindale');
mySelect.options[mySelect.options.length] = new Option("School location is in Boston schools",'all=School_location_is_in_Boston');
mySelect.options[mySelect.options.length] = new Option("West Roxbury schools",'all=West_Roxbury');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Boston[Boston.length] = createMarker(new GPoint(-71.04681700,42.31467600),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Boston College High School",'Boston=' + Boston.length);
Boston[Boston.length] = createMarker(new GPoint(-71.12918900,42.25942300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Boston Trinity Academy",'Boston=' + Boston.length);
Boston[Boston.length] = createMarker(new GPoint(-71.10955600,42.35057200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Boston University Academy",'Boston=' + Boston.length);
Boston[Boston.length] = createMarker(new GPoint(-71.13060300,42.30934800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("British School Of Boston",'Boston=' + Boston.length);
Boston[Boston.length] = createMarker(new GPoint(-71.06823000,42.34083800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cathedral High School",'Boston=' + Boston.length);
West_Roxbury[West_Roxbury.length] = createMarker(new GPoint(-71.16674200,42.27787600),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Catholic Memorial",'West_Roxbury=' + West_Roxbury.length);
Boston[Boston.length] = createMarker(new GPoint(-71.07793300,42.35228600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Commonwealth School",'Boston=' + Boston.length);
Jamaica_Plain[Jamaica_Plain.length] = createMarker(new GPoint(-71.10694800,42.32358600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Compass Inc",'Jamaica_Plain=' + Jamaica_Plain.length);
Charlestown[Charlestown.length] = createMarker(new GPoint(-71.06509800,42.37813000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holden School",'Charlestown=' + Charlestown.length);
Jamaica_Plain[Jamaica_Plain.length] = createMarker(new GPoint(-71.12624300,42.30200200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Italian Home For Children",'Jamaica_Plain=' + Jamaica_Plain.length);
Boston[Boston.length] = createMarker(new GPoint(-71.15350000,42.34980000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kennedy Day School Program",'Boston=' + Boston.length);
Jamaica_Plain[Jamaica_Plain.length] = createMarker(new GPoint(-71.11270000,42.31050000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Language And Cognitive Develop",'Jamaica_Plain=' + Jamaica_Plain.length);
Boston[Boston.length] = createMarker(new GPoint(-71.10971400,42.33121600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Manville School",'Boston=' + Boston.length);
School_location_is_in_Boston[School_location_is_in_Boston.length] = createMarker(new GPoint(-71.07050000,42.33860000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mary McLeod Bethune Institute",'School_location_is_in_Boston=' + School_location_is_in_Boston.length);
Brighton[Brighton.length] = createMarker(new GPoint(-71.15122900,42.35125300),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mesivta High School Of Greater Boston",'Brighton=' + Brighton.length);
Allston[Allston.length] = createMarker(new GPoint(-71.14327400,42.35168800),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mount Saint Joseph Academy",'Allston=' + Allston.length);
Dorchester[Dorchester.length] = createMarker(new GPoint(-71.06082100,42.32172900),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Msgr. Ryan Memorial High School",'Dorchester=' + Dorchester.length);
Hyde_Park[Hyde_Park.length] = createMarker(new GPoint(-71.12560000,42.25310000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Beginnings Academy",'Hyde_Park=' + Hyde_Park.length);
Boston[Boston.length] = createMarker(new GPoint(-71.08226800,42.35208900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Newman School",'Boston=' + Boston.length);
Dorchester[Dorchester.length] = createMarker(new GPoint(-71.05890000,42.31660000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Notre Dame Montessori School",'Dorchester=' + Dorchester.length);
West_Roxbury[West_Roxbury.length] = createMarker(new GPoint(-71.15549100,42.27659600),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Roxbury Latin School",'West_Roxbury=' + West_Roxbury.length);
Roslindale[Roslindale.length] = createMarker(new GPoint(-71.12211800,42.28175000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("St. Clare High School",'Roslindale=' + Roslindale.length);
East_Boston[East_Boston.length] = createMarker(new GPoint(-71.01609300,42.38286400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Savio Preparatory High School",'East_Boston=' + East_Boston.length);
Charlestown[Charlestown.length] = createMarker(new GPoint(-71.05174200,42.37400300),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Seaport Campus",'Charlestown=' + Charlestown.length);
Boston[Boston.length] = createMarker(new GPoint(-71.10685800,42.34094200),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("The Winsor School",'Boston=' + Boston.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(Allston);
map.removeOverlays(Boston);
map.removeOverlays(Brighton);
map.removeOverlays(Charlestown);
map.removeOverlays(Dorchester);
map.removeOverlays(East_Boston);
map.removeOverlays(Hyde_Park);
map.removeOverlays(Jamaica_Plain);
map.removeOverlays(Roslindale);
map.removeOverlays(School_location_is_in_Boston);
map.removeOverlays(West_Roxbury);
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(Boston);map.removeOverlays(Allston);
map.removeOverlays(Boston);
map.removeOverlays(Brighton);
map.removeOverlays(Charlestown);
map.removeOverlays(Dorchester);
map.removeOverlays(East_Boston);
map.removeOverlays(Hyde_Park);
map.removeOverlays(Jamaica_Plain);
map.removeOverlays(Roslindale);
map.removeOverlays(School_location_is_in_Boston);
map.removeOverlays(West_Roxbury);
map.addOverlays(Allston);
centerByArray(Allston, false, false);
cntMarker += Allston.length;
map.addOverlays(Boston);
centerByArray(Boston, false, false);
cntMarker += Boston.length;
map.addOverlays(Brighton);
centerByArray(Brighton, false, false);
cntMarker += Brighton.length;
map.addOverlays(Charlestown);
centerByArray(Charlestown, false, false);
cntMarker += Charlestown.length;
map.addOverlays(Dorchester);
centerByArray(Dorchester, false, false);
cntMarker += Dorchester.length;
map.addOverlays(East_Boston);
centerByArray(East_Boston, false, false);
cntMarker += East_Boston.length;
map.addOverlays(Hyde_Park);
centerByArray(Hyde_Park, false, false);
cntMarker += Hyde_Park.length;
map.addOverlays(Jamaica_Plain);
centerByArray(Jamaica_Plain, false, false);
cntMarker += Jamaica_Plain.length;
map.addOverlays(Roslindale);
centerByArray(Roslindale, false, false);
cntMarker += Roslindale.length;
map.addOverlays(School_location_is_in_Boston);
centerByArray(School_location_is_in_Boston, false, false);
cntMarker += School_location_is_in_Boston.length;
map.addOverlays(West_Roxbury);
centerByArray(West_Roxbury, false, false);
cntMarker += West_Roxbury.length;
centerByArray(Boston,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;
}