function addMarkers() { mySelect = document.getElementById('selection'); Cape_Elizabeth = [];Bar_Harbor = [];N_Anson = [];Falmouth = [];Northeast_Hbr = [];Strong = [];Yarmouth = [];mySelect.options[mySelect.options.length] = new Option("Bar Harbor schools",'all=Bar_Harbor'); mySelect.options[mySelect.options.length] = new Option("Cape Elizabeth schools",'all=Cape_Elizabeth'); mySelect.options[mySelect.options.length] = new Option("Falmouth schools",'all=Falmouth'); mySelect.options[mySelect.options.length] = new Option("N Anson schools",'all=N_Anson'); mySelect.options[mySelect.options.length] = new Option("Northeast Hbr schools",'all=Northeast_Hbr'); mySelect.options[mySelect.options.length] = new Option("Strong schools",'all=Strong'); mySelect.options[mySelect.options.length] = new Option("Yarmouth schools",'all=Yarmouth'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Cape_Elizabeth[Cape_Elizabeth.length] = createMarker(new GPoint(-70.22669983,43.59125137),"
Cape Elizabeth High School
345 Ocean House Road
Cape Elizabeth, ME 04107

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cape Elizabeth High School",'Cape_Elizabeth=' + Cape_Elizabeth.length); Bar_Harbor[Bar_Harbor.length] = createMarker(new GPoint(-68.21614075,44.38698196),"
Conners-emerson School
11 Eagle Lake Road
Bar Harbor, ME 04609

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Conners-emerson School",'Bar_Harbor=' + Bar_Harbor.length); N_Anson[N_Anson.length] = createMarker(new GPoint(-69.96082306,44.95067978),"
Embden Elementary School
797 Embden Pond Rd Po Box 87
N Anson, ME 04958

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Embden Elementary School",'N_Anson=' + N_Anson.length); Falmouth[Falmouth.length] = createMarker(new GPoint(-70.27267456,43.73831558),"
Falmouth Middle School
52 Woodville Road
Falmouth, ME 04105

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Falmouth Middle School",'Falmouth=' + Falmouth.length); Northeast_Hbr[Northeast_Hbr.length] = createMarker(new GPoint(-68.29206085,44.29378128),"
Mt Desert Elementary School
Joy Rd P.o. Box 308
Northeast Hbr, ME 04662

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mt Desert Elementary School",'Northeast_Hbr=' + Northeast_Hbr.length); Falmouth[Falmouth.length] = createMarker(new GPoint(-70.24475861,43.72441483),"
Plummer-motz School
192 Middle Road
Falmouth, ME 04105

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Plummer-motz School",'Falmouth=' + Falmouth.length); Strong[Strong.length] = createMarker(new GPoint(-70.21871948,44.81428146),"
Strong Elementary School
110 N Main Street
Strong, ME 04983

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Strong Elementary School",'Strong=' + Strong.length); Yarmouth[Yarmouth.length] = createMarker(new GPoint(-70.19650269,43.79447174),"
Yarmouth High School
286 West Elm Street
Yarmouth, ME 04096

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Yarmouth High School",'Yarmouth=' + Yarmouth.length); map.removeOverlays(Bar_Harbor); map.removeOverlays(Cape_Elizabeth); map.removeOverlays(Falmouth); map.removeOverlays(N_Anson); map.removeOverlays(Northeast_Hbr); map.removeOverlays(Strong); map.removeOverlays(Yarmouth); setTimeout(function(){map.addOverlays(Bar_Harbor)},1000); setTimeout(function(){map.addOverlays(Cape_Elizabeth)},1000); setTimeout(function(){map.addOverlays(Falmouth)},1000); setTimeout(function(){map.addOverlays(N_Anson)},1000); setTimeout(function(){map.addOverlays(Northeast_Hbr)},1000); setTimeout(function(){map.addOverlays(Strong)},1000); setTimeout(function(){map.addOverlays(Yarmouth)},1000); maxLng = -68.21614075; maxLat = 44.95067978; minLng = -70.27267456; minLat = 43.59125137; 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,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////' + showArray); map.removeOverlays(Bar_Harbor); map.removeOverlays(Cape_Elizabeth); map.removeOverlays(Falmouth); map.removeOverlays(N_Anson); map.removeOverlays(Northeast_Hbr); map.removeOverlays(Strong); map.removeOverlays(Yarmouth); 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(Cape_Elizabeth);map.removeOverlays(Bar_Harbor); map.removeOverlays(Cape_Elizabeth); map.removeOverlays(Falmouth); map.removeOverlays(N_Anson); map.removeOverlays(Northeast_Hbr); map.removeOverlays(Strong); map.removeOverlays(Yarmouth); map.addOverlays(Bar_Harbor); centerByArray(Bar_Harbor, false, false); cntMarker += Bar_Harbor.length; map.addOverlays(Cape_Elizabeth); centerByArray(Cape_Elizabeth, false, false); cntMarker += Cape_Elizabeth.length; map.addOverlays(Falmouth); centerByArray(Falmouth, false, false); cntMarker += Falmouth.length; map.addOverlays(N_Anson); centerByArray(N_Anson, false, false); cntMarker += N_Anson.length; map.addOverlays(Northeast_Hbr); centerByArray(Northeast_Hbr, false, false); cntMarker += Northeast_Hbr.length; map.addOverlays(Strong); centerByArray(Strong, false, false); cntMarker += Strong.length; map.addOverlays(Yarmouth); centerByArray(Yarmouth, false, false); cntMarker += Yarmouth.length; centerByArray(Cape_Elizabeth,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///35083,35531,35118,35046,35117,35671,35192,35562,/all'); } }