function addMarkers(){
mySelect = document.getElementById('selection');
Boston = [];Ashburnham = [];Woburn = [];Norwood = [];West_Newton = [];Cambridge = [];Somerville = [];Westwood = [];Prides_Crossing = [];Sheffield = [];Northfield = [];South_Hadley = [];Williamstown = [];Andover = [];Chestnut_Hill = [];Great_Barrington = [];Northampton = [];Williamsburg = [];Lexington = [];Greenfield = [];Marion = [];Northfields = [];Winchendon = [];Worcester = [];mySelect.options[mySelect.options.length] = new Option("Andover Schools",'all=Andover');
mySelect.options[mySelect.options.length] = new Option("Ashburnham Schools",'all=Ashburnham');
mySelect.options[mySelect.options.length] = new Option("Boston Schools",'all=Boston');
mySelect.options[mySelect.options.length] = new Option("Cambridge Schools",'all=Cambridge');
mySelect.options[mySelect.options.length] = new Option("Chestnut Hill Schools",'all=Chestnut_Hill');
mySelect.options[mySelect.options.length] = new Option("Great Barrington Schools",'all=Great_Barrington');
mySelect.options[mySelect.options.length] = new Option("Greenfield Schools",'all=Greenfield');
mySelect.options[mySelect.options.length] = new Option("Lexington Schools",'all=Lexington');
mySelect.options[mySelect.options.length] = new Option("Marion Schools",'all=Marion');
mySelect.options[mySelect.options.length] = new Option("Northampton Schools",'all=Northampton');
mySelect.options[mySelect.options.length] = new Option("Northfield Schools",'all=Northfield');
mySelect.options[mySelect.options.length] = new Option("Northfields Schools",'all=Northfields');
mySelect.options[mySelect.options.length] = new Option("Norwood Schools",'all=Norwood');
mySelect.options[mySelect.options.length] = new Option("Prides Crossing Schools",'all=Prides_Crossing');
mySelect.options[mySelect.options.length] = new Option("Sheffield Schools",'all=Sheffield');
mySelect.options[mySelect.options.length] = new Option("Somerville Schools",'all=Somerville');
mySelect.options[mySelect.options.length] = new Option("South Hadley Schools",'all=South_Hadley');
mySelect.options[mySelect.options.length] = new Option("West Newton Schools",'all=West_Newton');
mySelect.options[mySelect.options.length] = new Option("Westwood Schools",'all=Westwood');
mySelect.options[mySelect.options.length] = new Option("Williamsburg Schools",'all=Williamsburg');
mySelect.options[mySelect.options.length] = new Option("Williamstown Schools",'all=Williamstown');
mySelect.options[mySelect.options.length] = new Option("Winchendon Schools",'all=Winchendon');
mySelect.options[mySelect.options.length] = new Option("Woburn Schools",'all=Woburn');
mySelect.options[mySelect.options.length] = new Option("Worcester Schools",'all=Worcester');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Boston[Boston.length] = createMarker(new GLatLng(42.35058600,-71.04938300),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("American Council For International Study (acis)",'Boston=' + Boston.length);
Boston[Boston.length] = createMarker(new GLatLng(42.34883800,-71.10231600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Boston University Academy Of Media Production",'Boston=' + Boston.length);
Ashburnham[Ashburnham.length] = createMarker(new GLatLng(42.63321720,-71.91397490),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cushing Academy",'Ashburnham=' + Ashburnham.length);
Woburn[Woburn.length] = createMarker(new GLatLng(42.48361400,-71.15804100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Emagination Computer Camps",'Woburn=' + Woburn.length);
Norwood[Norwood.length] = createMarker(new GLatLng(42.19824030,-71.19845340),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Explo - Exploration School, Inc.",'Norwood=' + Norwood.length);
Norwood[Norwood.length] = createMarker(new GLatLng(42.19824030,-71.19845340),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Exploration School, Inc.",'Norwood=' + Norwood.length);
West_Newton[West_Newton.length] = createMarker(new GLatLng(42.35763100,-71.22161600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fessenden School",'West_Newton=' + West_Newton.length);
Cambridge[Cambridge.length] = createMarker(new GLatLng(42.37427360,-71.12176520),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Harvard University",'Cambridge=' + Cambridge.length);
Somerville[Somerville.length] = createMarker(new GLatLng(42.39535200,-71.10362700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Killooleet",'Somerville=' + Somerville.length);
Westwood[Westwood.length] = createMarker(new GLatLng(42.20986000,-71.23876000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kippewa For Girls",'Westwood=' + Westwood.length);
Prides_Crossing[Prides_Crossing.length] = createMarker(new GLatLng(42.55957800,-70.82478800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Landmark School",'Prides_Crossing=' + Prides_Crossing.length);
Sheffield[Sheffield.length] = createMarker(new GLatLng(42.12635700,-73.36089000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Landmark Volunteers, Inc.",'Sheffield=' + Sheffield.length);
Northfield[Northfield.length] = createMarker(new GLatLng(42.64958550,-72.45357310),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Linden Hill School",'Northfield=' + Northfield.length);
Boston[Boston.length] = createMarker(new GLatLng(42.33609990,-71.09991590),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Massachusetts College Of Art",'Boston=' + Boston.length);
South_Hadley[South_Hadley.length] = createMarker(new GLatLng(42.25625140,-72.57645350),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mount Holyoke College",'South_Hadley=' + South_Hadley.length);
South_Hadley[South_Hadley.length] = createMarker(new GLatLng(42.25672500,-72.57451100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mount Holyoke College",'South_Hadley=' + South_Hadley.length);
Northfield[Northfield.length] = createMarker(new GLatLng(42.70713990,-72.44931380),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northfield Mount Hermon School",'Northfield=' + Northfield.length);
Williamstown[Williamstown.length] = createMarker(new GLatLng(42.71124400,-73.19949300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Overland Travel, Inc.",'Williamstown=' + Williamstown.length);
Andover[Andover.length] = createMarker(new GLatLng(42.64715510,-71.13416110),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Phillips Academy ( Andover )",'Andover=' + Andover.length);
Chestnut_Hill[Chestnut_Hill.length] = createMarker(new GLatLng(42.32145500,-71.15460300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pine Manor College",'Chestnut_Hill=' + Chestnut_Hill.length);
Great_Barrington[Great_Barrington.length] = createMarker(new GLatLng(42.20736860,-73.38453890),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Simon's Rock College Of Bard",'Great_Barrington=' + Great_Barrington.length);
Northampton[Northampton.length] = createMarker(new GLatLng(42.31783200,-72.63879900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Smith College",'Northampton=' + Northampton.length);
Williamsburg[Williamsburg.length] = createMarker(new GLatLng(42.40752300,-72.76121800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Snow Farm: New England Craft Program",'Williamsburg=' + Williamsburg.length);
Lexington[Lexington.length] = createMarker(new GLatLng(42.45269950,-71.24062590),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Stagedoor Manor Performing Arts Training Center/theatre And Dance Camp",'Lexington=' + Lexington.length);
Greenfield[Greenfield.length] = createMarker(new GLatLng(42.61791510,-72.57917640),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Stoneleigh-burnham School",'Greenfield=' + Greenfield.length);
Marion[Marion.length] = createMarker(new GLatLng(41.70660200,-70.76736700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tabor Academy",'Marion=' + Marion.length);
Northfields[Northfields.length] = createMarker(new GLatLng(42.69196800,-72.45733300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Test Summer 1 School",'Northfields=' + Northfields.length);
Winchendon[Winchendon.length] = createMarker(new GLatLng(42.67731700,-72.03845000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Winchendon School",'Winchendon=' + Winchendon.length);
Worcester[Worcester.length] = createMarker(new GLatLng(42.27416500,-71.80666500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Worcester Polytechnic Institute",'Worcester=' + Worcester.length);
Worcester[Worcester.length] = createMarker(new GLatLng(42.27416500,-71.80666500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Worcester Polytechnic Institute",'Worcester=' + Worcester.length);
map.removeOverlays(Andover);
map.removeOverlays(Ashburnham);
map.removeOverlays(Boston);
map.removeOverlays(Cambridge);
map.removeOverlays(Chestnut_Hill);
map.removeOverlays(Great_Barrington);
map.removeOverlays(Greenfield);
map.removeOverlays(Lexington);
map.removeOverlays(Marion);
map.removeOverlays(Northampton);
map.removeOverlays(Northfield);
map.removeOverlays(Northfields);
map.removeOverlays(Norwood);
map.removeOverlays(Prides_Crossing);
map.removeOverlays(Sheffield);
map.removeOverlays(Somerville);
map.removeOverlays(South_Hadley);
map.removeOverlays(West_Newton);
map.removeOverlays(Westwood);
map.removeOverlays(Williamsburg);
map.removeOverlays(Williamstown);
map.removeOverlays(Winchendon);
map.removeOverlays(Woburn);
map.removeOverlays(Worcester);
setTimeout(function(){map.addOverlays(Andover)},1000);
setTimeout(function(){map.addOverlays(Ashburnham)},1000);
setTimeout(function(){map.addOverlays(Boston)},1000);
setTimeout(function(){map.addOverlays(Cambridge)},1000);
setTimeout(function(){map.addOverlays(Chestnut_Hill)},1000);
setTimeout(function(){map.addOverlays(Great_Barrington)},1000);
setTimeout(function(){map.addOverlays(Greenfield)},1000);
setTimeout(function(){map.addOverlays(Lexington)},1000);
setTimeout(function(){map.addOverlays(Marion)},1000);
setTimeout(function(){map.addOverlays(Northampton)},1000);
setTimeout(function(){map.addOverlays(Northfield)},1000);
setTimeout(function(){map.addOverlays(Northfields)},1000);
setTimeout(function(){map.addOverlays(Norwood)},1000);
setTimeout(function(){map.addOverlays(Prides_Crossing)},1000);
setTimeout(function(){map.addOverlays(Sheffield)},1000);
setTimeout(function(){map.addOverlays(Somerville)},1000);
setTimeout(function(){map.addOverlays(South_Hadley)},1000);
setTimeout(function(){map.addOverlays(West_Newton)},1000);
setTimeout(function(){map.addOverlays(Westwood)},1000);
setTimeout(function(){map.addOverlays(Williamsburg)},1000);
setTimeout(function(){map.addOverlays(Williamstown)},1000);
setTimeout(function(){map.addOverlays(Winchendon)},1000);
setTimeout(function(){map.addOverlays(Woburn)},1000);
setTimeout(function(){map.addOverlays(Worcester)},1000);
maxLng = -70.76736700;
maxLat = 42.71124400;
minLng = -73.38453890;
minLat = 41.70660200;
reCenterMap();
}
// End addStateMarkers JavaScript Function
function openAll() {
if (map) {
selectChange("all");
} else {
setTimeout("openAll()",200);
}
}
// 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].point.x;
var markLat = myArray[i].point.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){
//alert(myArray[0].point.x);
maxLng = myArray[0].point.x;
maxLat = myArray[0].point.y;
minLng = myArray[0].point.x;
minLat = myArray[0].point.y;
}
// Recenter map based on global max/mins
function reCenterMap(){
//alert('#' + minLat + '#' + minLng + '#' + maxLat + '#' + maxLng);
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);
if(minLat == maxLat) zoom = 9;
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////all');
map.removeOverlays(Andover);
map.removeOverlays(Ashburnham);
map.removeOverlays(Boston);
map.removeOverlays(Cambridge);
map.removeOverlays(Chestnut_Hill);
map.removeOverlays(Great_Barrington);
map.removeOverlays(Greenfield);
map.removeOverlays(Lexington);
map.removeOverlays(Marion);
map.removeOverlays(Northampton);
map.removeOverlays(Northfield);
map.removeOverlays(Northfields);
map.removeOverlays(Norwood);
map.removeOverlays(Prides_Crossing);
map.removeOverlays(Sheffield);
map.removeOverlays(Somerville);
map.removeOverlays(South_Hadley);
map.removeOverlays(West_Newton);
map.removeOverlays(Westwood);
map.removeOverlays(Williamsburg);
map.removeOverlays(Williamstown);
map.removeOverlays(Winchendon);
map.removeOverlays(Woburn);
map.removeOverlays(Worcester);
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(Andover);
map.removeOverlays(Ashburnham);
map.removeOverlays(Boston);
map.removeOverlays(Cambridge);
map.removeOverlays(Chestnut_Hill);
map.removeOverlays(Great_Barrington);
map.removeOverlays(Greenfield);
map.removeOverlays(Lexington);
map.removeOverlays(Marion);
map.removeOverlays(Northampton);
map.removeOverlays(Northfield);
map.removeOverlays(Northfields);
map.removeOverlays(Norwood);
map.removeOverlays(Prides_Crossing);
map.removeOverlays(Sheffield);
map.removeOverlays(Somerville);
map.removeOverlays(South_Hadley);
map.removeOverlays(West_Newton);
map.removeOverlays(Westwood);
map.removeOverlays(Williamsburg);
map.removeOverlays(Williamstown);
map.removeOverlays(Winchendon);
map.removeOverlays(Woburn);
map.removeOverlays(Worcester);
map.addOverlays(Andover);
centerByArray(Andover, false, false);
cntMarker += Andover.length;
map.addOverlays(Ashburnham);
centerByArray(Ashburnham, false, false);
cntMarker += Ashburnham.length;
map.addOverlays(Boston);
centerByArray(Boston, false, false);
cntMarker += Boston.length;
map.addOverlays(Cambridge);
centerByArray(Cambridge, false, false);
cntMarker += Cambridge.length;
map.addOverlays(Chestnut_Hill);
centerByArray(Chestnut_Hill, false, false);
cntMarker += Chestnut_Hill.length;
map.addOverlays(Great_Barrington);
centerByArray(Great_Barrington, false, false);
cntMarker += Great_Barrington.length;
map.addOverlays(Greenfield);
centerByArray(Greenfield, false, false);
cntMarker += Greenfield.length;
map.addOverlays(Lexington);
centerByArray(Lexington, false, false);
cntMarker += Lexington.length;
map.addOverlays(Marion);
centerByArray(Marion, false, false);
cntMarker += Marion.length;
map.addOverlays(Northampton);
centerByArray(Northampton, false, false);
cntMarker += Northampton.length;
map.addOverlays(Northfield);
centerByArray(Northfield, false, false);
cntMarker += Northfield.length;
map.addOverlays(Northfields);
centerByArray(Northfields, false, false);
cntMarker += Northfields.length;
map.addOverlays(Norwood);
centerByArray(Norwood, false, false);
cntMarker += Norwood.length;
map.addOverlays(Prides_Crossing);
centerByArray(Prides_Crossing, false, false);
cntMarker += Prides_Crossing.length;
map.addOverlays(Sheffield);
centerByArray(Sheffield, false, false);
cntMarker += Sheffield.length;
map.addOverlays(Somerville);
centerByArray(Somerville, false, false);
cntMarker += Somerville.length;
map.addOverlays(South_Hadley);
centerByArray(South_Hadley, false, false);
cntMarker += South_Hadley.length;
map.addOverlays(West_Newton);
centerByArray(West_Newton, false, false);
cntMarker += West_Newton.length;
map.addOverlays(Westwood);
centerByArray(Westwood, false, false);
cntMarker += Westwood.length;
map.addOverlays(Williamsburg);
centerByArray(Williamsburg, false, false);
cntMarker += Williamsburg.length;
map.addOverlays(Williamstown);
centerByArray(Williamstown, false, false);
cntMarker += Williamstown.length;
map.addOverlays(Winchendon);
centerByArray(Winchendon, false, false);
cntMarker += Winchendon.length;
map.addOverlays(Woburn);
centerByArray(Woburn, false, false);
cntMarker += Woburn.length;
map.addOverlays(Worcester);
centerByArray(Worcester, false, false);
cntMarker += Worcester.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('nearby_schools.php') == -1)
window.open(location.href + '/map/all');
//else
//window.open('/search////all');
}
}
function createMarker(point, label, icon){
var marker = new GMarker(point, icon);
var html = label;
GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); });
return marker;
}