function addMarkers() { mySelect = document.getElementById('selection'); Elim = [];St_Michael = [];Nome = [];Brevig_Mission = [];Diomede = [];Gambell = [];Savoonga = [];Teller = [];Koyuk = [];Golovin = [];Shaktoolik = [];Shishmaref = [];Stebbins = [];Unalakleet = [];Wales = [];White_Mountain = [];mySelect.options[mySelect.options.length] = new Option("Brevig Mission schools",'all=Brevig_Mission'); mySelect.options[mySelect.options.length] = new Option("Diomede schools",'all=Diomede'); mySelect.options[mySelect.options.length] = new Option("Elim schools",'all=Elim'); mySelect.options[mySelect.options.length] = new Option("Gambell schools",'all=Gambell'); mySelect.options[mySelect.options.length] = new Option("Golovin schools",'all=Golovin'); mySelect.options[mySelect.options.length] = new Option("Koyuk schools",'all=Koyuk'); mySelect.options[mySelect.options.length] = new Option("Nome schools",'all=Nome'); mySelect.options[mySelect.options.length] = new Option("Savoonga schools",'all=Savoonga'); mySelect.options[mySelect.options.length] = new Option("Shaktoolik schools",'all=Shaktoolik'); mySelect.options[mySelect.options.length] = new Option("Shishmaref schools",'all=Shishmaref'); mySelect.options[mySelect.options.length] = new Option("St Michael schools",'all=St_Michael'); mySelect.options[mySelect.options.length] = new Option("Stebbins schools",'all=Stebbins'); mySelect.options[mySelect.options.length] = new Option("Teller schools",'all=Teller'); mySelect.options[mySelect.options.length] = new Option("Unalakleet schools",'all=Unalakleet'); mySelect.options[mySelect.options.length] = new Option("Wales schools",'all=Wales'); mySelect.options[mySelect.options.length] = new Option("White Mountain schools",'all=White_Mountain'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Elim[Elim.length] = createMarker(new GPoint(-162.26101685,64.62030029),"
Aniguiin School
Po Box 29
Elim, AK 99739

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Aniguiin School",'Elim=' + Elim.length); St_Michael[St_Michael.length] = createMarker(new GPoint(-162.06956482,63.47685623),"
Anthony A. Andrews School
100 Baker Street
St. Michael, AK 99659

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Anthony A. Andrews School",'St_Michael=' + St_Michael.length); Nome[Nome.length] = createMarker(new GPoint(-165.27229309,64.78730011),"
Anvil City Science Academy
Po Box 1147
Nome, AK 99762

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Anvil City Science Academy",'Nome=' + Nome.length); Brevig_Mission[Brevig_Mission.length] = createMarker(new GPoint(-162.74549866,67.74009705),"
Brevig Mission School
General Delivery
Brevig Mission, AK 99785

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Brevig Mission School",'Brevig_Mission=' + Brevig_Mission.length); Diomede[Diomede.length] = createMarker(new GPoint(-165.27229309,64.78730011),"
Diomede School
Po Box 7099
Diomede, AK 99762

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Diomede School",'Diomede=' + Diomede.length); Gambell[Gambell.length] = createMarker(new GPoint(-171.72030640,63.77259827),"
Gambell School
Po Box 169
Gambell, AK 99742

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Gambell School",'Gambell=' + Gambell.length); Savoonga[Savoonga.length] = createMarker(new GPoint(-170.70970154,63.66979980),"
Hogarth Kingeekuk Memorial School
Po Box 200
Savoonga, AK 99769

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Hogarth Kingeekuk Memorial School",'Savoonga=' + Savoonga.length); Teller[Teller.length] = createMarker(new GPoint(-166.36251831,65.26306152),"
James C. Isabell School
100 Airport Avenue
Teller, AK 99778

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("James C. Isabell School",'Teller=' + Teller.length); Koyuk[Koyuk.length] = createMarker(new GPoint(-161.15660095,64.93389893),"
Koyuk-malemute School
Po Box 53009
Koyuk, AK 99753

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Koyuk-malemute School",'Koyuk=' + Koyuk.length); Nome[Nome.length] = createMarker(new GPoint(-165.27229309,64.78730011),"
Leonard Seppala Alternative High School
Box 131
Nome, AK 99762

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Leonard Seppala Alternative High School",'Nome=' + Nome.length); Golovin[Golovin.length] = createMarker(new GPoint(-165.27229309,64.78730011),"
Martin L. Olson School
Po Box 62040
Golovin, AK 99762

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Martin L. Olson School",'Golovin=' + Golovin.length); Nome[Nome.length] = createMarker(new GPoint(-165.27229309,64.78730011),"
Nome Correspondence
Box 131
Nome, AK 99762

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Nome Correspondence",'Nome=' + Nome.length); Nome[Nome.length] = createMarker(new GPoint(-165.27229309,64.78730011),"
Nome Elementary School
Box 131
Nome, AK 99762

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Nome Elementary School",'Nome=' + Nome.length); Nome[Nome.length] = createMarker(new GPoint(-165.27229309,64.78730011),"
Nome Youth Facility
Box 131
Nome, AK 99762

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Nome Youth Facility",'Nome=' + Nome.length); Nome[Nome.length] = createMarker(new GPoint(-165.27229309,64.78730011),"
Nome-beltz Jr/sr High School
Box 131
Nome, AK 99762

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Nome-beltz Jr/sr High School",'Nome=' + Nome.length); Shaktoolik[Shaktoolik.length] = createMarker(new GPoint(-161.15132141,64.32871246),"
Shaktoolik School
Po Box 40
Shaktoolik, AK 99771

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Shaktoolik School",'Shaktoolik=' + Shaktoolik.length); Shishmaref[Shishmaref.length] = createMarker(new GPoint(-165.98519897,65.98439789),"
Shishmaref School
1 Seaview Lane
Shishmaref, AK 99772

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Shishmaref School",'Shishmaref=' + Shishmaref.length); Stebbins[Stebbins.length] = createMarker(new GPoint(-162.24879456,63.49819946),"
Tukurngailnguq School
General Delivery
Stebbins, AK 99671

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Tukurngailnguq School",'Stebbins=' + Stebbins.length); Unalakleet[Unalakleet.length] = createMarker(new GPoint(-160.74630737,63.86199951),"
Unalakleet School
Po Box 130
Unalakleet, AK 99684

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Unalakleet School",'Unalakleet=' + Unalakleet.length); Wales[Wales.length] = createMarker(new GPoint(-167.87930298,65.58460236),"
Wales School
Box 490
Wales, AK 99783

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Wales School",'Wales=' + Wales.length); White_Mountain[White_Mountain.length] = createMarker(new GPoint(-163.40612793,64.68158722),"
White Mountain School
Box 55
White Mountain, AK 99784

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("White Mountain School",'White_Mountain=' + White_Mountain.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(Brevig_Mission); map.removeOverlays(Diomede); map.removeOverlays(Elim); map.removeOverlays(Gambell); map.removeOverlays(Golovin); map.removeOverlays(Koyuk); map.removeOverlays(Nome); map.removeOverlays(Savoonga); map.removeOverlays(Shaktoolik); map.removeOverlays(Shishmaref); map.removeOverlays(St_Michael); map.removeOverlays(Stebbins); map.removeOverlays(Teller); map.removeOverlays(Unalakleet); map.removeOverlays(Wales); map.removeOverlays(White_Mountain); 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(Elim);map.removeOverlays(Brevig_Mission); map.removeOverlays(Diomede); map.removeOverlays(Elim); map.removeOverlays(Gambell); map.removeOverlays(Golovin); map.removeOverlays(Koyuk); map.removeOverlays(Nome); map.removeOverlays(Savoonga); map.removeOverlays(Shaktoolik); map.removeOverlays(Shishmaref); map.removeOverlays(St_Michael); map.removeOverlays(Stebbins); map.removeOverlays(Teller); map.removeOverlays(Unalakleet); map.removeOverlays(Wales); map.removeOverlays(White_Mountain); map.addOverlays(Brevig_Mission); centerByArray(Brevig_Mission, false, false); cntMarker += Brevig_Mission.length; map.addOverlays(Diomede); centerByArray(Diomede, false, false); cntMarker += Diomede.length; map.addOverlays(Elim); centerByArray(Elim, false, false); cntMarker += Elim.length; map.addOverlays(Gambell); centerByArray(Gambell, false, false); cntMarker += Gambell.length; map.addOverlays(Golovin); centerByArray(Golovin, false, false); cntMarker += Golovin.length; map.addOverlays(Koyuk); centerByArray(Koyuk, false, false); cntMarker += Koyuk.length; map.addOverlays(Nome); centerByArray(Nome, false, false); cntMarker += Nome.length; map.addOverlays(Savoonga); centerByArray(Savoonga, false, false); cntMarker += Savoonga.length; map.addOverlays(Shaktoolik); centerByArray(Shaktoolik, false, false); cntMarker += Shaktoolik.length; map.addOverlays(Shishmaref); centerByArray(Shishmaref, false, false); cntMarker += Shishmaref.length; map.addOverlays(St_Michael); centerByArray(St_Michael, false, false); cntMarker += St_Michael.length; map.addOverlays(Stebbins); centerByArray(Stebbins, false, false); cntMarker += Stebbins.length; map.addOverlays(Teller); centerByArray(Teller, false, false); cntMarker += Teller.length; map.addOverlays(Unalakleet); centerByArray(Unalakleet, false, false); cntMarker += Unalakleet.length; map.addOverlays(Wales); centerByArray(Wales, false, false); cntMarker += Wales.length; map.addOverlays(White_Mountain); centerByArray(White_Mountain, false, false); cntMarker += White_Mountain.length; centerByArray(Elim,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'); } }