function addMarkers(){
mySelect = document.getElementById('selection');
Duxbury = [];Bedford = [];Canton = [];Marblehead = [];Dover = [];East_Boston = [];Foxboro = [];Woods_Hole = [];Auburn = [];Westport = [];Natick = [];Newburyport = [];Springfield = [];Sandwich = [];West_Bridgewater = [];Manchester_By_The_Sea = [];Milton = [];Sturbridge = [];Vineyard_Haven = [];Westwood = [];Woburn = [];Millis = [];mySelect.options[mySelect.options.length] = new Option("Auburn schools",'all=Auburn');
mySelect.options[mySelect.options.length] = new Option("Bedford schools",'all=Bedford');
mySelect.options[mySelect.options.length] = new Option("Canton schools",'all=Canton');
mySelect.options[mySelect.options.length] = new Option("Dover schools",'all=Dover');
mySelect.options[mySelect.options.length] = new Option("Duxbury schools",'all=Duxbury');
mySelect.options[mySelect.options.length] = new Option("East Boston schools",'all=East_Boston');
mySelect.options[mySelect.options.length] = new Option("Foxboro schools",'all=Foxboro');
mySelect.options[mySelect.options.length] = new Option("Manchester By The Sea schools",'all=Manchester_By_The_Sea');
mySelect.options[mySelect.options.length] = new Option("Marblehead schools",'all=Marblehead');
mySelect.options[mySelect.options.length] = new Option("Millis schools",'all=Millis');
mySelect.options[mySelect.options.length] = new Option("Milton schools",'all=Milton');
mySelect.options[mySelect.options.length] = new Option("Natick schools",'all=Natick');
mySelect.options[mySelect.options.length] = new Option("Newburyport schools",'all=Newburyport');
mySelect.options[mySelect.options.length] = new Option("Sandwich schools",'all=Sandwich');
mySelect.options[mySelect.options.length] = new Option("Springfield schools",'all=Springfield');
mySelect.options[mySelect.options.length] = new Option("Sturbridge schools",'all=Sturbridge');
mySelect.options[mySelect.options.length] = new Option("Vineyard Haven schools",'all=Vineyard_Haven');
mySelect.options[mySelect.options.length] = new Option("West Bridgewater schools",'all=West_Bridgewater');
mySelect.options[mySelect.options.length] = new Option("Westport schools",'all=Westport');
mySelect.options[mySelect.options.length] = new Option("Westwood schools",'all=Westwood');
mySelect.options[mySelect.options.length] = new Option("Woburn schools",'all=Woburn');
mySelect.options[mySelect.options.length] = new Option("Woods Hole schools",'all=Woods_Hole');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Duxbury[Duxbury.length] = createMarker(new GPoint(-70.71789500,42.00734900),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bay Farm Montessori Academy",'Duxbury=' + Duxbury.length);
Bedford[Bedford.length] = createMarker(new GPoint(-71.29444300,42.48778700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bedford Montessori School",'Bedford=' + Bedford.length);
Canton[Canton.length] = createMarker(new GPoint(-71.11449500,42.18273300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Blue Hill Montessori School",'Canton=' + Canton.length);
Marblehead[Marblehead.length] = createMarker(new GPoint(-70.84661000,42.51337700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Childrens Workshop Montessori",'Marblehead=' + Marblehead.length);
Dover[Dover.length] = createMarker(new GPoint(-71.32602900,42.24562300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Dover Montessori School",'Dover=' + Dover.length);
East_Boston[East_Boston.length] = createMarker(new GPoint(-71.00900200,42.38691400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("East Boston Montessori School",'East_Boston=' + East_Boston.length);
Foxboro[Foxboro.length] = createMarker(new GPoint(-71.25341800,42.06659800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kings Wood Montessori School",'Foxboro=' + Foxboro.length);
Woods_Hole[Woods_Hole.length] = createMarker(new GPoint(-70.66744300,41.52770000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Little Harbor Montessori School",'Woods_Hole=' + Woods_Hole.length);
Auburn[Auburn.length] = createMarker(new GPoint(-71.84634700,42.20478600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Childrens House Of Auburn",'Auburn=' + Auburn.length);
Westport[Westport.length] = createMarker(new GPoint(-71.08540000,41.61610000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School Of Angel",'Westport=' + Westport.length);
Natick[Natick.length] = createMarker(new GPoint(-71.31636200,42.27284900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Natick Montessori School",'Natick=' + Natick.length);
Newburyport[Newburyport.length] = createMarker(new GPoint(-70.87103500,42.81039700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Newburyport Montessori School",'Newburyport=' + Newburyport.length);
Springfield[Springfield.length] = createMarker(new GPoint(-72.49729800,42.10572400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pioneer Valley Montessori School",'Springfield=' + Springfield.length);
Sandwich[Sandwich.length] = createMarker(new GPoint(-70.48488100,41.70440800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sandwich Montessori School",'Sandwich=' + Sandwich.length);
West_Bridgewater[West_Bridgewater.length] = createMarker(new GPoint(-71.05281700,42.02379300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Small World Montessori",'West_Bridgewater=' + West_Bridgewater.length);
Manchester_By_The_Sea[Manchester_By_The_Sea.length] = createMarker(new GPoint(-70.77062200,42.57968200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tara Montessori School",'Manchester_By_The_Sea=' + Manchester_By_The_Sea.length);
Milton[Milton.length] = createMarker(new GPoint(-71.11849900,42.22293000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Thacher Montessori School",'Milton=' + Milton.length);
Sturbridge[Sturbridge.length] = createMarker(new GPoint(-72.07069500,42.08189900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Treetops Montessori School",'Sturbridge=' + Sturbridge.length);
Vineyard_Haven[Vineyard_Haven.length] = createMarker(new GPoint(-70.60680000,41.43790000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Vineyard Montessori School",'Vineyard_Haven=' + Vineyard_Haven.length);
Westwood[Westwood.length] = createMarker(new GPoint(-71.22288500,42.22305300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Westwood Montessori School",'Westwood=' + Westwood.length);
Woburn[Woburn.length] = createMarker(new GPoint(-71.15130700,42.47596400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Woburn Montessori School",'Woburn=' + Woburn.length);
Millis[Millis.length] = createMarker(new GPoint(-71.36623300,42.14397500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Woodside Montessori Academy",'Millis=' + Millis.length);
map.removeOverlays(Auburn);
map.removeOverlays(Bedford);
map.removeOverlays(Canton);
map.removeOverlays(Dover);
map.removeOverlays(Duxbury);
map.removeOverlays(East_Boston);
map.removeOverlays(Foxboro);
map.removeOverlays(Manchester_By_The_Sea);
map.removeOverlays(Marblehead);
map.removeOverlays(Millis);
map.removeOverlays(Milton);
map.removeOverlays(Natick);
map.removeOverlays(Newburyport);
map.removeOverlays(Sandwich);
map.removeOverlays(Springfield);
map.removeOverlays(Sturbridge);
map.removeOverlays(Vineyard_Haven);
map.removeOverlays(West_Bridgewater);
map.removeOverlays(Westport);
map.removeOverlays(Westwood);
map.removeOverlays(Woburn);
map.removeOverlays(Woods_Hole);
setTimeout(function(){map.addOverlays(Auburn)},1000);
setTimeout(function(){map.addOverlays(Bedford)},1000);
setTimeout(function(){map.addOverlays(Canton)},1000);
setTimeout(function(){map.addOverlays(Dover)},1000);
setTimeout(function(){map.addOverlays(Duxbury)},1000);
setTimeout(function(){map.addOverlays(East_Boston)},1000);
setTimeout(function(){map.addOverlays(Foxboro)},1000);
setTimeout(function(){map.addOverlays(Manchester_By_The_Sea)},1000);
setTimeout(function(){map.addOverlays(Marblehead)},1000);
setTimeout(function(){map.addOverlays(Millis)},1000);
setTimeout(function(){map.addOverlays(Milton)},1000);
setTimeout(function(){map.addOverlays(Natick)},1000);
setTimeout(function(){map.addOverlays(Newburyport)},1000);
setTimeout(function(){map.addOverlays(Sandwich)},1000);
setTimeout(function(){map.addOverlays(Springfield)},1000);
setTimeout(function(){map.addOverlays(Sturbridge)},1000);
setTimeout(function(){map.addOverlays(Vineyard_Haven)},1000);
setTimeout(function(){map.addOverlays(West_Bridgewater)},1000);
setTimeout(function(){map.addOverlays(Westport)},1000);
setTimeout(function(){map.addOverlays(Westwood)},1000);
setTimeout(function(){map.addOverlays(Woburn)},1000);
setTimeout(function(){map.addOverlays(Woods_Hole)},1000);
maxLng = -70.48488100;
maxLat = 42.81039700;
minLng = -72.49729800;
minLat = 41.43790000;
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(Auburn);
map.removeOverlays(Bedford);
map.removeOverlays(Canton);
map.removeOverlays(Dover);
map.removeOverlays(Duxbury);
map.removeOverlays(East_Boston);
map.removeOverlays(Foxboro);
map.removeOverlays(Manchester_By_The_Sea);
map.removeOverlays(Marblehead);
map.removeOverlays(Millis);
map.removeOverlays(Milton);
map.removeOverlays(Natick);
map.removeOverlays(Newburyport);
map.removeOverlays(Sandwich);
map.removeOverlays(Springfield);
map.removeOverlays(Sturbridge);
map.removeOverlays(Vineyard_Haven);
map.removeOverlays(West_Bridgewater);
map.removeOverlays(Westport);
map.removeOverlays(Westwood);
map.removeOverlays(Woburn);
map.removeOverlays(Woods_Hole);
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(Duxbury);map.removeOverlays(Auburn);
map.removeOverlays(Bedford);
map.removeOverlays(Canton);
map.removeOverlays(Dover);
map.removeOverlays(Duxbury);
map.removeOverlays(East_Boston);
map.removeOverlays(Foxboro);
map.removeOverlays(Manchester_By_The_Sea);
map.removeOverlays(Marblehead);
map.removeOverlays(Millis);
map.removeOverlays(Milton);
map.removeOverlays(Natick);
map.removeOverlays(Newburyport);
map.removeOverlays(Sandwich);
map.removeOverlays(Springfield);
map.removeOverlays(Sturbridge);
map.removeOverlays(Vineyard_Haven);
map.removeOverlays(West_Bridgewater);
map.removeOverlays(Westport);
map.removeOverlays(Westwood);
map.removeOverlays(Woburn);
map.removeOverlays(Woods_Hole);
map.addOverlays(Auburn);
centerByArray(Auburn, false, false);
cntMarker += Auburn.length;
map.addOverlays(Bedford);
centerByArray(Bedford, false, false);
cntMarker += Bedford.length;
map.addOverlays(Canton);
centerByArray(Canton, false, false);
cntMarker += Canton.length;
map.addOverlays(Dover);
centerByArray(Dover, false, false);
cntMarker += Dover.length;
map.addOverlays(Duxbury);
centerByArray(Duxbury, false, false);
cntMarker += Duxbury.length;
map.addOverlays(East_Boston);
centerByArray(East_Boston, false, false);
cntMarker += East_Boston.length;
map.addOverlays(Foxboro);
centerByArray(Foxboro, false, false);
cntMarker += Foxboro.length;
map.addOverlays(Manchester_By_The_Sea);
centerByArray(Manchester_By_The_Sea, false, false);
cntMarker += Manchester_By_The_Sea.length;
map.addOverlays(Marblehead);
centerByArray(Marblehead, false, false);
cntMarker += Marblehead.length;
map.addOverlays(Millis);
centerByArray(Millis, false, false);
cntMarker += Millis.length;
map.addOverlays(Milton);
centerByArray(Milton, false, false);
cntMarker += Milton.length;
map.addOverlays(Natick);
centerByArray(Natick, false, false);
cntMarker += Natick.length;
map.addOverlays(Newburyport);
centerByArray(Newburyport, false, false);
cntMarker += Newburyport.length;
map.addOverlays(Sandwich);
centerByArray(Sandwich, false, false);
cntMarker += Sandwich.length;
map.addOverlays(Springfield);
centerByArray(Springfield, false, false);
cntMarker += Springfield.length;
map.addOverlays(Sturbridge);
centerByArray(Sturbridge, false, false);
cntMarker += Sturbridge.length;
map.addOverlays(Vineyard_Haven);
centerByArray(Vineyard_Haven, false, false);
cntMarker += Vineyard_Haven.length;
map.addOverlays(West_Bridgewater);
centerByArray(West_Bridgewater, false, false);
cntMarker += West_Bridgewater.length;
map.addOverlays(Westport);
centerByArray(Westport, false, false);
cntMarker += Westport.length;
map.addOverlays(Westwood);
centerByArray(Westwood, false, false);
cntMarker += Westwood.length;
map.addOverlays(Woburn);
centerByArray(Woburn, false, false);
cntMarker += Woburn.length;
map.addOverlays(Woods_Hole);
centerByArray(Woods_Hole, false, false);
cntMarker += Woods_Hole.length;
centerByArray(Duxbury,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///13168,12909,13460,13008,12906,31354,13102,13453,13570,13533,13456,35077,13199,34769,13249,13504,13517,13290,13173,35106,13531,34770,/all');
//window.open('/map.php?type=2&schools=13168,12909,13460,13008,12906,31354,13102,13453,13570,13533,13456,35077,13199,34769,13249,13504,13517,13290,13173,35106,13531,34770,&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;
}