function addMarkers() { mySelect = document.getElementById('selection'); Monmouth = [];Dallas = [];Salem = [];Independence = [];Falls_City = [];Rickreall = [];Amity = [];Grand_Ronde = [];mySelect.options[mySelect.options.length] = new Option("Amity schools",'all=Amity'); mySelect.options[mySelect.options.length] = new Option("Dallas schools",'all=Dallas'); mySelect.options[mySelect.options.length] = new Option("Falls City schools",'all=Falls_City'); mySelect.options[mySelect.options.length] = new Option("Grand Ronde schools",'all=Grand_Ronde'); mySelect.options[mySelect.options.length] = new Option("Independence schools",'all=Independence'); mySelect.options[mySelect.options.length] = new Option("Monmouth schools",'all=Monmouth'); mySelect.options[mySelect.options.length] = new Option("Rickreall schools",'all=Rickreall'); mySelect.options[mySelect.options.length] = new Option("Salem schools",'all=Salem'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Monmouth[Monmouth.length] = createMarker(new GPoint(-123.21800232,44.86380005),"
",iconBl); mySelect.options[mySelect.options.length] = new Option("Ash Creek Intermediate School",'Monmouth=' + Monmouth.length); Dallas[Dallas.length] = createMarker(new GPoint(-123.32330322,44.92580032),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bridgeport Elementary School",'Dallas=' + Dallas.length); Salem[Salem.length] = createMarker(new GPoint(-123.07669067,44.97187805),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Brush College Elementary School",'Salem=' + Salem.length); Independence[Independence.length] = createMarker(new GPoint(-123.20986938,44.85133743),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Central High School",'Independence=' + Independence.length); Salem[Salem.length] = createMarker(new GPoint(-123.08048248,44.95452881),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Chapman Hill Elementary School",'Salem=' + Salem.length); Dallas[Dallas.length] = createMarker(new GPoint(-123.30500793,44.91675568),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Dallas High School",'Dallas=' + Dallas.length); Falls_City[Falls_City.length] = createMarker(new GPoint(-123.43122864,44.86772156),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Falls City Elementary School",'Falls_City=' + Falls_City.length); Falls_City[Falls_City.length] = createMarker(new GPoint(-123.42855835,44.86568832),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Falls City High School",'Falls_City=' + Falls_City.length); Salem[Salem.length] = createMarker(new GPoint(-123.08219910,44.96369934),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Harritt Elementary School",'Salem=' + Salem.length); Independence[Independence.length] = createMarker(new GPoint(-123.19058990,44.84655762),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Henry Hill Elementary School",'Independence=' + Independence.length); Independence[Independence.length] = createMarker(new GPoint(-123.18919373,44.85254669),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Independence Elementary School",'Independence=' + Independence.length); Dallas[Dallas.length] = createMarker(new GPoint(-123.29978943,44.92373657),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Lacreole Middle School",'Dallas=' + Dallas.length); Monmouth[Monmouth.length] = createMarker(new GPoint(-123.44623566,44.74503708),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Luckiamute Valley Charter School",'Monmouth=' + Monmouth.length); Dallas[Dallas.length] = createMarker(new GPoint(-123.31969452,44.92863846),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lyle Elementary School",'Dallas=' + Dallas.length); Monmouth[Monmouth.length] = createMarker(new GPoint(-123.22512054,44.85203552),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Monmouth Elementary School",'Monmouth=' + Monmouth.length); Dallas[Dallas.length] = createMarker(new GPoint(-123.31130219,44.93535995),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Morrison Charter School",'Dallas=' + Dallas.length); Salem[Salem.length] = createMarker(new GPoint(-123.07706451,44.94642258),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Myers Elementary School",'Salem=' + Salem.length); Rickreall[Rickreall.length] = createMarker(new GPoint(-123.17213440,44.97212601),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Oak Grove Elementary School",'Rickreall=' + Rickreall.length); Dallas[Dallas.length] = createMarker(new GPoint(-123.33552551,44.91626358),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Oakdale Heights Elementary School",'Dallas=' + Dallas.length); Amity[Amity.length] = createMarker(new GPoint(-123.25728607,45.04129410),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Perrydale School",'Amity=' + Amity.length); Dallas[Dallas.length] = createMarker(new GPoint(-123.27544403,44.92843628),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Polk Adolscent Dtc High School",'Dallas=' + Dallas.length); Independence[Independence.length] = createMarker(new GPoint(-123.17730713,44.92410278),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Poyama Land",'Independence=' + Independence.length); Rickreall[Rickreall.length] = createMarker(new GPoint(-123.20500183,44.99589920),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Rickreall Elementary School",'Rickreall=' + Rickreall.length); Independence[Independence.length] = createMarker(new GPoint(-123.21189117,44.85196686),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Talmadge Middle School",'Independence=' + Independence.length); Salem[Salem.length] = createMarker(new GPoint(-123.05908966,44.94728088),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Walker Middle School",'Salem=' + Salem.length); Dallas[Dallas.length] = createMarker(new GPoint(-123.29723358,44.91776276),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Whitworth Elementary School",'Dallas=' + Dallas.length); Grand_Ronde[Grand_Ronde.length] = createMarker(new GPoint(-123.66329956,45.06669998),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Willamina Middle School At Grand Ronde",'Grand_Ronde=' + Grand_Ronde.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(Amity); map.removeOverlays(Dallas); map.removeOverlays(Falls_City); map.removeOverlays(Grand_Ronde); map.removeOverlays(Independence); map.removeOverlays(Monmouth); map.removeOverlays(Rickreall); map.removeOverlays(Salem); 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(Monmouth);map.removeOverlays(Amity); map.removeOverlays(Dallas); map.removeOverlays(Falls_City); map.removeOverlays(Grand_Ronde); map.removeOverlays(Independence); map.removeOverlays(Monmouth); map.removeOverlays(Rickreall); map.removeOverlays(Salem); map.addOverlays(Amity); centerByArray(Amity, false, false); cntMarker += Amity.length; map.addOverlays(Dallas); centerByArray(Dallas, false, false); cntMarker += Dallas.length; map.addOverlays(Falls_City); centerByArray(Falls_City, false, false); cntMarker += Falls_City.length; map.addOverlays(Grand_Ronde); centerByArray(Grand_Ronde, false, false); cntMarker += Grand_Ronde.length; map.addOverlays(Independence); centerByArray(Independence, false, false); cntMarker += Independence.length; map.addOverlays(Monmouth); centerByArray(Monmouth, false, false); cntMarker += Monmouth.length; map.addOverlays(Rickreall); centerByArray(Rickreall, false, false); cntMarker += Rickreall.length; map.addOverlays(Salem); centerByArray(Salem, false, false); cntMarker += Salem.length; centerByArray(Monmouth,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'); } }