function addMarkers() { mySelect = document.getElementById('selection'); Craig = [];Hollis = [];Coffman_Cove = [];Hydaburg = [];Hyder = [];Klawock = [];Metlakatla = [];Thorne_Bay = [];mySelect.options[mySelect.options.length] = new Option("Coffman Cove schools",'all=Coffman_Cove'); mySelect.options[mySelect.options.length] = new Option("Craig schools",'all=Craig'); mySelect.options[mySelect.options.length] = new Option("Hollis schools",'all=Hollis'); mySelect.options[mySelect.options.length] = new Option("Hydaburg schools",'all=Hydaburg'); mySelect.options[mySelect.options.length] = new Option("Hyder schools",'all=Hyder'); mySelect.options[mySelect.options.length] = new Option("Klawock schools",'all=Klawock'); mySelect.options[mySelect.options.length] = new Option("Metlakatla schools",'all=Metlakatla'); mySelect.options[mySelect.options.length] = new Option("Thorne Bay schools",'all=Thorne_Bay'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Craig[Craig.length] = createMarker(new GPoint(-133.13349915,55.47909927),"
Craig Elementary School
Box 800
Craig, AK 99921

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Craig Elementary School",'Craig=' + Craig.length); Craig[Craig.length] = createMarker(new GPoint(-133.13349915,55.47909927),"
Craig High School
Box 800
Craig, AK 99921

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Craig High School",'Craig=' + Craig.length); Craig[Craig.length] = createMarker(new GPoint(-133.13349915,55.47909927),"
Craig Middle School
Box 800
Craig, AK 99921

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Craig Middle School",'Craig=' + Craig.length); Hollis[Hollis.length] = createMarker(new GPoint(-132.70046997,55.51049805),"
Hollis School
Box Hyl
Hollis, AK 99950

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Hollis School",'Hollis=' + Hollis.length); Coffman_Cove[Coffman_Cove.length] = createMarker(new GPoint(-131.69639587,55.35649872),"
Howard Valentine School
Box 18002
Coffman Cove, AK 99918

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Howard Valentine School",'Coffman_Cove=' + Coffman_Cove.length); Hydaburg[Hydaburg.length] = createMarker(new GPoint(-132.82202900,55.20497000),"
Hydaburg Elementary School
Box 109
Hydaburg, AK 99922

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Hydaburg Elementary School",'Hydaburg=' + Hydaburg.length); Hydaburg[Hydaburg.length] = createMarker(new GPoint(-132.68809509,55.20989990),"
Hydaburg Jr/sr High School
Box 109
Hydaburg, AK 99922

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Hydaburg Jr/sr High School",'Hydaburg=' + Hydaburg.length); Hyder[Hyder.length] = createMarker(new GPoint(-130.30180359,55.96950150),"
Hyder School
Po Box 110
Hyder, AK 99923

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Hyder School",'Hyder=' + Hyder.length); Klawock[Klawock.length] = createMarker(new GPoint(-133.07359314,55.55310059),"
Klawock City School
Po Box 9
Klawock, AK 99925

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Klawock City School",'Klawock=' + Klawock.length); Metlakatla[Metlakatla.length] = createMarker(new GPoint(-131.57809448,55.11059952),"
Leask Middle School
Po Box 7
Metlakatla, AK 99926

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Leask Middle School",'Metlakatla=' + Metlakatla.length); Metlakatla[Metlakatla.length] = createMarker(new GPoint(-131.57809448,55.11059952),"
Metlakatla High School
Po Box 7
Metlakatla, AK 99926

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Metlakatla High School",'Metlakatla=' + Metlakatla.length); Craig[Craig.length] = createMarker(new GPoint(-133.13349915,55.47909927),"
Pace Learning Centers
Po Box 800
Craig, AK 99921

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Pace Learning Centers",'Craig=' + Craig.length); Craig[Craig.length] = createMarker(new GPoint(-133.13349915,55.47909927),"
PACE Statewide Correspondence School
Box 800
Craig, AK 99921

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("PACE Statewide Correspondence School",'Craig=' + Craig.length); Metlakatla[Metlakatla.length] = createMarker(new GPoint(-131.57809448,55.11059952),"
Richard Johnson Elementary School
Po Box 7
Metlakatla, AK 99926

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Richard Johnson Elementary School",'Metlakatla=' + Metlakatla.length); Thorne_Bay[Thorne_Bay.length] = createMarker(new GPoint(-131.69639587,55.35649872),"
Se Island Corresp.
Box 19005
Thorne Bay, AK 99919

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Se Island Corresp.",'Thorne_Bay=' + Thorne_Bay.length); Thorne_Bay[Thorne_Bay.length] = createMarker(new GPoint(-132.52258301,55.68769455),"
Thorne Bay School
Box 5
Thorne Bay, AK 99919

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Thorne Bay School",'Thorne_Bay=' + Thorne_Bay.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(Coffman_Cove); map.removeOverlays(Craig); map.removeOverlays(Hollis); map.removeOverlays(Hydaburg); map.removeOverlays(Hyder); map.removeOverlays(Klawock); map.removeOverlays(Metlakatla); map.removeOverlays(Thorne_Bay); 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(Craig);map.removeOverlays(Coffman_Cove); map.removeOverlays(Craig); map.removeOverlays(Hollis); map.removeOverlays(Hydaburg); map.removeOverlays(Hyder); map.removeOverlays(Klawock); map.removeOverlays(Metlakatla); map.removeOverlays(Thorne_Bay); map.addOverlays(Coffman_Cove); centerByArray(Coffman_Cove, false, false); cntMarker += Coffman_Cove.length; map.addOverlays(Craig); centerByArray(Craig, false, false); cntMarker += Craig.length; map.addOverlays(Hollis); centerByArray(Hollis, false, false); cntMarker += Hollis.length; map.addOverlays(Hydaburg); centerByArray(Hydaburg, false, false); cntMarker += Hydaburg.length; map.addOverlays(Hyder); centerByArray(Hyder, false, false); cntMarker += Hyder.length; map.addOverlays(Klawock); centerByArray(Klawock, false, false); cntMarker += Klawock.length; map.addOverlays(Metlakatla); centerByArray(Metlakatla, false, false); cntMarker += Metlakatla.length; map.addOverlays(Thorne_Bay); centerByArray(Thorne_Bay, false, false); cntMarker += Thorne_Bay.length; centerByArray(Craig,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'); } }