function addMarkers() { mySelect = document.getElementById('selection'); Winthrop = [];Brewster = [];_Omak_Ave = [];Okanogan = [];Coulee_Dam = [];Malott = [];Omak = [];Nespelem = [];Oroville = [];Pateros = [];Tonasket = [];mySelect.options[mySelect.options.length] = new Option("Brewster schools",'all=Brewster'); mySelect.options[mySelect.options.length] = new Option("Coulee Dam schools",'all=Coulee_Dam'); mySelect.options[mySelect.options.length] = new Option("Malott schools",'all=Malott'); mySelect.options[mySelect.options.length] = new Option("Nespelem schools",'all=Nespelem'); mySelect.options[mySelect.options.length] = new Option("Okanogan schools",'all=Okanogan'); mySelect.options[mySelect.options.length] = new Option("Omak schools",'all=Omak'); mySelect.options[mySelect.options.length] = new Option("Oroville schools",'all=Oroville'); mySelect.options[mySelect.options.length] = new Option("Pateros schools",'all=Pateros'); mySelect.options[mySelect.options.length] = new Option("Tonasket schools",'all=Tonasket'); mySelect.options[mySelect.options.length] = new Option("Winthrop schools",'all=Winthrop'); mySelect.options[mySelect.options.length] = new Option(" Omak Ave schools",'all=_Omak_Ave'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Winthrop[Winthrop.length] = createMarker(new GPoint(-120.16773987,48.43941498),"
",iconGr); mySelect.options[mySelect.options.length] = new Option("Alt Educational Experience",'Winthrop=' + Winthrop.length); Brewster[Brewster.length] = createMarker(new GPoint(-119.78657532,48.09455490),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Brewster Elementary School",'Brewster=' + Brewster.length); Brewster[Brewster.length] = createMarker(new GPoint(-119.78698730,48.09453583),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Brewster High School",'Brewster=' + Brewster.length); Brewster[Brewster.length] = createMarker(new GPoint(-119.78659058,48.09579086),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Brewster Junior High School",'Brewster=' + Brewster.length); _Omak_Ave[_Omak_Ave.length] = createMarker(new GPoint(-119.52742004,48.41080093),"",iconRd); mySelect.options[mySelect.options.length] = new Option("E Omak Elementary School",'_Omak_Ave=' + _Omak_Ave.length); Okanogan[Okanogan.length] = createMarker(new GPoint(-119.59160614,48.35908890),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Grainger Elementary School",'Okanogan=' + Okanogan.length); Coulee_Dam[Coulee_Dam.length] = createMarker(new GPoint(-118.97586060,47.97018814),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Lake Roosevelt High School",'Coulee_Dam=' + Coulee_Dam.length); Winthrop[Winthrop.length] = createMarker(new GPoint(-120.16773987,48.43941498),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Liberty Bell Junior Senior High School",'Winthrop=' + Winthrop.length); Malott[Malott.length] = createMarker(new GPoint(-119.70613861,48.28466415),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Malott Elementary School",'Malott=' + Malott.length); Winthrop[Winthrop.length] = createMarker(new GPoint(-120.16773987,48.43941498),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Methow Valley Elementary School",'Winthrop=' + Winthrop.length); Winthrop[Winthrop.length] = createMarker(new GPoint(-120.18544006,48.47782135),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Methow Valley Independent L C High School",'Winthrop=' + Winthrop.length); Omak[Omak.length] = createMarker(new GPoint(-119.51677704,48.41445923),"",iconRd); mySelect.options[mySelect.options.length] = new Option("N Omak Elementary School",'Omak=' + Omak.length); Nespelem[Nespelem.length] = createMarker(new GPoint(-118.97489929,48.16659927),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Nespelem Elementary School",'Nespelem=' + Nespelem.length); Okanogan[Okanogan.length] = createMarker(new GPoint(-119.58157349,48.36580276),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Okanogan Co Juvenile Detention",'Okanogan=' + Okanogan.length); Okanogan[Okanogan.length] = createMarker(new GPoint(-119.58203888,48.36618042),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Okanogan High School",'Okanogan=' + Okanogan.length); Okanogan[Okanogan.length] = createMarker(new GPoint(-119.35874176,48.15422058),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Okanogan Middle School",'Okanogan=' + Okanogan.length); Omak[Omak.length] = createMarker(new GPoint(-119.51570129,48.41619873),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Omak Alternative High School",'Omak=' + Omak.length); Omak[Omak.length] = createMarker(new GPoint(-119.53292084,48.41055679),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Omak High School",'Omak=' + Omak.length); Omak[Omak.length] = createMarker(new GPoint(-119.53291321,48.41062164),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Omak Middle School",'Omak=' + Omak.length); Oroville[Oroville.length] = createMarker(new GPoint(-119.43692780,48.93228912),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Oroville Elementary School",'Oroville=' + Oroville.length); Oroville[Oroville.length] = createMarker(new GPoint(-119.43973541,48.93226242),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Oroville High School",'Oroville=' + Oroville.length); Omak[Omak.length] = createMarker(new GPoint(-119.50051880,48.39376068),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Paschal Sherman Indian School",'Omak=' + Omak.length); Pateros[Pateros.length] = createMarker(new GPoint(-119.51570129,48.41619873),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pateros Elementary School",'Pateros=' + Pateros.length); Pateros[Pateros.length] = createMarker(new GPoint(-119.90047900,48.05456500),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Pateros High School",'Pateros=' + Pateros.length); Tonasket[Tonasket.length] = createMarker(new GPoint(-119.43759155,48.70133972),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Tonasket Elementary School",'Tonasket=' + Tonasket.length); Tonasket[Tonasket.length] = createMarker(new GPoint(-119.43759155,48.70133972),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Tonasket High School",'Tonasket=' + Tonasket.length); Tonasket[Tonasket.length] = createMarker(new GPoint(-119.43759155,48.70133972),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Tonasket Middle School",'Tonasket=' + Tonasket.length); Coulee_Dam[Coulee_Dam.length] = createMarker(new GPoint(-118.96991730,47.96496964),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wright Elementary School",'Coulee_Dam=' + Coulee_Dam.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(Brewster); map.removeOverlays(Coulee_Dam); map.removeOverlays(Malott); map.removeOverlays(Nespelem); map.removeOverlays(Okanogan); map.removeOverlays(Omak); map.removeOverlays(Oroville); map.removeOverlays(Pateros); map.removeOverlays(Tonasket); map.removeOverlays(Winthrop); map.removeOverlays(_Omak_Ave); 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(Winthrop);map.removeOverlays(Brewster); map.removeOverlays(Coulee_Dam); map.removeOverlays(Malott); map.removeOverlays(Nespelem); map.removeOverlays(Okanogan); map.removeOverlays(Omak); map.removeOverlays(Oroville); map.removeOverlays(Pateros); map.removeOverlays(Tonasket); map.removeOverlays(Winthrop); map.removeOverlays(_Omak_Ave); map.addOverlays(Brewster); centerByArray(Brewster, false, false); cntMarker += Brewster.length; map.addOverlays(Coulee_Dam); centerByArray(Coulee_Dam, false, false); cntMarker += Coulee_Dam.length; map.addOverlays(Malott); centerByArray(Malott, false, false); cntMarker += Malott.length; map.addOverlays(Nespelem); centerByArray(Nespelem, false, false); cntMarker += Nespelem.length; map.addOverlays(Okanogan); centerByArray(Okanogan, false, false); cntMarker += Okanogan.length; map.addOverlays(Omak); centerByArray(Omak, false, false); cntMarker += Omak.length; map.addOverlays(Oroville); centerByArray(Oroville, false, false); cntMarker += Oroville.length; map.addOverlays(Pateros); centerByArray(Pateros, false, false); cntMarker += Pateros.length; map.addOverlays(Tonasket); centerByArray(Tonasket, false, false); cntMarker += Tonasket.length; map.addOverlays(Winthrop); centerByArray(Winthrop, false, false); cntMarker += Winthrop.length; map.addOverlays(_Omak_Ave); centerByArray(_Omak_Ave, false, false); cntMarker += _Omak_Ave.length; centerByArray(Winthrop,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'); } }