function addMarkers()
{
mySelect = document.getElementById('selection');
Akiachak = [];Akiak = [];Kasigluk = [];Aniak = [];Nunapitchuk = [];Platinum = [];Bethel = [];Newtok = [];Chefornak = [];Kipnuk = [];Chuathbaluk = [];Kongiganak = [];Eek = [];Kalskag = [];Red_Devil = [];Stony_River = [];Sleetmute = [];Atmautluak = [];Crooked_Creek = [];Kwethluk = [];Quinhagak = [];Kwigillingok = [];Tuntutuliak = [];Toksook_Bay = [];Nightmute = [];Mekoryuk = [];Tununak = [];Napaskiak = [];Goodnews_Bay = [];Tuluksak = [];Napakiak = [];Lower_Kalskag = [];mySelect.options[mySelect.options.length] = new Option("Akiachak schools",'all=Akiachak');
mySelect.options[mySelect.options.length] = new Option("Akiak schools",'all=Akiak');
mySelect.options[mySelect.options.length] = new Option("Aniak schools",'all=Aniak');
mySelect.options[mySelect.options.length] = new Option("Atmautluak schools",'all=Atmautluak');
mySelect.options[mySelect.options.length] = new Option("Bethel schools",'all=Bethel');
mySelect.options[mySelect.options.length] = new Option("Chefornak schools",'all=Chefornak');
mySelect.options[mySelect.options.length] = new Option("Chuathbaluk schools",'all=Chuathbaluk');
mySelect.options[mySelect.options.length] = new Option("Crooked Creek schools",'all=Crooked_Creek');
mySelect.options[mySelect.options.length] = new Option("Eek schools",'all=Eek');
mySelect.options[mySelect.options.length] = new Option("Goodnews Bay schools",'all=Goodnews_Bay');
mySelect.options[mySelect.options.length] = new Option("Kalskag schools",'all=Kalskag');
mySelect.options[mySelect.options.length] = new Option("Kasigluk schools",'all=Kasigluk');
mySelect.options[mySelect.options.length] = new Option("Kipnuk schools",'all=Kipnuk');
mySelect.options[mySelect.options.length] = new Option("Kongiganak schools",'all=Kongiganak');
mySelect.options[mySelect.options.length] = new Option("Kwethluk schools",'all=Kwethluk');
mySelect.options[mySelect.options.length] = new Option("Kwigillingok schools",'all=Kwigillingok');
mySelect.options[mySelect.options.length] = new Option("Lower Kalskag schools",'all=Lower_Kalskag');
mySelect.options[mySelect.options.length] = new Option("Mekoryuk schools",'all=Mekoryuk');
mySelect.options[mySelect.options.length] = new Option("Napakiak schools",'all=Napakiak');
mySelect.options[mySelect.options.length] = new Option("Napaskiak schools",'all=Napaskiak');
mySelect.options[mySelect.options.length] = new Option("Newtok schools",'all=Newtok');
mySelect.options[mySelect.options.length] = new Option("Nightmute schools",'all=Nightmute');
mySelect.options[mySelect.options.length] = new Option("Nunapitchuk schools",'all=Nunapitchuk');
mySelect.options[mySelect.options.length] = new Option("Platinum schools",'all=Platinum');
mySelect.options[mySelect.options.length] = new Option("Quinhagak schools",'all=Quinhagak');
mySelect.options[mySelect.options.length] = new Option("Red Devil schools",'all=Red_Devil');
mySelect.options[mySelect.options.length] = new Option("Sleetmute schools",'all=Sleetmute');
mySelect.options[mySelect.options.length] = new Option("Stony River schools",'all=Stony_River');
mySelect.options[mySelect.options.length] = new Option("Toksook Bay schools",'all=Toksook_Bay');
mySelect.options[mySelect.options.length] = new Option("Tuluksak schools",'all=Tuluksak');
mySelect.options[mySelect.options.length] = new Option("Tuntutuliak schools",'all=Tuntutuliak');
mySelect.options[mySelect.options.length] = new Option("Tununak schools",'all=Tununak');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Akiachak[Akiachak.length] = createMarker(new GPoint(-161.39230347,60.88980103),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Akiachak School",'Akiachak=' + Akiachak.length);
Akiak[Akiak.length] = createMarker(new GPoint(-161.21435547,60.91102600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Akiak School",'Akiak=' + Akiak.length);
Kasigluk[Kasigluk.length] = createMarker(new GPoint(-161.63720703,60.84379959),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Akiuk Memorial School",'Kasigluk=' + Kasigluk.length);
Kasigluk[Kasigluk.length] = createMarker(new GPoint(-161.63720703,60.84379959),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Akula Elitnaurvik School",'Kasigluk=' + Kasigluk.length);
Aniak[Aniak.length] = createMarker(new GPoint(-157.38079834,61.74179840),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Aniak High School",'Aniak=' + Aniak.length);
Aniak[Aniak.length] = createMarker(new GPoint(-157.38079834,61.74179840),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Aniak Middle School",'Aniak=' + Aniak.length);
Nunapitchuk[Nunapitchuk.length] = createMarker(new GPoint(-161.63720703,60.84379959),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Anna Tobeluk Memorial School",'Nunapitchuk=' + Nunapitchuk.length);
Platinum[Platinum.length] = createMarker(new GPoint(-161.76040649,58.94459915),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Arviq School",'Platinum=' + Platinum.length);
Aniak[Aniak.length] = createMarker(new GPoint(-157.38079834,61.74179840),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Auntie Mary Nicoli Elementary School",'Aniak=' + Aniak.length);
Bethel[Bethel.length] = createMarker(new GPoint(-161.41059875,60.85309982),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ayaprun Elitnaurvik Yup’ik Immersion Elementary School",'Bethel=' + Bethel.length);
Newtok[Newtok.length] = createMarker(new GPoint(-164.62944031,60.94277954),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ayaprun School",'Newtok=' + Newtok.length);
Bethel[Bethel.length] = createMarker(new GPoint(-161.41059875,60.85309982),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethel Alternative Boarding School",'Bethel=' + Bethel.length);
Bethel[Bethel.length] = createMarker(new GPoint(-161.41059875,60.85309982),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethel Regional High School",'Bethel=' + Bethel.length);
Bethel[Bethel.length] = createMarker(new GPoint(-161.41059875,60.85309982),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethel Youth Facility",'Bethel=' + Bethel.length);
Chefornak[Chefornak.length] = createMarker(new GPoint(-164.19419861,60.16849899),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chaptnguak School",'Chefornak=' + Chefornak.length);
Kipnuk[Kipnuk.length] = createMarker(new GPoint(-164.05209351,59.93230057),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chief Paul Memorial School",'Kipnuk=' + Kipnuk.length);
Chuathbaluk[Chuathbaluk.length] = createMarker(new GPoint(-157.38079834,61.74179840),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Crow Village Sam School",'Chuathbaluk=' + Chuathbaluk.length);
Kongiganak[Kongiganak.length] = createMarker(new GPoint(-161.41059875,60.85309982),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Dick R Kiunya Memorial School",'Kongiganak=' + Kongiganak.length);
Eek[Eek.length] = createMarker(new GPoint(-161.91720581,59.74980164),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eek School",'Eek=' + Eek.length);
Kalskag[Kalskag.length] = createMarker(new GPoint(-160.32260132,61.53889847),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("George Morgan Senior High School",'Kalskag=' + Kalskag.length);
Red_Devil[Red_Devil.length] = createMarker(new GPoint(-157.16870117,61.70309830),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("George Willis Sr. School",'Red_Devil=' + Red_Devil.length);
Stony_River[Stony_River.length] = createMarker(new GPoint(-157.38079834,61.74179840),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gusty Michael School",'Stony_River=' + Stony_River.length);
Sleetmute[Sleetmute.length] = createMarker(new GPoint(-157.01339722,61.54589844),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jack Egnaty Sr. School",'Sleetmute=' + Sleetmute.length);
Atmautluak[Atmautluak.length] = createMarker(new GPoint(-161.41059875,60.85309982),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Joann A. Alexie Memorial School",'Atmautluak=' + Atmautluak.length);
Crooked_Creek[Crooked_Creek.length] = createMarker(new GPoint(-157.93699646,61.80649948),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Johnnie John Sr. School",'Crooked_Creek=' + Crooked_Creek.length);
Kalskag[Kalskag.length] = createMarker(new GPoint(-160.32260132,61.53889847),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Joseph S. & Olinga Gregory Elementary School",'Kalskag=' + Kalskag.length);
Kwethluk[Kwethluk.length] = createMarker(new GPoint(-10.00000000,10.00000000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ket'acik/aapalluk Memorial School",'Kwethluk=' + Kwethluk.length);
Bethel[Bethel.length] = createMarker(new GPoint(-161.41059875,60.85309982),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kilbuck Elementary School",'Bethel=' + Bethel.length);
Quinhagak[Quinhagak.length] = createMarker(new GPoint(-161.76159668,59.64099884),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kuinerrarmiut Elitnaurviat",'Quinhagak=' + Quinhagak.length);
Kwigillingok[Kwigillingok.length] = createMarker(new GPoint(-163.10409546,59.87490082),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kwigillingok School",'Kwigillingok=' + Kwigillingok.length);
Tuntutuliak[Tuntutuliak.length] = createMarker(new GPoint(-161.63720703,60.84379959),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lewis Angapak Memorial School",'Tuntutuliak=' + Tuntutuliak.length);
Bethel[Bethel.length] = createMarker(new GPoint(-161.41059875,60.85309982),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mikelnguut Elitnaurviat Elementary School",'Bethel=' + Bethel.length);
Toksook_Bay[Toksook_Bay.length] = createMarker(new GPoint(-165.09700012,60.53699875),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Nelson Island Area School",'Toksook_Bay=' + Toksook_Bay.length);
Nightmute[Nightmute.length] = createMarker(new GPoint(-161.63720703,60.84379959),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Nightmute School",'Nightmute=' + Nightmute.length);
Mekoryuk[Mekoryuk.length] = createMarker(new GPoint(-166.00860596,60.19340134),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Nuniwaarmiut School",'Mekoryuk=' + Mekoryuk.length);
Tununak[Tununak.length] = createMarker(new GPoint(-165.11680603,60.54610062),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Paul T. Albert Memorial School",'Tununak=' + Tununak.length);
Napaskiak[Napaskiak.length] = createMarker(new GPoint(-161.41059875,60.85309982),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Qugcuun Memorial School",'Napaskiak=' + Napaskiak.length);
Goodnews_Bay[Goodnews_Bay.length] = createMarker(new GPoint(-161.56489563,59.11420059),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rocky Mountain School",'Goodnews_Bay=' + Goodnews_Bay.length);
Tuluksak[Tuluksak.length] = createMarker(new GPoint(-160.95889282,61.09889984),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tuluksak School",'Tuluksak=' + Tuluksak.length);
Napakiak[Napakiak.length] = createMarker(new GPoint(-161.76069641,60.66680145),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("William Miller Memorial School",'Napakiak=' + Napakiak.length);
Napaskiak[Napaskiak.length] = createMarker(new GPoint(-161.41059875,60.85309982),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Z. John Williams Memorial School",'Napaskiak=' + Napaskiak.length);
Lower_Kalskag[Lower_Kalskag.length] = createMarker(new GPoint(-160.35690308,61.51509857),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Zackar Levi Elementary School",'Lower_Kalskag=' + Lower_Kalskag.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(Akiachak);
map.removeOverlays(Akiak);
map.removeOverlays(Aniak);
map.removeOverlays(Atmautluak);
map.removeOverlays(Bethel);
map.removeOverlays(Chefornak);
map.removeOverlays(Chuathbaluk);
map.removeOverlays(Crooked_Creek);
map.removeOverlays(Eek);
map.removeOverlays(Goodnews_Bay);
map.removeOverlays(Kalskag);
map.removeOverlays(Kasigluk);
map.removeOverlays(Kipnuk);
map.removeOverlays(Kongiganak);
map.removeOverlays(Kwethluk);
map.removeOverlays(Kwigillingok);
map.removeOverlays(Lower_Kalskag);
map.removeOverlays(Mekoryuk);
map.removeOverlays(Napakiak);
map.removeOverlays(Napaskiak);
map.removeOverlays(Newtok);
map.removeOverlays(Nightmute);
map.removeOverlays(Nunapitchuk);
map.removeOverlays(Platinum);
map.removeOverlays(Quinhagak);
map.removeOverlays(Red_Devil);
map.removeOverlays(Sleetmute);
map.removeOverlays(Stony_River);
map.removeOverlays(Toksook_Bay);
map.removeOverlays(Tuluksak);
map.removeOverlays(Tuntutuliak);
map.removeOverlays(Tununak);
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(Akiachak);map.removeOverlays(Akiachak);
map.removeOverlays(Akiak);
map.removeOverlays(Aniak);
map.removeOverlays(Atmautluak);
map.removeOverlays(Bethel);
map.removeOverlays(Chefornak);
map.removeOverlays(Chuathbaluk);
map.removeOverlays(Crooked_Creek);
map.removeOverlays(Eek);
map.removeOverlays(Goodnews_Bay);
map.removeOverlays(Kalskag);
map.removeOverlays(Kasigluk);
map.removeOverlays(Kipnuk);
map.removeOverlays(Kongiganak);
map.removeOverlays(Kwethluk);
map.removeOverlays(Kwigillingok);
map.removeOverlays(Lower_Kalskag);
map.removeOverlays(Mekoryuk);
map.removeOverlays(Napakiak);
map.removeOverlays(Napaskiak);
map.removeOverlays(Newtok);
map.removeOverlays(Nightmute);
map.removeOverlays(Nunapitchuk);
map.removeOverlays(Platinum);
map.removeOverlays(Quinhagak);
map.removeOverlays(Red_Devil);
map.removeOverlays(Sleetmute);
map.removeOverlays(Stony_River);
map.removeOverlays(Toksook_Bay);
map.removeOverlays(Tuluksak);
map.removeOverlays(Tuntutuliak);
map.removeOverlays(Tununak);
map.addOverlays(Akiachak);
centerByArray(Akiachak, false, false);
cntMarker += Akiachak.length;
map.addOverlays(Akiak);
centerByArray(Akiak, false, false);
cntMarker += Akiak.length;
map.addOverlays(Aniak);
centerByArray(Aniak, false, false);
cntMarker += Aniak.length;
map.addOverlays(Atmautluak);
centerByArray(Atmautluak, false, false);
cntMarker += Atmautluak.length;
map.addOverlays(Bethel);
centerByArray(Bethel, false, false);
cntMarker += Bethel.length;
map.addOverlays(Chefornak);
centerByArray(Chefornak, false, false);
cntMarker += Chefornak.length;
map.addOverlays(Chuathbaluk);
centerByArray(Chuathbaluk, false, false);
cntMarker += Chuathbaluk.length;
map.addOverlays(Crooked_Creek);
centerByArray(Crooked_Creek, false, false);
cntMarker += Crooked_Creek.length;
map.addOverlays(Eek);
centerByArray(Eek, false, false);
cntMarker += Eek.length;
map.addOverlays(Goodnews_Bay);
centerByArray(Goodnews_Bay, false, false);
cntMarker += Goodnews_Bay.length;
map.addOverlays(Kalskag);
centerByArray(Kalskag, false, false);
cntMarker += Kalskag.length;
map.addOverlays(Kasigluk);
centerByArray(Kasigluk, false, false);
cntMarker += Kasigluk.length;
map.addOverlays(Kipnuk);
centerByArray(Kipnuk, false, false);
cntMarker += Kipnuk.length;
map.addOverlays(Kongiganak);
centerByArray(Kongiganak, false, false);
cntMarker += Kongiganak.length;
map.addOverlays(Kwethluk);
centerByArray(Kwethluk, false, false);
cntMarker += Kwethluk.length;
map.addOverlays(Kwigillingok);
centerByArray(Kwigillingok, false, false);
cntMarker += Kwigillingok.length;
map.addOverlays(Lower_Kalskag);
centerByArray(Lower_Kalskag, false, false);
cntMarker += Lower_Kalskag.length;
map.addOverlays(Mekoryuk);
centerByArray(Mekoryuk, false, false);
cntMarker += Mekoryuk.length;
map.addOverlays(Napakiak);
centerByArray(Napakiak, false, false);
cntMarker += Napakiak.length;
map.addOverlays(Napaskiak);
centerByArray(Napaskiak, false, false);
cntMarker += Napaskiak.length;
map.addOverlays(Newtok);
centerByArray(Newtok, false, false);
cntMarker += Newtok.length;
map.addOverlays(Nightmute);
centerByArray(Nightmute, false, false);
cntMarker += Nightmute.length;
map.addOverlays(Nunapitchuk);
centerByArray(Nunapitchuk, false, false);
cntMarker += Nunapitchuk.length;
map.addOverlays(Platinum);
centerByArray(Platinum, false, false);
cntMarker += Platinum.length;
map.addOverlays(Quinhagak);
centerByArray(Quinhagak, false, false);
cntMarker += Quinhagak.length;
map.addOverlays(Red_Devil);
centerByArray(Red_Devil, false, false);
cntMarker += Red_Devil.length;
map.addOverlays(Sleetmute);
centerByArray(Sleetmute, false, false);
cntMarker += Sleetmute.length;
map.addOverlays(Stony_River);
centerByArray(Stony_River, false, false);
cntMarker += Stony_River.length;
map.addOverlays(Toksook_Bay);
centerByArray(Toksook_Bay, false, false);
cntMarker += Toksook_Bay.length;
map.addOverlays(Tuluksak);
centerByArray(Tuluksak, false, false);
cntMarker += Tuluksak.length;
map.addOverlays(Tuntutuliak);
centerByArray(Tuntutuliak, false, false);
cntMarker += Tuntutuliak.length;
map.addOverlays(Tununak);
centerByArray(Tununak, false, false);
cntMarker += Tununak.length;
centerByArray(Akiachak,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');
}
}