function addMarkers() { mySelect = document.getElementById('selection'); Union = [];Rockport = [];Camden = [];Cushing = [];Friendship = [];Thomaston = [];South_Thomaston = [];Hope = [];Isle_Au_Haut = [];Rockland = [];Matinicus = [];North_Haven = [];Owls_Head = [];Washington = [];Tenants_Harbor = [];Vinalhaven = [];Warren = [];mySelect.options[mySelect.options.length] = new Option("Camden schools",'all=Camden'); mySelect.options[mySelect.options.length] = new Option("Cushing schools",'all=Cushing'); mySelect.options[mySelect.options.length] = new Option("Friendship schools",'all=Friendship'); mySelect.options[mySelect.options.length] = new Option("Hope schools",'all=Hope'); mySelect.options[mySelect.options.length] = new Option("Isle Au Haut schools",'all=Isle_Au_Haut'); mySelect.options[mySelect.options.length] = new Option("Matinicus schools",'all=Matinicus'); mySelect.options[mySelect.options.length] = new Option("North Haven schools",'all=North_Haven'); mySelect.options[mySelect.options.length] = new Option("Owls Head schools",'all=Owls_Head'); mySelect.options[mySelect.options.length] = new Option("Rockland schools",'all=Rockland'); mySelect.options[mySelect.options.length] = new Option("Rockport schools",'all=Rockport'); mySelect.options[mySelect.options.length] = new Option("South Thomaston schools",'all=South_Thomaston'); mySelect.options[mySelect.options.length] = new Option("Tenants Harbor schools",'all=Tenants_Harbor'); mySelect.options[mySelect.options.length] = new Option("Thomaston schools",'all=Thomaston'); mySelect.options[mySelect.options.length] = new Option("Union schools",'all=Union'); mySelect.options[mySelect.options.length] = new Option("Vinalhaven schools",'all=Vinalhaven'); mySelect.options[mySelect.options.length] = new Option("Warren schools",'all=Warren'); mySelect.options[mySelect.options.length] = new Option("Washington schools",'all=Washington'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Union[Union.length] = createMarker(new GPoint(-69.26715851,44.27288437),"
Appleton Village School
737 Union Road
Union, ME 04862

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Appleton Village School",'Union=' + Union.length); Rockport[Rockport.length] = createMarker(new GPoint(-69.08660126,44.18980026),"
Camden Hills Regional High School
25 Keelson Drive
Rockport, ME 04856

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Camden Hills Regional High School",'Rockport=' + Rockport.length); Camden[Camden.length] = createMarker(new GPoint(-69.07099152,44.21146011),"
Camden-rockport Middle School
34 Knowlton Street
Camden, ME 04843

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Camden-rockport Middle School",'Camden=' + Camden.length); Cushing[Cushing.length] = createMarker(new GPoint(-69.24925995,44.02110291),"
Cushing Community School
54 Cross Road
Cushing, ME 04563

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Cushing Community School",'Cushing=' + Cushing.length); Rockport[Rockport.length] = createMarker(new GPoint(-69.09919739,44.16930008),"
Elm Street School
Po Box 9
Rockport, ME 04856

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Elm Street School",'Rockport=' + Rockport.length); Friendship[Friendship.length] = createMarker(new GPoint(-69.33046722,43.98496246),"
Friendship Village School
23 School St Po Box 100
Friendship, ME 04547

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Friendship Village School",'Friendship=' + Friendship.length); Thomaston[Thomaston.length] = createMarker(new GPoint(-69.18557739,44.08064651),"
Georges Valley High School
47 Valley Street
Thomaston, ME 04861

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Georges Valley High School",'Thomaston=' + Thomaston.length); South_Thomaston[South_Thomaston.length] = createMarker(new GPoint(-69.12914276,44.05054474),"
Gilford Butler School
54 Spruce Head Rd Po Box 146
South Thomaston, ME 04858

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Gilford Butler School",'South_Thomaston=' + South_Thomaston.length); Hope[Hope.length] = createMarker(new GPoint(-69.22319031,44.22357941),"
Hope Elementary School
34 Highfield Road
Hope, ME 04847

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Hope Elementary School",'Hope=' + Hope.length); Isle_Au_Haut[Isle_Au_Haut.length] = createMarker(new GPoint(-68.62229919,44.06940079),"
Isle Au Haut Rural School
Po Box 56b
Isle Au Haut, ME 04645

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Isle Au Haut Rural School",'Isle_Au_Haut=' + Isle_Au_Haut.length); Thomaston[Thomaston.length] = createMarker(new GPoint(-69.18814850,44.08036423),"
Lura Libby School
13 Valley Street
Thomaston, ME 04861

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lura Libby School",'Thomaston=' + Thomaston.length); Rockland[Rockland.length] = createMarker(new GPoint(-69.11499786,44.11233521),"
Macdougal School
338 Broadway
Rockland, ME 04841

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Macdougal School",'Rockland=' + Rockland.length); Matinicus[Matinicus.length] = createMarker(new GPoint(-68.89089966,43.85639954),"
Matinicus Elementary School
Po Box 194
Matinicus, ME 04851

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Matinicus Elementary School",'Matinicus=' + Matinicus.length); Rockland[Rockland.length] = createMarker(new GPoint(-69.10990143,44.09000015),"
Mid-coast School Of Tech-region 8
One Main Street
Rockland, ME 04841

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Mid-coast School Of Tech-region 8",'Rockland=' + Rockland.length); North_Haven[North_Haven.length] = createMarker(new GPoint(-68.86710358,44.15010071),"
North Haven Community School
Rr 1 Box 699
North Haven, ME 04853

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("North Haven Community School",'North_Haven=' + North_Haven.length); Owls_Head[Owls_Head.length] = createMarker(new GPoint(-69.10102081,44.07529831),"
Owls Head Central School
54 Ash Point Drive
Owls Head, ME 04854

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Owls Head Central School",'Owls_Head=' + Owls_Head.length); Washington[Washington.length] = createMarker(new GPoint(-69.37187195,44.26793671),"
Prescott Memorial School
100 Waldoboro Road
Washington, ME 04574

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Prescott Memorial School",'Washington=' + Washington.length); Rockland[Rockland.length] = createMarker(new GPoint(-69.11290741,44.11526871),"
Rockland District High School
400 Broadway
Rockland, ME 04841

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Rockland District High School",'Rockland=' + Rockland.length); Rockland[Rockland.length] = createMarker(new GPoint(-69.11602783,44.09585190),"
Rockland District Middle School
30 Broadway
Rockland, ME 04841

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Rockland District Middle School",'Rockland=' + Rockland.length); Rockport[Rockport.length] = createMarker(new GPoint(-69.07701111,44.18371964),"
Rockport Elementary School
West St Po Box 9
Rockport, ME 04856

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Rockport Elementary School",'Rockport=' + Rockport.length); Rockland[Rockland.length] = createMarker(new GPoint(-69.11643219,44.09672165),"
South School
100 Holmes Street
Rockland, ME 04841

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("South School",'Rockland=' + Rockland.length); Tenants_Harbor[Tenants_Harbor.length] = createMarker(new GPoint(-69.20937347,43.96638107),"
St George School
65 Main St Po Box 153
Tenants Harbor, ME 04860

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("St George School",'Tenants_Harbor=' + Tenants_Harbor.length); Thomaston[Thomaston.length] = createMarker(new GPoint(-69.18318939,44.08100510),"
Thomaston Grammar School
65 Watts Lane
Thomaston, ME 04861

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Thomaston Grammar School",'Thomaston=' + Thomaston.length); Union[Union.length] = createMarker(new GPoint(-69.25688934,44.21136856),"
Union Elementary & Gaul Middle Schs
1070 Heald Highway
Union, ME 04862

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Union Elementary & Gaul Middle Schs",'Union=' + Union.length); Vinalhaven[Vinalhaven.length] = createMarker(new GPoint(-68.84380341,44.03430176),"
Vinalhaven School
Rr 1 Box 112
Vinalhaven, ME 04863

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Vinalhaven School",'Vinalhaven=' + Vinalhaven.length); Warren[Warren.length] = createMarker(new GPoint(-69.23985291,44.12667847),"
Warren Community School
117 Eastern Road
Warren, ME 04864

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Warren Community School",'Warren=' + Warren.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(Camden); map.removeOverlays(Cushing); map.removeOverlays(Friendship); map.removeOverlays(Hope); map.removeOverlays(Isle_Au_Haut); map.removeOverlays(Matinicus); map.removeOverlays(North_Haven); map.removeOverlays(Owls_Head); map.removeOverlays(Rockland); map.removeOverlays(Rockport); map.removeOverlays(South_Thomaston); map.removeOverlays(Tenants_Harbor); map.removeOverlays(Thomaston); map.removeOverlays(Union); map.removeOverlays(Vinalhaven); map.removeOverlays(Warren); map.removeOverlays(Washington); 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(Union);map.removeOverlays(Camden); map.removeOverlays(Cushing); map.removeOverlays(Friendship); map.removeOverlays(Hope); map.removeOverlays(Isle_Au_Haut); map.removeOverlays(Matinicus); map.removeOverlays(North_Haven); map.removeOverlays(Owls_Head); map.removeOverlays(Rockland); map.removeOverlays(Rockport); map.removeOverlays(South_Thomaston); map.removeOverlays(Tenants_Harbor); map.removeOverlays(Thomaston); map.removeOverlays(Union); map.removeOverlays(Vinalhaven); map.removeOverlays(Warren); map.removeOverlays(Washington); map.addOverlays(Camden); centerByArray(Camden, false, false); cntMarker += Camden.length; map.addOverlays(Cushing); centerByArray(Cushing, false, false); cntMarker += Cushing.length; map.addOverlays(Friendship); centerByArray(Friendship, false, false); cntMarker += Friendship.length; map.addOverlays(Hope); centerByArray(Hope, false, false); cntMarker += Hope.length; map.addOverlays(Isle_Au_Haut); centerByArray(Isle_Au_Haut, false, false); cntMarker += Isle_Au_Haut.length; map.addOverlays(Matinicus); centerByArray(Matinicus, false, false); cntMarker += Matinicus.length; map.addOverlays(North_Haven); centerByArray(North_Haven, false, false); cntMarker += North_Haven.length; map.addOverlays(Owls_Head); centerByArray(Owls_Head, false, false); cntMarker += Owls_Head.length; map.addOverlays(Rockland); centerByArray(Rockland, false, false); cntMarker += Rockland.length; map.addOverlays(Rockport); centerByArray(Rockport, false, false); cntMarker += Rockport.length; map.addOverlays(South_Thomaston); centerByArray(South_Thomaston, false, false); cntMarker += South_Thomaston.length; map.addOverlays(Tenants_Harbor); centerByArray(Tenants_Harbor, false, false); cntMarker += Tenants_Harbor.length; map.addOverlays(Thomaston); centerByArray(Thomaston, false, false); cntMarker += Thomaston.length; map.addOverlays(Union); centerByArray(Union, false, false); cntMarker += Union.length; map.addOverlays(Vinalhaven); centerByArray(Vinalhaven, false, false); cntMarker += Vinalhaven.length; map.addOverlays(Warren); centerByArray(Warren, false, false); cntMarker += Warren.length; map.addOverlays(Washington); centerByArray(Washington, false, false); cntMarker += Washington.length; centerByArray(Union,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'); } }