function addMarkers() { mySelect = document.getElementById('selection'); Chignik_Bay = [];Chignik_Lagoon = [];Chignik_Lake = [];Pedro_Bay = [];Egegik = [];Igiugig = [];Kokhanok = [];Levelock = [];Port_Heiden = [];Iliamna = [];Nondalton = [];Perryville = [];Pilot_Point = [];Port_Alsworth = [];mySelect.options[mySelect.options.length] = new Option("Chignik Bay schools",'all=Chignik_Bay'); mySelect.options[mySelect.options.length] = new Option("Chignik Lagoon schools",'all=Chignik_Lagoon'); mySelect.options[mySelect.options.length] = new Option("Chignik Lake schools",'all=Chignik_Lake'); mySelect.options[mySelect.options.length] = new Option("Egegik schools",'all=Egegik'); mySelect.options[mySelect.options.length] = new Option("Igiugig schools",'all=Igiugig'); mySelect.options[mySelect.options.length] = new Option("Iliamna schools",'all=Iliamna'); mySelect.options[mySelect.options.length] = new Option("Kokhanok schools",'all=Kokhanok'); mySelect.options[mySelect.options.length] = new Option("Levelock schools",'all=Levelock'); mySelect.options[mySelect.options.length] = new Option("Nondalton schools",'all=Nondalton'); mySelect.options[mySelect.options.length] = new Option("Pedro Bay schools",'all=Pedro_Bay'); mySelect.options[mySelect.options.length] = new Option("Perryville schools",'all=Perryville'); mySelect.options[mySelect.options.length] = new Option("Pilot Point schools",'all=Pilot_Point'); mySelect.options[mySelect.options.length] = new Option("Port Alsworth schools",'all=Port_Alsworth'); mySelect.options[mySelect.options.length] = new Option("Port Heiden schools",'all=Port_Heiden'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Chignik_Bay[Chignik_Bay.length] = createMarker(new GPoint(-151.64700317,65.28579712),"
",iconGr); mySelect.options[mySelect.options.length] = new Option("Chignik Bay School",'Chignik_Bay=' + Chignik_Bay.length); Chignik_Lagoon[Chignik_Lagoon.length] = createMarker(new GPoint(-158.50250244,56.32379913),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Chignik Lagoon School",'Chignik_Lagoon=' + Chignik_Lagoon.length); Chignik_Lake[Chignik_Lake.length] = createMarker(new GPoint(-157.86300659,56.77099991),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Chignik Lake School",'Chignik_Lake=' + Chignik_Lake.length); Pedro_Bay[Pedro_Bay.length] = createMarker(new GPoint(-147.71745800,64.84193900),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Dena'ina School",'Pedro_Bay=' + Pedro_Bay.length); Egegik[Egegik.length] = createMarker(new GPoint(-157.34860229,58.21379852),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Egegik School",'Egegik=' + Egegik.length); Igiugig[Igiugig.length] = createMarker(new GPoint(-156.10440063,59.08890152),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Igiugig School",'Igiugig=' + Igiugig.length); Kokhanok[Kokhanok.length] = createMarker(new GPoint(-154.16510010,59.91630173),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Kokhanok School",'Kokhanok=' + Kokhanok.length); Levelock[Levelock.length] = createMarker(new GPoint(-155.56530762,59.34389877),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Levelock School",'Levelock=' + Levelock.length); Port_Heiden[Port_Heiden.length] = createMarker(new GPoint(-158.63609314,56.94729996),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Meshik School",'Port_Heiden=' + Port_Heiden.length); Iliamna[Iliamna.length] = createMarker(new GPoint(-154.16510010,59.91630173),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Newhalen School",'Iliamna=' + Iliamna.length); Nondalton[Nondalton.length] = createMarker(new GPoint(-154.84640503,59.97339630),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Nondalton School",'Nondalton=' + Nondalton.length); Perryville[Perryville.length] = createMarker(new GPoint(-159.14320374,55.92100143),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Perryville School",'Perryville=' + Perryville.length); Pilot_Point[Pilot_Point.length] = createMarker(new GPoint(-157.54640198,57.54999924),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Pilot Point School",'Pilot_Point=' + Pilot_Point.length); Port_Alsworth[Port_Alsworth.length] = createMarker(new GPoint(-154.36630249,60.47510147),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Tanalian School",'Port_Alsworth=' + Port_Alsworth.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(Chignik_Bay); map.removeOverlays(Chignik_Lagoon); map.removeOverlays(Chignik_Lake); map.removeOverlays(Egegik); map.removeOverlays(Igiugig); map.removeOverlays(Iliamna); map.removeOverlays(Kokhanok); map.removeOverlays(Levelock); map.removeOverlays(Nondalton); map.removeOverlays(Pedro_Bay); map.removeOverlays(Perryville); map.removeOverlays(Pilot_Point); map.removeOverlays(Port_Alsworth); map.removeOverlays(Port_Heiden); 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(Chignik_Bay);map.removeOverlays(Chignik_Bay); map.removeOverlays(Chignik_Lagoon); map.removeOverlays(Chignik_Lake); map.removeOverlays(Egegik); map.removeOverlays(Igiugig); map.removeOverlays(Iliamna); map.removeOverlays(Kokhanok); map.removeOverlays(Levelock); map.removeOverlays(Nondalton); map.removeOverlays(Pedro_Bay); map.removeOverlays(Perryville); map.removeOverlays(Pilot_Point); map.removeOverlays(Port_Alsworth); map.removeOverlays(Port_Heiden); map.addOverlays(Chignik_Bay); centerByArray(Chignik_Bay, false, false); cntMarker += Chignik_Bay.length; map.addOverlays(Chignik_Lagoon); centerByArray(Chignik_Lagoon, false, false); cntMarker += Chignik_Lagoon.length; map.addOverlays(Chignik_Lake); centerByArray(Chignik_Lake, false, false); cntMarker += Chignik_Lake.length; map.addOverlays(Egegik); centerByArray(Egegik, false, false); cntMarker += Egegik.length; map.addOverlays(Igiugig); centerByArray(Igiugig, false, false); cntMarker += Igiugig.length; map.addOverlays(Iliamna); centerByArray(Iliamna, false, false); cntMarker += Iliamna.length; map.addOverlays(Kokhanok); centerByArray(Kokhanok, false, false); cntMarker += Kokhanok.length; map.addOverlays(Levelock); centerByArray(Levelock, false, false); cntMarker += Levelock.length; map.addOverlays(Nondalton); centerByArray(Nondalton, false, false); cntMarker += Nondalton.length; map.addOverlays(Pedro_Bay); centerByArray(Pedro_Bay, false, false); cntMarker += Pedro_Bay.length; map.addOverlays(Perryville); centerByArray(Perryville, false, false); cntMarker += Perryville.length; map.addOverlays(Pilot_Point); centerByArray(Pilot_Point, false, false); cntMarker += Pilot_Point.length; map.addOverlays(Port_Alsworth); centerByArray(Port_Alsworth, false, false); cntMarker += Port_Alsworth.length; map.addOverlays(Port_Heiden); centerByArray(Port_Heiden, false, false); cntMarker += Port_Heiden.length; centerByArray(Chignik_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'); } }