function addMarkers() { mySelect = document.getElementById('selection'); Searsmont = [];Belfast = [];Northport = [];Frankfort = [];Morrill = [];Islesboro = [];Swanville = [];Winterport = [];Lincolnville = [];Monroe = [];Brooks = [];Thorndike = [];Palermo = [];Searsport = [];Stockton_Springs = [];Troy = [];Unity = [];Waldo = [];Liberty = [];mySelect.options[mySelect.options.length] = new Option("Belfast schools",'all=Belfast'); mySelect.options[mySelect.options.length] = new Option("Brooks schools",'all=Brooks'); mySelect.options[mySelect.options.length] = new Option("Frankfort schools",'all=Frankfort'); mySelect.options[mySelect.options.length] = new Option("Islesboro schools",'all=Islesboro'); mySelect.options[mySelect.options.length] = new Option("Liberty schools",'all=Liberty'); mySelect.options[mySelect.options.length] = new Option("Lincolnville schools",'all=Lincolnville'); mySelect.options[mySelect.options.length] = new Option("Monroe schools",'all=Monroe'); mySelect.options[mySelect.options.length] = new Option("Morrill schools",'all=Morrill'); mySelect.options[mySelect.options.length] = new Option("Northport schools",'all=Northport'); mySelect.options[mySelect.options.length] = new Option("Palermo schools",'all=Palermo'); mySelect.options[mySelect.options.length] = new Option("Searsmont schools",'all=Searsmont'); mySelect.options[mySelect.options.length] = new Option("Searsport schools",'all=Searsport'); mySelect.options[mySelect.options.length] = new Option("Stockton Springs schools",'all=Stockton_Springs'); mySelect.options[mySelect.options.length] = new Option("Swanville schools",'all=Swanville'); mySelect.options[mySelect.options.length] = new Option("Thorndike schools",'all=Thorndike'); mySelect.options[mySelect.options.length] = new Option("Troy schools",'all=Troy'); mySelect.options[mySelect.options.length] = new Option("Unity schools",'all=Unity'); mySelect.options[mySelect.options.length] = new Option("Waldo schools",'all=Waldo'); mySelect.options[mySelect.options.length] = new Option("Winterport schools",'all=Winterport'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Searsmont[Searsmont.length] = createMarker(new GPoint(-69.19518280,44.36132813),"
Ames Elementary School
Hc 81 Box 160
Searsmont, ME 04973

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Ames Elementary School",'Searsmont=' + Searsmont.length); Belfast[Belfast.length] = createMarker(new GPoint(-69.01699066,44.43038559),"
Belfast Area High School
98 Waldo Avenue
Belfast, ME 04915

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Belfast Area High School",'Belfast=' + Belfast.length); Belfast[Belfast.length] = createMarker(new GPoint(-69.00415802,44.43618774),"
East Belfast School
14 Swan Lake Avenue
Belfast, ME 04915

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("East Belfast School",'Belfast=' + Belfast.length); Northport[Northport.length] = createMarker(new GPoint(-68.97783661,44.38195419),"
Edna Drinkwater School
56 Bayside Road
Northport, ME 04849

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Edna Drinkwater School",'Northport=' + Northport.length); Frankfort[Frankfort.length] = createMarker(new GPoint(-68.93453217,44.60997772),"
Frankfort Elementary School
112 North Searsport Road
Frankfort, ME 04438

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Frankfort Elementary School",'Frankfort=' + Frankfort.length); Belfast[Belfast.length] = createMarker(new GPoint(-69.01127625,44.41982651),"
George H Robertson School
9 School Street
Belfast, ME 04915

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("George H Robertson School",'Belfast=' + Belfast.length); Morrill[Morrill.length] = createMarker(new GPoint(-69.14893341,44.44293976),"
Gladys Weymouth Elementary School
2 South Main Street
Morrill, ME 04952

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Gladys Weymouth Elementary School",'Morrill=' + Morrill.length); Belfast[Belfast.length] = createMarker(new GPoint(-69.01360321,44.42979431),"
Governor Anderson School
256 High Street
Belfast, ME 04915

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Governor Anderson School",'Belfast=' + Belfast.length); Islesboro[Islesboro.length] = createMarker(new GPoint(-68.91297913,44.26726151),"
Islesboro Central School
159 Alumni Dr Po Box 118
Islesboro, ME 04848

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Islesboro Central School",'Islesboro=' + Islesboro.length); Swanville[Swanville.length] = createMarker(new GPoint(-68.99340057,44.48369980),"
Kermit S Nickerson School
18 Townhouse Road
Swanville, ME 04915

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Kermit S Nickerson School",'Swanville=' + Swanville.length); Winterport[Winterport.length] = createMarker(new GPoint(-68.84971619,44.63300705),"
Leroy H Smith School
319 S Main St Po Box 10
Winterport, ME 04496

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Leroy H Smith School",'Winterport=' + Winterport.length); Lincolnville[Lincolnville.length] = createMarker(new GPoint(-69.00879669,44.28123093),"
Lincolnville Central School
523 Hope Road
Lincolnville, ME 04849

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincolnville Central School",'Lincolnville=' + Lincolnville.length); Monroe[Monroe.length] = createMarker(new GPoint(-69.01785278,44.61370087),"
Monroe Elementary School
36 West Main St Po Box 789
Monroe, ME 04951

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Monroe Elementary School",'Monroe=' + Monroe.length); Brooks[Brooks.length] = createMarker(new GPoint(-69.12966156,44.55509949),"
Morse Memorial School
27 School St Po Box 37
Brooks, ME 04921

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Morse Memorial School",'Brooks=' + Brooks.length); Thorndike[Thorndike.length] = createMarker(new GPoint(-69.26879120,44.55356598),"
Mt View Elementary School
573 Mount View Road
Thorndike, ME 04986

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mt View Elementary School",'Thorndike=' + Thorndike.length); Thorndike[Thorndike.length] = createMarker(new GPoint(-69.26876831,44.55350494),"
Mt View High School
577 Mount View Road
Thorndike, ME 04986

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Mt View High School",'Thorndike=' + Thorndike.length); Thorndike[Thorndike.length] = createMarker(new GPoint(-69.26877594,44.55353546),"
Mt View Junior High School
575 Mount View Road
Thorndike, ME 04986

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Mt View Junior High School",'Thorndike=' + Thorndike.length); Palermo[Palermo.length] = createMarker(new GPoint(-69.46586609,44.38719177),"
Palermo Consolidated School
501 Route 3
Palermo, ME 04354

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Palermo Consolidated School",'Palermo=' + Palermo.length); Belfast[Belfast.length] = createMarker(new GPoint(-69.00099182,44.42099762),"
Peirce Elementary School
31 Elementary Avenue
Belfast, ME 04915

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Peirce Elementary School",'Belfast=' + Belfast.length); Winterport[Winterport.length] = createMarker(new GPoint(-68.84519196,44.63795853),"
Samuel L Wagner Middle School
Mountain View Dr Po Box 739
Winterport, ME 04496

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Samuel L Wagner Middle School",'Winterport=' + Winterport.length); Searsport[Searsport.length] = createMarker(new GPoint(-68.92469788,44.48280716),"
Searsport District High School
24 Mortland Road
Searsport, ME 04974

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Searsport District High School",'Searsport=' + Searsport.length); Searsport[Searsport.length] = createMarker(new GPoint(-68.92471313,44.48282242),"
Searsport District Middle School
26 Mortland Road
Searsport, ME 04974

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Searsport District Middle School",'Searsport=' + Searsport.length); Searsport[Searsport.length] = createMarker(new GPoint(-68.92475128,44.48285675),"
Searsport Elementary School
30 Mortland Road
Searsport, ME 04974

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Searsport Elementary School",'Searsport=' + Searsport.length); Stockton_Springs[Stockton_Springs.length] = createMarker(new GPoint(-68.84519958,44.51319885),"
Stockton Springs Elementary School
113 Church Street
Stockton Springs, ME 04981

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Stockton Springs Elementary School",'Stockton_Springs=' + Stockton_Springs.length); Belfast[Belfast.length] = createMarker(new GPoint(-69.02365875,44.41331863),"
Troy A Howard Middle School
173 Lincolnville Avenue
Belfast, ME 04915

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Troy A Howard Middle School",'Belfast=' + Belfast.length); Troy[Troy.length] = createMarker(new GPoint(-69.24160767,44.66484070),"
Troy Central School
733 Bangor Rd Po Box 30
Troy, ME 04987

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Troy Central School",'Troy=' + Troy.length); Unity[Unity.length] = createMarker(new GPoint(-69.33419037,44.61127853),"
Unity Elementary School
84 School Street
Unity, ME 04988

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Unity Elementary School",'Unity=' + Unity.length); Waldo[Waldo.length] = createMarker(new GPoint(-69.06112671,44.44498444),"
Waldo County Technical Ctr-region 7 High School
1022 Waterville Road
Waldo, ME 04915

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Waldo County Technical Ctr-region 7 High School",'Waldo=' + Waldo.length); Liberty[Liberty.length] = createMarker(new GPoint(-69.30225372,44.38798904),"
Walker Memorial School
33 West Main Street
Liberty, ME 04949

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Walker Memorial School",'Liberty=' + Liberty.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,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(Belfast); map.removeOverlays(Brooks); map.removeOverlays(Frankfort); map.removeOverlays(Islesboro); map.removeOverlays(Liberty); map.removeOverlays(Lincolnville); map.removeOverlays(Monroe); map.removeOverlays(Morrill); map.removeOverlays(Northport); map.removeOverlays(Palermo); map.removeOverlays(Searsmont); map.removeOverlays(Searsport); map.removeOverlays(Stockton_Springs); map.removeOverlays(Swanville); map.removeOverlays(Thorndike); map.removeOverlays(Troy); map.removeOverlays(Unity); map.removeOverlays(Waldo); map.removeOverlays(Winterport); 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(Searsmont);map.removeOverlays(Belfast); map.removeOverlays(Brooks); map.removeOverlays(Frankfort); map.removeOverlays(Islesboro); map.removeOverlays(Liberty); map.removeOverlays(Lincolnville); map.removeOverlays(Monroe); map.removeOverlays(Morrill); map.removeOverlays(Northport); map.removeOverlays(Palermo); map.removeOverlays(Searsmont); map.removeOverlays(Searsport); map.removeOverlays(Stockton_Springs); map.removeOverlays(Swanville); map.removeOverlays(Thorndike); map.removeOverlays(Troy); map.removeOverlays(Unity); map.removeOverlays(Waldo); map.removeOverlays(Winterport); map.addOverlays(Belfast); centerByArray(Belfast, false, false); cntMarker += Belfast.length; map.addOverlays(Brooks); centerByArray(Brooks, false, false); cntMarker += Brooks.length; map.addOverlays(Frankfort); centerByArray(Frankfort, false, false); cntMarker += Frankfort.length; map.addOverlays(Islesboro); centerByArray(Islesboro, false, false); cntMarker += Islesboro.length; map.addOverlays(Liberty); centerByArray(Liberty, false, false); cntMarker += Liberty.length; map.addOverlays(Lincolnville); centerByArray(Lincolnville, false, false); cntMarker += Lincolnville.length; map.addOverlays(Monroe); centerByArray(Monroe, false, false); cntMarker += Monroe.length; map.addOverlays(Morrill); centerByArray(Morrill, false, false); cntMarker += Morrill.length; map.addOverlays(Northport); centerByArray(Northport, false, false); cntMarker += Northport.length; map.addOverlays(Palermo); centerByArray(Palermo, false, false); cntMarker += Palermo.length; map.addOverlays(Searsmont); centerByArray(Searsmont, false, false); cntMarker += Searsmont.length; map.addOverlays(Searsport); centerByArray(Searsport, false, false); cntMarker += Searsport.length; map.addOverlays(Stockton_Springs); centerByArray(Stockton_Springs, false, false); cntMarker += Stockton_Springs.length; map.addOverlays(Swanville); centerByArray(Swanville, false, false); cntMarker += Swanville.length; map.addOverlays(Thorndike); centerByArray(Thorndike, false, false); cntMarker += Thorndike.length; map.addOverlays(Troy); centerByArray(Troy, false, false); cntMarker += Troy.length; map.addOverlays(Unity); centerByArray(Unity, false, false); cntMarker += Unity.length; map.addOverlays(Waldo); centerByArray(Waldo, false, false); cntMarker += Waldo.length; map.addOverlays(Winterport); centerByArray(Winterport, false, false); cntMarker += Winterport.length; centerByArray(Searsmont,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'); } }