function addMarkers() { mySelect = document.getElementById('selection'); Ambler = [];Noorvik = [];Buckland = [];Selawik = [];Deering = [];Kotzebue = [];Kiana = [];Kobuk = [];Kivalina = [];Noatak = [];Shungnak = [];mySelect.options[mySelect.options.length] = new Option("Ambler schools",'all=Ambler'); mySelect.options[mySelect.options.length] = new Option("Buckland schools",'all=Buckland'); mySelect.options[mySelect.options.length] = new Option("Deering schools",'all=Deering'); mySelect.options[mySelect.options.length] = new Option("Kiana schools",'all=Kiana'); mySelect.options[mySelect.options.length] = new Option("Kivalina schools",'all=Kivalina'); mySelect.options[mySelect.options.length] = new Option("Kobuk schools",'all=Kobuk'); mySelect.options[mySelect.options.length] = new Option("Kotzebue schools",'all=Kotzebue'); mySelect.options[mySelect.options.length] = new Option("Noatak schools",'all=Noatak'); mySelect.options[mySelect.options.length] = new Option("Noorvik schools",'all=Noorvik'); mySelect.options[mySelect.options.length] = new Option("Selawik schools",'all=Selawik'); mySelect.options[mySelect.options.length] = new Option("Shungnak schools",'all=Shungnak'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Ambler[Ambler.length] = createMarker(new GPoint(-158.75599670,66.70549774),"
Ambler School
Po Box 109
Ambler, AK 99786

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Ambler School",'Ambler=' + Ambler.length); Noorvik[Noorvik.length] = createMarker(new GPoint(-160.12379456,66.64880371),"
Aqqaluk High/noorvik Elementary School
Po Box 165
Noorvik, AK 99763

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Aqqaluk High/noorvik Elementary School",'Noorvik=' + Noorvik.length); Buckland[Buckland.length] = createMarker(new GPoint(-161.34260559,65.73709869),"
Buckland School
Po Box 91
Buckland, AK 99727

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Buckland School",'Buckland=' + Buckland.length); Selawik[Selawik.length] = createMarker(new GPoint(-159.53309631,66.27899933),"
Davis-ramoth School
Po Box 29
Selawik, AK 99770

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Davis-ramoth School",'Selawik=' + Selawik.length); Deering[Deering.length] = createMarker(new GPoint(-162.62809753,65.84799957),"
Deering School
Po Box 36009
Deering, AK 99736

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Deering School",'Deering=' + Deering.length); Kotzebue[Kotzebue.length] = createMarker(new GPoint(-162.28799438,66.88819885),"
June Nelson Elementary School
Po Box 264
Kotzebue, AK 99752

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("June Nelson Elementary School",'Kotzebue=' + Kotzebue.length); Kiana[Kiana.length] = createMarker(new GPoint(-159.67550659,67.02439880),"
Kiana School
Po Box 190
Kiana, AK 99749

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Kiana School",'Kiana=' + Kiana.length); Kobuk[Kobuk.length] = createMarker(new GPoint(-156.88237000,66.90328979),"
Kobuk School
Po Box 40
Kobuk, AK 99751

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Kobuk School",'Kobuk=' + Kobuk.length); Kotzebue[Kotzebue.length] = createMarker(new GPoint(-162.28799438,66.88819885),"
Kotzebue Middle/high School
Po Box 264
Kotzebue, AK 99752

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Kotzebue Middle/high School",'Kotzebue=' + Kotzebue.length); Kivalina[Kivalina.length] = createMarker(new GPoint(-163.48970032,67.51730347),"
Mcqueen School
General Delivery
Kivalina, AK 99750

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Mcqueen School",'Kivalina=' + Kivalina.length); Noatak[Noatak.length] = createMarker(new GPoint(-162.73399353,67.29509735),"
Napaaqtugmiut School
Po Box 49
Noatak, AK 99761

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Napaaqtugmiut School",'Noatak=' + Noatak.length); Kotzebue[Kotzebue.length] = createMarker(new GPoint(-162.28799438,66.88819885),"
Nw Arctic Dist. Wide Corresp.
Box 51
Kotzebue, AK 99752

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Nw Arctic Dist. Wide Corresp.",'Kotzebue=' + Kotzebue.length); Shungnak[Shungnak.length] = createMarker(new GPoint(-157.13638306,66.88806152),"
Shungnak School
Po Box 79
Shungnak, AK 99773

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Shungnak School",'Shungnak=' + Shungnak.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(Ambler); map.removeOverlays(Buckland); map.removeOverlays(Deering); map.removeOverlays(Kiana); map.removeOverlays(Kivalina); map.removeOverlays(Kobuk); map.removeOverlays(Kotzebue); map.removeOverlays(Noatak); map.removeOverlays(Noorvik); map.removeOverlays(Selawik); map.removeOverlays(Shungnak); 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(Ambler);map.removeOverlays(Ambler); map.removeOverlays(Buckland); map.removeOverlays(Deering); map.removeOverlays(Kiana); map.removeOverlays(Kivalina); map.removeOverlays(Kobuk); map.removeOverlays(Kotzebue); map.removeOverlays(Noatak); map.removeOverlays(Noorvik); map.removeOverlays(Selawik); map.removeOverlays(Shungnak); map.addOverlays(Ambler); centerByArray(Ambler, false, false); cntMarker += Ambler.length; map.addOverlays(Buckland); centerByArray(Buckland, false, false); cntMarker += Buckland.length; map.addOverlays(Deering); centerByArray(Deering, false, false); cntMarker += Deering.length; map.addOverlays(Kiana); centerByArray(Kiana, false, false); cntMarker += Kiana.length; map.addOverlays(Kivalina); centerByArray(Kivalina, false, false); cntMarker += Kivalina.length; map.addOverlays(Kobuk); centerByArray(Kobuk, false, false); cntMarker += Kobuk.length; map.addOverlays(Kotzebue); centerByArray(Kotzebue, false, false); cntMarker += Kotzebue.length; map.addOverlays(Noatak); centerByArray(Noatak, false, false); cntMarker += Noatak.length; map.addOverlays(Noorvik); centerByArray(Noorvik, false, false); cntMarker += Noorvik.length; map.addOverlays(Selawik); centerByArray(Selawik, false, false); cntMarker += Selawik.length; map.addOverlays(Shungnak); centerByArray(Shungnak, false, false); cntMarker += Shungnak.length; centerByArray(Ambler,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'); } }