function addMarkers(){
mySelect = document.getElementById('selection');
Plymouth = [];Duxbury = [];Brockton = [];Hanover = [];West_Bridgewater = [];West__Bridgewa = [];Marion = [];Hingham = [];Rockland = [];Whitman = [];Scituate = [];Lakeville = [];Carver = [];Norwell = [];W_Bridgewater = [];Abington = [];Kingston = [];Bridgewater = [];Marshfield = [];mySelect.options[mySelect.options.length] = new Option("Abington schools",'all=Abington');
mySelect.options[mySelect.options.length] = new Option("Bridgewater schools",'all=Bridgewater');
mySelect.options[mySelect.options.length] = new Option("Brockton schools",'all=Brockton');
mySelect.options[mySelect.options.length] = new Option("Carver schools",'all=Carver');
mySelect.options[mySelect.options.length] = new Option("Duxbury schools",'all=Duxbury');
mySelect.options[mySelect.options.length] = new Option("Hanover schools",'all=Hanover');
mySelect.options[mySelect.options.length] = new Option("Hingham schools",'all=Hingham');
mySelect.options[mySelect.options.length] = new Option("Kingston schools",'all=Kingston');
mySelect.options[mySelect.options.length] = new Option("Lakeville schools",'all=Lakeville');
mySelect.options[mySelect.options.length] = new Option("Marion schools",'all=Marion');
mySelect.options[mySelect.options.length] = new Option("Marshfield schools",'all=Marshfield');
mySelect.options[mySelect.options.length] = new Option("Norwell schools",'all=Norwell');
mySelect.options[mySelect.options.length] = new Option("Plymouth schools",'all=Plymouth');
mySelect.options[mySelect.options.length] = new Option("Rockland schools",'all=Rockland');
mySelect.options[mySelect.options.length] = new Option("Scituate schools",'all=Scituate');
mySelect.options[mySelect.options.length] = new Option("W Bridgewater schools",'all=W_Bridgewater');
mySelect.options[mySelect.options.length] = new Option("West Bridgewater schools",'all=West_Bridgewater');
mySelect.options[mySelect.options.length] = new Option("West Bridgewa schools",'all=West__Bridgewa');
mySelect.options[mySelect.options.length] = new Option("Whitman schools",'all=Whitman');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Plymouth[Plymouth.length] = createMarker(new GPoint(-70.58658800,41.85841600),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("The Baird Center",'Plymouth=' + Plymouth.length);
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);
Brockton[Brockton.length] = createMarker(new GPoint(-71.01376800,42.05809700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Brockton Christian School",'Brockton=' + Brockton.length);
Brockton[Brockton.length] = createMarker(new GPoint(-71.00726900,42.08069700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Brockton Sda Elementary School",'Brockton=' + Brockton.length);
Hanover[Hanover.length] = createMarker(new GPoint(-70.81952600,42.11668300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cardinal Cushing Centers, Inc.",'Hanover=' + Hanover.length);
West_Bridgewater[West_Bridgewater.length] = createMarker(new GPoint(-71.03173400,42.01635300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Children's World Learning Center",'West_Bridgewater=' + West_Bridgewater.length);
West__Bridgewa[West__Bridgewa.length] = createMarker(new GPoint(-71.05681600,42.03714800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Childrens Express Learning Cen",'West__Bridgewa=' + West__Bridgewa.length);
Marion[Marion.length] = createMarker(new GPoint(-70.75750000,41.71000000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Children's Depot",'Marion=' + Marion.length);
Hingham[Hingham.length] = createMarker(new GPoint(-70.89261500,42.24897900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Derby Academy",'Hingham=' + Hingham.length);
Plymouth[Plymouth.length] = createMarker(new GPoint(-70.73633600,41.93145000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fellowship Christian Academy",'Plymouth=' + Plymouth.length);
Brockton[Brockton.length] = createMarker(new GPoint(-71.03335900,42.11216800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Field House Day School",'Brockton=' + Brockton.length);
Duxbury[Duxbury.length] = createMarker(new GPoint(-70.72525400,42.01408800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Good Shepherd Christian Academy",'Duxbury=' + Duxbury.length);
Rockland[Rockland.length] = createMarker(new GPoint(-70.91477600,42.13356000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Family Elementary School",'Rockland=' + Rockland.length);
Whitman[Whitman.length] = createMarker(new GPoint(-70.91988000,42.08408100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hope Christian School",'Whitman=' + Whitman.length);
Scituate[Scituate.length] = createMarker(new GPoint(-70.75941300,42.17183700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Inly School",'Scituate=' + Scituate.length);
Lakeville[Lakeville.length] = createMarker(new GPoint(-70.94854400,41.87509200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kalia Kids Learning Center",'Lakeville=' + Lakeville.length);
Brockton[Brockton.length] = createMarker(new GPoint(-71.01947200,42.08640600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Keys Of The Kingdom Christian",'Brockton=' + Brockton.length);
Plymouth[Plymouth.length] = createMarker(new GPoint(-70.71739300,41.92387700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kidsport Learning Center",'Plymouth=' + Plymouth.length);
Carver[Carver.length] = createMarker(new GPoint(-70.77190500,41.89101400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kidstop Early Childhood Center, Inc.",'Carver=' + Carver.length);
Norwell[Norwell.length] = createMarker(new GPoint(-70.86009700,42.16035900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kindercare Learning Center #1554",'Norwell=' + Norwell.length);
W_Bridgewater[W_Bridgewater.length] = createMarker(new GPoint(-71.01900000,42.01748000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kiner Care Learning Center #1318",'W_Bridgewater=' + W_Bridgewater.length);
Brockton[Brockton.length] = createMarker(new GPoint(-70.99231900,42.09868100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Labelle Day School",'Brockton=' + Brockton.length);
Plymouth[Plymouth.length] = createMarker(new GPoint(-70.68483800,41.97450800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Little Red Schoolhouse",'Plymouth=' + Plymouth.length);
West_Bridgewater[West_Bridgewater.length] = createMarker(new GPoint(-71.02230000,42.02330000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Magic Touch Nursery Pre School Center",'West_Bridgewater=' + West_Bridgewater.length);
Rockland[Rockland.length] = createMarker(new GPoint(-70.90507500,42.09468700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Master's Academy",'Rockland=' + Rockland.length);
Brockton[Brockton.length] = createMarker(new GPoint(-71.00370700,42.06277700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("May Center For Education And Neurorehabilitation",'Brockton=' + Brockton.length);
Lakeville[Lakeville.length] = createMarker(new GPoint(-70.95567900,41.88283300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mulberry Child Care & Preschool",'Lakeville=' + Lakeville.length);
Hanover[Hanover.length] = createMarker(new GPoint(-70.82541600,42.12365700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mulberry Child Care & Preschool",'Hanover=' + Hanover.length);
Lakeville[Lakeville.length] = createMarker(new GPoint(-70.97522000,41.81224300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mullein Hill Christian Academy",'Lakeville=' + Lakeville.length);
West_Bridgewater[West_Bridgewater.length] = createMarker(new GPoint(-71.00908400,42.03479500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New England Baptist Academy",'West_Bridgewater=' + West_Bridgewater.length);
Plymouth[Plymouth.length] = createMarker(new GPoint(-70.55881300,41.81264500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Testament Christian School",'Plymouth=' + Plymouth.length);
Duxbury[Duxbury.length] = createMarker(new GPoint(-70.73723200,42.03237300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Noahs Ark Day School",'Duxbury=' + Duxbury.length);
Hingham[Hingham.length] = createMarker(new GPoint(-70.90183800,42.18053300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Old Colony Montessori School",'Hingham=' + Hingham.length);
Hanover[Hanover.length] = createMarker(new GPoint(-70.82111400,42.11424700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Little Angels Preschool",'Hanover=' + Hanover.length);
Abington[Abington.length] = createMarker(new GPoint(-70.97440100,42.13498000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Preschool Playmates",'Abington=' + Abington.length);
Plymouth[Plymouth.length] = createMarker(new GPoint(-70.65915000,41.94330400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Radius Pediatric Center Day School At Plymouth",'Plymouth=' + Plymouth.length);
Norwell[Norwell.length] = createMarker(new GPoint(-70.87897900,42.16565500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Ridge Hill School",'Norwell=' + Norwell.length);
Brockton[Brockton.length] = createMarker(new GPoint(-71.01066800,42.08642300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sacred Heart Elementary School",'Brockton=' + Brockton.length);
Kingston[Kingston.length] = createMarker(new GPoint(-70.73437700,41.95044800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sacred Heart Elementary School",'Kingston=' + Kingston.length);
Kingston[Kingston.length] = createMarker(new GPoint(-70.73406900,41.94795700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sacred Heart Pre-primary School",'Kingston=' + Kingston.length);
Abington[Abington.length] = createMarker(new GPoint(-70.93661600,42.11635100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Bridget School",'Abington=' + Abington.length);
Brockton[Brockton.length] = createMarker(new GPoint(-71.01184900,42.10200700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Casimir School",'Brockton=' + Brockton.length);
Brockton[Brockton.length] = createMarker(new GPoint(-71.02000300,42.09903600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Edward Elementary School",'Brockton=' + Brockton.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);
Bridgewater[Bridgewater.length] = createMarker(new GPoint(-70.94792500,41.99017900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Southbrook Academy",'Bridgewater=' + Bridgewater.length);
Hingham[Hingham.length] = createMarker(new GPoint(-70.89036900,42.24344700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Paul Elementary School",'Hingham=' + Hingham.length);
Marshfield[Marshfield.length] = createMarker(new GPoint(-70.71040200,42.09121100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Steeple School Of Trinity Church",'Marshfield=' + Marshfield.length);
Plymouth[Plymouth.length] = createMarker(new GPoint(-70.70813800,41.95560000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Superkids Of Plymouth",'Plymouth=' + Plymouth.length);
Brockton[Brockton.length] = createMarker(new GPoint(-71.03835200,42.06170000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tinker Bell Kindergarten",'Brockton=' + Brockton.length);
Norwell[Norwell.length] = createMarker(new GPoint(-70.87768600,42.15618600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wearguard Child Development Center",'Norwell=' + Norwell.length);
Brockton[Brockton.length] = createMarker(new GPoint(-71.06413200,42.07077500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Westfield Child Center",'Brockton=' + Brockton.length);
Kingston[Kingston.length] = createMarker(new GPoint(-70.72243300,41.98946200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wooded Acres Child Care",'Kingston=' + Kingston.length);
Plymouth[Plymouth.length] = createMarker(new GPoint(-70.71182200,41.89584600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Woodside School & Community Resource Center",'Plymouth=' + Plymouth.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/////1/' + showArray);
map.removeOverlays(Abington);
map.removeOverlays(Bridgewater);
map.removeOverlays(Brockton);
map.removeOverlays(Carver);
map.removeOverlays(Duxbury);
map.removeOverlays(Hanover);
map.removeOverlays(Hingham);
map.removeOverlays(Kingston);
map.removeOverlays(Lakeville);
map.removeOverlays(Marion);
map.removeOverlays(Marshfield);
map.removeOverlays(Norwell);
map.removeOverlays(Plymouth);
map.removeOverlays(Rockland);
map.removeOverlays(Scituate);
map.removeOverlays(W_Bridgewater);
map.removeOverlays(West_Bridgewater);
map.removeOverlays(West__Bridgewa);
map.removeOverlays(Whitman);
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(Plymouth);map.removeOverlays(Abington);
map.removeOverlays(Bridgewater);
map.removeOverlays(Brockton);
map.removeOverlays(Carver);
map.removeOverlays(Duxbury);
map.removeOverlays(Hanover);
map.removeOverlays(Hingham);
map.removeOverlays(Kingston);
map.removeOverlays(Lakeville);
map.removeOverlays(Marion);
map.removeOverlays(Marshfield);
map.removeOverlays(Norwell);
map.removeOverlays(Plymouth);
map.removeOverlays(Rockland);
map.removeOverlays(Scituate);
map.removeOverlays(W_Bridgewater);
map.removeOverlays(West_Bridgewater);
map.removeOverlays(West__Bridgewa);
map.removeOverlays(Whitman);
map.addOverlays(Abington);
centerByArray(Abington, false, false);
cntMarker += Abington.length;
map.addOverlays(Bridgewater);
centerByArray(Bridgewater, false, false);
cntMarker += Bridgewater.length;
map.addOverlays(Brockton);
centerByArray(Brockton, false, false);
cntMarker += Brockton.length;
map.addOverlays(Carver);
centerByArray(Carver, false, false);
cntMarker += Carver.length;
map.addOverlays(Duxbury);
centerByArray(Duxbury, false, false);
cntMarker += Duxbury.length;
map.addOverlays(Hanover);
centerByArray(Hanover, false, false);
cntMarker += Hanover.length;
map.addOverlays(Hingham);
centerByArray(Hingham, false, false);
cntMarker += Hingham.length;
map.addOverlays(Kingston);
centerByArray(Kingston, false, false);
cntMarker += Kingston.length;
map.addOverlays(Lakeville);
centerByArray(Lakeville, false, false);
cntMarker += Lakeville.length;
map.addOverlays(Marion);
centerByArray(Marion, false, false);
cntMarker += Marion.length;
map.addOverlays(Marshfield);
centerByArray(Marshfield, false, false);
cntMarker += Marshfield.length;
map.addOverlays(Norwell);
centerByArray(Norwell, false, false);
cntMarker += Norwell.length;
map.addOverlays(Plymouth);
centerByArray(Plymouth, false, false);
cntMarker += Plymouth.length;
map.addOverlays(Rockland);
centerByArray(Rockland, false, false);
cntMarker += Rockland.length;
map.addOverlays(Scituate);
centerByArray(Scituate, false, false);
cntMarker += Scituate.length;
map.addOverlays(W_Bridgewater);
centerByArray(W_Bridgewater, false, false);
cntMarker += W_Bridgewater.length;
map.addOverlays(West_Bridgewater);
centerByArray(West_Bridgewater, false, false);
cntMarker += West_Bridgewater.length;
map.addOverlays(West__Bridgewa);
centerByArray(West__Bridgewa, false, false);
cntMarker += West__Bridgewa.length;
map.addOverlays(Whitman);
centerByArray(Whitman, false, false);
cntMarker += Whitman.length;
centerByArray(Plymouth,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=1&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;
}