function addMarkers() { mySelect = document.getElementById('selection'); Colfax = [];Colton = [];Endicott = [];Pullman = [];Garfield = [];Palouse = [];Lacrosse = [];Lamont = [];Oakesdale = [];Rosalia = [];Saint_John = [];Steptoe = [];Tekoa = [];mySelect.options[mySelect.options.length] = new Option("Colfax schools",'all=Colfax'); mySelect.options[mySelect.options.length] = new Option("Colton schools",'all=Colton'); mySelect.options[mySelect.options.length] = new Option("Endicott schools",'all=Endicott'); mySelect.options[mySelect.options.length] = new Option("Garfield schools",'all=Garfield'); mySelect.options[mySelect.options.length] = new Option("Lacrosse schools",'all=Lacrosse'); mySelect.options[mySelect.options.length] = new Option("Lamont schools",'all=Lamont'); mySelect.options[mySelect.options.length] = new Option("Oakesdale schools",'all=Oakesdale'); mySelect.options[mySelect.options.length] = new Option("Palouse schools",'all=Palouse'); mySelect.options[mySelect.options.length] = new Option("Pullman schools",'all=Pullman'); mySelect.options[mySelect.options.length] = new Option("Rosalia schools",'all=Rosalia'); mySelect.options[mySelect.options.length] = new Option("Saint John schools",'all=Saint_John'); mySelect.options[mySelect.options.length] = new Option("Steptoe schools",'all=Steptoe'); mySelect.options[mySelect.options.length] = new Option("Tekoa schools",'all=Tekoa'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Colfax[Colfax.length] = createMarker(new GPoint(-117.36138153,46.89195633),"
",iconGr); mySelect.options[mySelect.options.length] = new Option("Colfax High School",'Colfax=' + Colfax.length); Colton[Colton.length] = createMarker(new GPoint(-117.13019562,46.56681824),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Colton School",'Colton=' + Colton.length); Endicott[Endicott.length] = createMarker(new GPoint(-117.68720245,46.93019867),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Endicott/st John Elementary And Middle School",'Endicott=' + Endicott.length); Pullman[Pullman.length] = createMarker(new GPoint(-117.16964000,46.71658300),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Franklin Elementary School",'Pullman=' + Pullman.length); Garfield[Garfield.length] = createMarker(new GPoint(-117.14120483,47.01206207),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Garfield Elementary School",'Garfield=' + Garfield.length); Garfield[Garfield.length] = createMarker(new GPoint(-117.14012146,47.00793076),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Garfield Middle School",'Garfield=' + Garfield.length); Palouse[Palouse.length] = createMarker(new GPoint(-117.07213593,46.91233826),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Garfield-palouse High School",'Palouse=' + Palouse.length); Pullman[Pullman.length] = createMarker(new GPoint(-117.18115234,46.73939133),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'Pullman=' + Pullman.length); Lacrosse[Lacrosse.length] = createMarker(new GPoint(-117.91773987,46.67766190),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lacrosse Elementary School",'Lacrosse=' + Lacrosse.length); Lacrosse[Lacrosse.length] = createMarker(new GPoint(-117.91773987,46.67766190),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Lacrosse High School",'Lacrosse=' + Lacrosse.length); Lamont[Lamont.length] = createMarker(new GPoint(-117.90509033,47.20255280),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Lamont Middle School",'Lamont=' + Lamont.length); Colfax[Colfax.length] = createMarker(new GPoint(-117.36100769,46.89320755),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Leonard M Jennings Elementary School",'Colfax=' + Colfax.length); Pullman[Pullman.length] = createMarker(new GPoint(-117.18044281,46.71926117),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Lincoln Middle School",'Pullman=' + Pullman.length); Oakesdale[Oakesdale.length] = createMarker(new GPoint(-117.24259949,47.12865829),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Oakesdale Elementary School",'Oakesdale=' + Oakesdale.length); Oakesdale[Oakesdale.length] = createMarker(new GPoint(-117.24250031,47.12639999),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Oakesdale High School",'Oakesdale=' + Oakesdale.length); Palouse[Palouse.length] = createMarker(new GPoint(-117.06981659,46.90719986),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Palouse At Garfield Middle School",'Palouse=' + Palouse.length); Palouse[Palouse.length] = createMarker(new GPoint(-117.07213593,46.91233826),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Palouse Elementary School",'Palouse=' + Palouse.length); Pullman[Pullman.length] = createMarker(new GPoint(-117.18022156,46.74541855),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Pullman High School",'Pullman=' + Pullman.length); Rosalia[Rosalia.length] = createMarker(new GPoint(-117.36892700,47.23142624),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Rosalia Elementary & High School",'Rosalia=' + Rosalia.length); Saint_John[Saint_John.length] = createMarker(new GPoint(-117.58200073,47.08810043),"",iconGr); mySelect.options[mySelect.options.length] = new Option("St John Elementary School",'Saint_John=' + Saint_John.length); Saint_John[Saint_John.length] = createMarker(new GPoint(-117.58200073,47.08810043),"",iconGr); mySelect.options[mySelect.options.length] = new Option("St John/endicott High School",'Saint_John=' + Saint_John.length); Steptoe[Steptoe.length] = createMarker(new GPoint(-117.34522247,47.02069855),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Steptoe Elementary School",'Steptoe=' + Steptoe.length); Pullman[Pullman.length] = createMarker(new GPoint(-117.18766022,46.72766113),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sunnyside Elementary School",'Pullman=' + Pullman.length); Tekoa[Tekoa.length] = createMarker(new GPoint(-117.07064819,47.22320175),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Tekoa Elementary School",'Tekoa=' + Tekoa.length); Tekoa[Tekoa.length] = createMarker(new GPoint(-117.06779480,47.22323608),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Tekoa High School",'Tekoa=' + Tekoa.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(Colfax); map.removeOverlays(Colton); map.removeOverlays(Endicott); map.removeOverlays(Garfield); map.removeOverlays(Lacrosse); map.removeOverlays(Lamont); map.removeOverlays(Oakesdale); map.removeOverlays(Palouse); map.removeOverlays(Pullman); map.removeOverlays(Rosalia); map.removeOverlays(Saint_John); map.removeOverlays(Steptoe); map.removeOverlays(Tekoa); 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(Colfax);map.removeOverlays(Colfax); map.removeOverlays(Colton); map.removeOverlays(Endicott); map.removeOverlays(Garfield); map.removeOverlays(Lacrosse); map.removeOverlays(Lamont); map.removeOverlays(Oakesdale); map.removeOverlays(Palouse); map.removeOverlays(Pullman); map.removeOverlays(Rosalia); map.removeOverlays(Saint_John); map.removeOverlays(Steptoe); map.removeOverlays(Tekoa); map.addOverlays(Colfax); centerByArray(Colfax, false, false); cntMarker += Colfax.length; map.addOverlays(Colton); centerByArray(Colton, false, false); cntMarker += Colton.length; map.addOverlays(Endicott); centerByArray(Endicott, false, false); cntMarker += Endicott.length; map.addOverlays(Garfield); centerByArray(Garfield, false, false); cntMarker += Garfield.length; map.addOverlays(Lacrosse); centerByArray(Lacrosse, false, false); cntMarker += Lacrosse.length; map.addOverlays(Lamont); centerByArray(Lamont, false, false); cntMarker += Lamont.length; map.addOverlays(Oakesdale); centerByArray(Oakesdale, false, false); cntMarker += Oakesdale.length; map.addOverlays(Palouse); centerByArray(Palouse, false, false); cntMarker += Palouse.length; map.addOverlays(Pullman); centerByArray(Pullman, false, false); cntMarker += Pullman.length; map.addOverlays(Rosalia); centerByArray(Rosalia, false, false); cntMarker += Rosalia.length; map.addOverlays(Saint_John); centerByArray(Saint_John, false, false); cntMarker += Saint_John.length; map.addOverlays(Steptoe); centerByArray(Steptoe, false, false); cntMarker += Steptoe.length; map.addOverlays(Tekoa); centerByArray(Tekoa, false, false); cntMarker += Tekoa.length; centerByArray(Colfax,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'); } }