function addMarkers() { mySelect = document.getElementById('selection'); Chenega_Bay = [];Glennallen = [];Anchorage = [];Copper_Center = [];Cordova = [];Gakona = [];Valdez = [];Mentasta_Lake = [];Slana = [];Tatitlek = [];Whittier = [];mySelect.options[mySelect.options.length] = new Option("Anchorage schools",'all=Anchorage'); mySelect.options[mySelect.options.length] = new Option("Chenega Bay schools",'all=Chenega_Bay'); mySelect.options[mySelect.options.length] = new Option("Copper Center schools",'all=Copper_Center'); mySelect.options[mySelect.options.length] = new Option("Cordova schools",'all=Cordova'); mySelect.options[mySelect.options.length] = new Option("Gakona schools",'all=Gakona'); mySelect.options[mySelect.options.length] = new Option("Glennallen schools",'all=Glennallen'); mySelect.options[mySelect.options.length] = new Option("Mentasta Lake schools",'all=Mentasta_Lake'); mySelect.options[mySelect.options.length] = new Option("Slana schools",'all=Slana'); mySelect.options[mySelect.options.length] = new Option("Tatitlek schools",'all=Tatitlek'); mySelect.options[mySelect.options.length] = new Option("Valdez schools",'all=Valdez'); mySelect.options[mySelect.options.length] = new Option("Whittier schools",'all=Whittier'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Chenega_Bay[Chenega_Bay.length] = createMarker(new GPoint(-145.26840210,60.48619843),"
Chenega Bay School
Box 8030
Chenega Bay, AK 99574

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Chenega Bay School",'Chenega_Bay=' + Chenega_Bay.length); Glennallen[Glennallen.length] = createMarker(new GPoint(-145.62950134,62.13909912),"
Chistochina School
Box 108
Glennallen, AK 99588

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Chistochina School",'Glennallen=' + Glennallen.length); Anchorage[Anchorage.length] = createMarker(new GPoint(-146.35334778,61.13074112),"
Chugach Extension Corresp.
9312 Vanguard Dr
Anchorage, AK 99507

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Chugach Extension Corresp.",'Anchorage=' + Anchorage.length); Copper_Center[Copper_Center.length] = createMarker(new GPoint(-144.70339966,61.86199951),"
Copper Center School
Drawer D
Copper Center, AK 99573

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Copper Center School",'Copper_Center=' + Copper_Center.length); Glennallen[Glennallen.length] = createMarker(new GPoint(-145.62950134,62.13909912),"
Copper River Corresp.
Box 108
Glennallen, AK 99588

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Copper River Corresp.",'Glennallen=' + Glennallen.length); Cordova[Cordova.length] = createMarker(new GPoint(-145.26840210,60.48619843),"
Cordova Jr/sr High School
Box 140
Cordova, AK 99574

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cordova Jr/sr High School",'Cordova=' + Cordova.length); Gakona[Gakona.length] = createMarker(new GPoint(-143.47920227,62.62620163),"
Gakona Elementary School
Box 228
Gakona, AK 99586

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Gakona Elementary School",'Gakona=' + Gakona.length); Valdez[Valdez.length] = createMarker(new GPoint(-146.66450500,61.05250168),"
George H Gilson Junior High School
Po Box 827
Valdez, AK 99686

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("George H Gilson Junior High School",'Valdez=' + Valdez.length); Glennallen[Glennallen.length] = createMarker(new GPoint(-145.62950134,62.13909912),"
Glennallen Elementary School
Box 108
Glennallen, AK 99588

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Glennallen Elementary School",'Glennallen=' + Glennallen.length); Glennallen[Glennallen.length] = createMarker(new GPoint(-145.62950134,62.13909912),"
Glennallen Jr/sr High School
Box 108
Glennallen, AK 99588

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Glennallen Jr/sr High School",'Glennallen=' + Glennallen.length); Valdez[Valdez.length] = createMarker(new GPoint(-146.66450500,61.05250168),"
Hermon Hutchens Elementary School
Po Box 627
Valdez, AK 99686

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Hermon Hutchens Elementary School",'Valdez=' + Valdez.length); Copper_Center[Copper_Center.length] = createMarker(new GPoint(-144.70339966,61.86199951),"
Kenny Lake School
Hc 60 Box 224
Copper Center, AK 99573

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Kenny Lake School",'Copper_Center=' + Copper_Center.length); Glennallen[Glennallen.length] = createMarker(new GPoint(-145.53964233,62.10238647),"
Lottie Sparks Elementary School
Hc 01box 2330
Glennallen, AK 99588

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lottie Sparks Elementary School",'Glennallen=' + Glennallen.length); Mentasta_Lake[Mentasta_Lake.length] = createMarker(new GPoint(-142.34080505,63.55899811),"
Mentasta Lake School
Box 6039
Mentasta Lake, AK 99780

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Mentasta Lake School",'Mentasta_Lake=' + Mentasta_Lake.length); Cordova[Cordova.length] = createMarker(new GPoint(-145.26840210,60.48619843),"
Mt. Eccles Elementary School
Box 140
Cordova, AK 99574

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mt. Eccles Elementary School",'Cordova=' + Cordova.length); Slana[Slana.length] = createMarker(new GPoint(-143.47920227,62.62620163),"
Slana School
Hc 60 Box 1002
Slana, AK 99586

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Slana School",'Slana=' + Slana.length); Tatitlek[Tatitlek.length] = createMarker(new GPoint(-147.37019348,60.88439941),"
Tatitlek Community School
Po Box 167
Tatitlek, AK 99677

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Tatitlek Community School",'Tatitlek=' + Tatitlek.length); Valdez[Valdez.length] = createMarker(new GPoint(-146.66450500,61.05250168),"
Valdez High School
Po Box 1629
Valdez, AK 99686

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Valdez High School",'Valdez=' + Valdez.length); Whittier[Whittier.length] = createMarker(new GPoint(-147.11120605,61.10449982),"
Whittier Community School
Box 638
Whittier, AK 99693

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Whittier Community School",'Whittier=' + Whittier.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(Anchorage); map.removeOverlays(Chenega_Bay); map.removeOverlays(Copper_Center); map.removeOverlays(Cordova); map.removeOverlays(Gakona); map.removeOverlays(Glennallen); map.removeOverlays(Mentasta_Lake); map.removeOverlays(Slana); map.removeOverlays(Tatitlek); map.removeOverlays(Valdez); map.removeOverlays(Whittier); 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(Chenega_Bay);map.removeOverlays(Anchorage); map.removeOverlays(Chenega_Bay); map.removeOverlays(Copper_Center); map.removeOverlays(Cordova); map.removeOverlays(Gakona); map.removeOverlays(Glennallen); map.removeOverlays(Mentasta_Lake); map.removeOverlays(Slana); map.removeOverlays(Tatitlek); map.removeOverlays(Valdez); map.removeOverlays(Whittier); map.addOverlays(Anchorage); centerByArray(Anchorage, false, false); cntMarker += Anchorage.length; map.addOverlays(Chenega_Bay); centerByArray(Chenega_Bay, false, false); cntMarker += Chenega_Bay.length; map.addOverlays(Copper_Center); centerByArray(Copper_Center, false, false); cntMarker += Copper_Center.length; map.addOverlays(Cordova); centerByArray(Cordova, false, false); cntMarker += Cordova.length; map.addOverlays(Gakona); centerByArray(Gakona, false, false); cntMarker += Gakona.length; map.addOverlays(Glennallen); centerByArray(Glennallen, false, false); cntMarker += Glennallen.length; map.addOverlays(Mentasta_Lake); centerByArray(Mentasta_Lake, false, false); cntMarker += Mentasta_Lake.length; map.addOverlays(Slana); centerByArray(Slana, false, false); cntMarker += Slana.length; map.addOverlays(Tatitlek); centerByArray(Tatitlek, false, false); cntMarker += Tatitlek.length; map.addOverlays(Valdez); centerByArray(Valdez, false, false); cntMarker += Valdez.length; map.addOverlays(Whittier); centerByArray(Whittier, false, false); cntMarker += Whittier.length; centerByArray(Chenega_Bay,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'); } }