function addMarkers(){ mySelect = document.getElementById('selection'); Bangor = [];North_Yarmouth = [];York = [];South_Portland = [];South_Berwick = [];Camden = [];Sthwest_Harbor = [];Fairfield = [];Bath = [];Sedgwick = [];Falmouth = [];Old_Town = [];Wiscasset = [];Biddeford_Pool = [];mySelect.options[mySelect.options.length] = new Option("Bangor schools",'all=Bangor'); mySelect.options[mySelect.options.length] = new Option("Bath schools",'all=Bath'); mySelect.options[mySelect.options.length] = new Option("Biddeford Pool schools",'all=Biddeford_Pool'); mySelect.options[mySelect.options.length] = new Option("Camden schools",'all=Camden'); mySelect.options[mySelect.options.length] = new Option("Fairfield schools",'all=Fairfield'); mySelect.options[mySelect.options.length] = new Option("Falmouth schools",'all=Falmouth'); mySelect.options[mySelect.options.length] = new Option("North Yarmouth schools",'all=North_Yarmouth'); mySelect.options[mySelect.options.length] = new Option("Old Town schools",'all=Old_Town'); mySelect.options[mySelect.options.length] = new Option("Sedgwick schools",'all=Sedgwick'); mySelect.options[mySelect.options.length] = new Option("South Berwick schools",'all=South_Berwick'); mySelect.options[mySelect.options.length] = new Option("South Portland schools",'all=South_Portland'); mySelect.options[mySelect.options.length] = new Option("Sthwest Harbor schools",'all=Sthwest_Harbor'); mySelect.options[mySelect.options.length] = new Option("Wiscasset schools",'all=Wiscasset'); mySelect.options[mySelect.options.length] = new Option("York schools",'all=York'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Bangor[Bangor.length] = createMarker(new GPoint(-68.75572800,44.80856200),"
Bangor Montessori School
30 Otis Street
Bangor, ME 04401
Co-ed school, PK-KG
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bangor Montessori School",'Bangor=' + Bangor.length); North_Yarmouth[North_Yarmouth.length] = createMarker(new GPoint(-70.22042600,43.85500300),"
Brailsford School
512 Memorial Hwy
North Yarmouth, ME 04097
Co-ed school, PK-2
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Brailsford School",'North_Yarmouth=' + North_Yarmouth.length); York[York.length] = createMarker(new GPoint(-70.73589500,43.18076200),"
Brixham Montessori Friends School
18 Brickyard Court
York, ME 03909
Co-ed school, PK-3
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Brixham Montessori Friends School",'York=' + York.length); South_Portland[South_Portland.length] = createMarker(new GPoint(-70.25038700,43.62699500),"
Casco Bay Montessori School
440 Ocean Street
South Portland, ME 04106
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Casco Bay Montessori School",'South_Portland=' + South_Portland.length); South_Berwick[South_Berwick.length] = createMarker(new GPoint(-70.80779000,43.22666700),"
Childlight Montessori School
28 Liberty Street
South Berwick, ME 03908
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Childlight Montessori School",'South_Berwick=' + South_Berwick.length); Camden[Camden.length] = createMarker(new GPoint(-69.09820000,44.17030000),"
Children's House Montessori School
58 Elm Street
Camden, ME 04843
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Children's House Montessori School",'Camden=' + Camden.length); Sthwest_Harbor[Sthwest_Harbor.length] = createMarker(new GPoint(-68.32595600,44.27977100),"
Island Montessori School
Po Box 418
Sthwest Harbor, ME 04679
Co-ed school, PK-KG
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Island Montessori School",'Sthwest_Harbor=' + Sthwest_Harbor.length); Fairfield[Fairfield.length] = createMarker(new GPoint(-69.62071600,44.59345500),"
Kennebec Montessori School
38 Sheridan Road
Fairfield, ME 04937
Co-ed school, PK-3
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Kennebec Montessori School",'Fairfield=' + Fairfield.length); Bath[Bath.length] = createMarker(new GPoint(-69.81955900,43.91268000),"
Midcoast Montessori School
785 High Street
Bath, ME 04530
Co-ed school, PK-3
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Midcoast Montessori School",'Bath=' + Bath.length); Sedgwick[Sedgwick.length] = createMarker(new GPoint(-68.60966500,44.35351700),"
Peninsula Montessori School
274 Sedgwick Ridge Road
Sedgwick, ME 04676
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Peninsula Montessori School",'Sedgwick=' + Sedgwick.length); Falmouth[Falmouth.length] = createMarker(new GPoint(-70.23110400,43.71163000),"
Pine Grove Child Development Center
32 Foreside Road
Falmouth, ME 04105
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Pine Grove Child Development Center",'Falmouth=' + Falmouth.length); North_Yarmouth[North_Yarmouth.length] = createMarker(new GPoint(-70.24708900,43.82504100),"
Red House Montessori School
392 Walnut Hill Rd
North Yarmouth, ME 04097
Co-ed school, PK-KG
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Red House Montessori School",'North_Yarmouth=' + North_Yarmouth.length); Old_Town[Old_Town.length] = createMarker(new GPoint(-68.68328700,44.91455600),"
Stillwater Montessori School
1024 Stillwater Avenue
Old Town, ME 04468
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Stillwater Montessori School",'Old_Town=' + Old_Town.length); Wiscasset[Wiscasset.length] = createMarker(new GPoint(-69.68590000,43.97010000),"
Svch
Po Box 449
Wiscasset, ME 04578
Co-ed school, PK-3
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Svch",'Wiscasset=' + Wiscasset.length); Falmouth[Falmouth.length] = createMarker(new GPoint(-70.27530900,43.76109600),"
Winfield Children's House
161 Field Road
Falmouth, ME 04105
Co-ed school, NS-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Winfield Children's House",'Falmouth=' + Falmouth.length); Biddeford_Pool[Biddeford_Pool.length] = createMarker(new GPoint(-70.34267400,43.44579500),"
Winter Harbor Children's House
2 Yates Street
Biddeford Pool, ME 04006
Co-ed school, NS-NS
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Winter Harbor Children's House",'Biddeford_Pool=' + Biddeford_Pool.length); map.removeOverlays(Bangor); map.removeOverlays(Bath); map.removeOverlays(Biddeford_Pool); map.removeOverlays(Camden); map.removeOverlays(Fairfield); map.removeOverlays(Falmouth); map.removeOverlays(North_Yarmouth); map.removeOverlays(Old_Town); map.removeOverlays(Sedgwick); map.removeOverlays(South_Berwick); map.removeOverlays(South_Portland); map.removeOverlays(Sthwest_Harbor); map.removeOverlays(Wiscasset); map.removeOverlays(York); setTimeout(function(){map.addOverlays(Bangor)},1000); setTimeout(function(){map.addOverlays(Bath)},1000); setTimeout(function(){map.addOverlays(Biddeford_Pool)},1000); setTimeout(function(){map.addOverlays(Camden)},1000); setTimeout(function(){map.addOverlays(Fairfield)},1000); setTimeout(function(){map.addOverlays(Falmouth)},1000); setTimeout(function(){map.addOverlays(North_Yarmouth)},1000); setTimeout(function(){map.addOverlays(Old_Town)},1000); setTimeout(function(){map.addOverlays(Sedgwick)},1000); setTimeout(function(){map.addOverlays(South_Berwick)},1000); setTimeout(function(){map.addOverlays(South_Portland)},1000); setTimeout(function(){map.addOverlays(Sthwest_Harbor)},1000); setTimeout(function(){map.addOverlays(Wiscasset)},1000); setTimeout(function(){map.addOverlays(York)},1000); maxLng = -68.32595600; maxLat = 44.91455600; minLng = -70.80779000; minLat = 43.18076200; 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(Bangor); map.removeOverlays(Bath); map.removeOverlays(Biddeford_Pool); map.removeOverlays(Camden); map.removeOverlays(Fairfield); map.removeOverlays(Falmouth); map.removeOverlays(North_Yarmouth); map.removeOverlays(Old_Town); map.removeOverlays(Sedgwick); map.removeOverlays(South_Berwick); map.removeOverlays(South_Portland); map.removeOverlays(Sthwest_Harbor); map.removeOverlays(Wiscasset); map.removeOverlays(York); 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(Bangor);map.removeOverlays(Bangor); map.removeOverlays(Bath); map.removeOverlays(Biddeford_Pool); map.removeOverlays(Camden); map.removeOverlays(Fairfield); map.removeOverlays(Falmouth); map.removeOverlays(North_Yarmouth); map.removeOverlays(Old_Town); map.removeOverlays(Sedgwick); map.removeOverlays(South_Berwick); map.removeOverlays(South_Portland); map.removeOverlays(Sthwest_Harbor); map.removeOverlays(Wiscasset); map.removeOverlays(York); map.addOverlays(Bangor); centerByArray(Bangor, false, false); cntMarker += Bangor.length; map.addOverlays(Bath); centerByArray(Bath, false, false); cntMarker += Bath.length; map.addOverlays(Biddeford_Pool); centerByArray(Biddeford_Pool, false, false); cntMarker += Biddeford_Pool.length; map.addOverlays(Camden); centerByArray(Camden, false, false); cntMarker += Camden.length; map.addOverlays(Fairfield); centerByArray(Fairfield, false, false); cntMarker += Fairfield.length; map.addOverlays(Falmouth); centerByArray(Falmouth, false, false); cntMarker += Falmouth.length; map.addOverlays(North_Yarmouth); centerByArray(North_Yarmouth, false, false); cntMarker += North_Yarmouth.length; map.addOverlays(Old_Town); centerByArray(Old_Town, false, false); cntMarker += Old_Town.length; map.addOverlays(Sedgwick); centerByArray(Sedgwick, false, false); cntMarker += Sedgwick.length; map.addOverlays(South_Berwick); centerByArray(South_Berwick, false, false); cntMarker += South_Berwick.length; map.addOverlays(South_Portland); centerByArray(South_Portland, false, false); cntMarker += South_Portland.length; map.addOverlays(Sthwest_Harbor); centerByArray(Sthwest_Harbor, false, false); cntMarker += Sthwest_Harbor.length; map.addOverlays(Wiscasset); centerByArray(Wiscasset, false, false); cntMarker += Wiscasset.length; map.addOverlays(York); centerByArray(York, false, false); cntMarker += York.length; centerByArray(Bangor,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///11895,12036,12028,11910,34583,11977,12027,12031,12037,12005,31326,11911,11903,11947,11987,12032,/all'); //window.open('/map.php?type=2&schools=11895,12036,12028,11910,34583,11977,12027,12031,12037,12005,31326,11911,11903,11947,11987,12032,&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; }