function addMarkers(){ mySelect = document.getElementById('selection'); Cape_Elizabeth = [];Steep_Falls = [];Portland = [];Scarborough = [];South_Portland = [];Freeport = [];New_Gloucester = [];Yarmouth = [];Brunswick = [];Windham = [];mySelect.options[mySelect.options.length] = new Option("Brunswick schools",'all=Brunswick'); mySelect.options[mySelect.options.length] = new Option("Cape Elizabeth schools",'all=Cape_Elizabeth'); mySelect.options[mySelect.options.length] = new Option("Freeport schools",'all=Freeport'); mySelect.options[mySelect.options.length] = new Option("New Gloucester schools",'all=New_Gloucester'); mySelect.options[mySelect.options.length] = new Option("Portland schools",'all=Portland'); mySelect.options[mySelect.options.length] = new Option("Scarborough schools",'all=Scarborough'); mySelect.options[mySelect.options.length] = new Option("South Portland schools",'all=South_Portland'); mySelect.options[mySelect.options.length] = new Option("Steep Falls schools",'all=Steep_Falls'); mySelect.options[mySelect.options.length] = new Option("Windham schools",'all=Windham'); 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.24662400,43.61886500),"
Aucocisco School
126 Spurwink Avenue
Cape Elizabeth, ME 04107
Co-ed school, 5-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Aucocisco School",'Cape_Elizabeth=' + Cape_Elizabeth.length); Steep_Falls[Steep_Falls.length] = createMarker(new GPoint(-70.63850000,43.76690000),"
Berean Christian Academy
Po Box 22
Steep Falls, ME 04085
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Berean Christian Academy",'Steep_Falls=' + Steep_Falls.length); Portland[Portland.length] = createMarker(new GPoint(-70.29413900,43.67932500),"
Catherine Mcauley High School
631 Stevens Avenue
Portland, ME 04103
All-girls school, 9-12
[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Catherine Mcauley High School",'Portland=' + Portland.length); Portland[Portland.length] = createMarker(new GPoint(-70.27833500,43.67963300),"
Cheverus High School
267 Ocean Avenue
Portland, ME 04103
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cheverus High School",'Portland=' + Portland.length); Scarborough[Scarborough.length] = createMarker(new GPoint(-70.34630000,43.58480000),"
Day School
136 U S Route One Ste 1
Scarborough, ME 04074
Co-ed school, 7-11
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Day School",'Scarborough=' + Scarborough.length); Portland[Portland.length] = createMarker(new GPoint(-70.29615100,43.71826200),"
Grace Baptist Church School
476 Summit Street
Portland, ME 04103
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Grace Baptist Church School",'Portland=' + Portland.length); South_Portland[South_Portland.length] = createMarker(new GPoint(-70.28770900,43.62979200),"
Greater Portland Christian School
1338 Broadway
South Portland, ME 04106
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Greater Portland Christian School",'South_Portland=' + South_Portland.length); Freeport[Freeport.length] = createMarker(new GPoint(-70.10320000,43.85630000),"
Maine Classical School
P.O. Box 243
Freeport, ME 04032
Co-ed school, KG-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Maine Classical School",'Freeport=' + Freeport.length); Freeport[Freeport.length] = createMarker(new GPoint(-70.14300100,43.85352900),"
Merriconeag Waldorf School
57 Desert Road
Freeport, ME 04032
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Merriconeag Waldorf School",'Freeport=' + Freeport.length); Portland[Portland.length] = createMarker(new GPoint(-70.24671000,43.68925400),"
Morrison Developmental Center
331 Veranda Street
Portland, ME 04103
Co-ed school, PK-11
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Morrison Developmental Center",'Portland=' + Portland.length); New_Gloucester[New_Gloucester.length] = createMarker(new GPoint(-70.25506900,43.90369700),"
Msemhc-collaborative School
41 Pineland Drive
New Gloucester, ME 04260
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Msemhc-collaborative School",'New_Gloucester=' + New_Gloucester.length); Yarmouth[Yarmouth.length] = createMarker(new GPoint(-70.18481000,43.79966800),"
North Yarmouth Academy
148 Main St
Yarmouth, ME 04096
Co-ed school, 6-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("North Yarmouth Academy",'Yarmouth=' + Yarmouth.length); Freeport[Freeport.length] = createMarker(new GPoint(-70.11317000,43.86310900),"
Pine Tree Academy
67 Pownal Road
Freeport, ME 04032
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Pine Tree Academy",'Freeport=' + Freeport.length); Brunswick[Brunswick.length] = createMarker(new GPoint(-70.05861600,43.90058100),"
Spurwink Brunswick Staff Secure
675 Old Portland Road
Brunswick, ME 04011
Co-ed school, 5-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Spurwink Brunswick Staff Secure",'Brunswick=' + Brunswick.length); Portland[Portland.length] = createMarker(new GPoint(-70.31912600,43.70523800),"
Spurwink School
899 Riverside Street
Portland, ME 04103
Co-ed school, NS-NS
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Spurwink School",'Portland=' + Portland.length); Portland[Portland.length] = createMarker(new GPoint(-70.26742800,43.68663400),"
Spurwink-cummings School
587 Ocean Avenue
Portland, ME 04103
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Spurwink-cummings School",'Portland=' + Portland.length); Portland[Portland.length] = createMarker(new GPoint(-70.27096200,43.64639100),"
Waynflete School
360 Spring Street
Portland, ME 04102
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Waynflete School",'Portland=' + Portland.length); Windham[Windham.length] = createMarker(new GPoint(-70.46606200,43.86438500),"
Windham Christian Academy
1051 Roosevelt Trail
Windham, ME 04062
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Windham Christian Academy",'Windham=' + Windham.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/////2/' + showArray); map.removeOverlays(Brunswick); map.removeOverlays(Cape_Elizabeth); map.removeOverlays(Freeport); map.removeOverlays(New_Gloucester); map.removeOverlays(Portland); map.removeOverlays(Scarborough); map.removeOverlays(South_Portland); map.removeOverlays(Steep_Falls); map.removeOverlays(Windham); 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(Brunswick); map.removeOverlays(Cape_Elizabeth); map.removeOverlays(Freeport); map.removeOverlays(New_Gloucester); map.removeOverlays(Portland); map.removeOverlays(Scarborough); map.removeOverlays(South_Portland); map.removeOverlays(Steep_Falls); map.removeOverlays(Windham); map.removeOverlays(Yarmouth); map.addOverlays(Brunswick); centerByArray(Brunswick, false, false); cntMarker += Brunswick.length; map.addOverlays(Cape_Elizabeth); centerByArray(Cape_Elizabeth, false, false); cntMarker += Cape_Elizabeth.length; map.addOverlays(Freeport); centerByArray(Freeport, false, false); cntMarker += Freeport.length; map.addOverlays(New_Gloucester); centerByArray(New_Gloucester, false, false); cntMarker += New_Gloucester.length; map.addOverlays(Portland); centerByArray(Portland, false, false); cntMarker += Portland.length; map.addOverlays(Scarborough); centerByArray(Scarborough, false, false); cntMarker += Scarborough.length; map.addOverlays(South_Portland); centerByArray(South_Portland, false, false); cntMarker += South_Portland.length; map.addOverlays(Steep_Falls); centerByArray(Steep_Falls, false, false); cntMarker += Steep_Falls.length; map.addOverlays(Windham); centerByArray(Windham, false, false); cntMarker += Windham.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////all'); //window.open('/map.php?type=1&schools=&school_level=2&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; }