function addMarkers() { mySelect = document.getElementById('selection'); Connell = [];Pasco = [];Kahlotus = [];mySelect.options[mySelect.options.length] = new Option("Connell schools",'all=Connell'); mySelect.options[mySelect.options.length] = new Option("Kahlotus schools",'all=Kahlotus'); mySelect.options[mySelect.options.length] = new Option("Pasco schools",'all=Pasco'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Connell[Connell.length] = createMarker(new GPoint(-119.15296936,46.59487152),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Basin City Elementary School",'Connell=' + Connell.length); Connell[Connell.length] = createMarker(new GPoint(-118.87079620,46.67269897),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Camp Outlook",'Connell=' + Connell.length); Connell[Connell.length] = createMarker(new GPoint(-118.87079620,46.67269897),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Connell Elementary School",'Connell=' + Connell.length); Connell[Connell.length] = createMarker(new GPoint(-118.87079620,46.67269897),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Connell High School",'Connell=' + Connell.length); Pasco[Pasco.length] = createMarker(new GPoint(-119.19719696,46.43057632),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Edwin Markham Elementary School",'Pasco=' + Pasco.length); Pasco[Pasco.length] = createMarker(new GPoint(-119.07298279,46.24473572),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Ellen Ochoa Middle School",'Pasco=' + Pasco.length); Pasco[Pasco.length] = createMarker(new GPoint(-119.11057281,46.23826218),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Emerson Elementary School",'Pasco=' + Pasco.length); Pasco[Pasco.length] = createMarker(new GPoint(-119.14411926,46.26786804),"",iconRd); mySelect.options[mySelect.options.length] = new Option("James Mcgee Elementary School",'Pasco=' + Pasco.length); Kahlotus[Kahlotus.length] = createMarker(new GPoint(-118.55670166,46.64153671),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Kahlotus Elementary & High School",'Kahlotus=' + Kahlotus.length); Pasco[Pasco.length] = createMarker(new GPoint(-119.10227966,46.23048019),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Longfellow Elementary School",'Pasco=' + Pasco.length); Pasco[Pasco.length] = createMarker(new GPoint(-119.14320374,46.24444580),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mark Twain Elementary School",'Pasco=' + Pasco.length); Pasco[Pasco.length] = createMarker(new GPoint(-119.20082000,46.25624200),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Maya Angelou Elementary School",'Pasco=' + Pasco.length); Pasco[Pasco.length] = createMarker(new GPoint(-119.20610046,46.25372696),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Mcloughlin Middle School",'Pasco=' + Pasco.length); Connell[Connell.length] = createMarker(new GPoint(-119.00186157,46.57396317),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mesa Elementary School",'Connell=' + Connell.length); Pasco[Pasco.length] = createMarker(new GPoint(-119.12908173,46.25338745),"",iconGr); mySelect.options[mySelect.options.length] = new Option("New Horizons High School",'Pasco=' + Pasco.length); Connell[Connell.length] = createMarker(new GPoint(-118.87079620,46.67269897),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Palouse Junction High School",'Connell=' + Connell.length); Pasco[Pasco.length] = createMarker(new GPoint(-118.57599640,46.53578186),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pasco Early Childhood Elementary School",'Pasco=' + Pasco.length); Pasco[Pasco.length] = createMarker(new GPoint(-119.10279846,46.23778915),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Pasco Senior High School",'Pasco=' + Pasco.length); Pasco[Pasco.length] = createMarker(new GPoint(-119.11959076,46.24541855),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Robert Frost Elementary School",'Pasco=' + Pasco.length); Connell[Connell.length] = createMarker(new GPoint(-118.87079620,46.67269897),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Robert L Olds Junior High School",'Connell=' + Connell.length); Pasco[Pasco.length] = createMarker(new GPoint(-119.12249756,46.23456955),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Rowena Chess Elementary School",'Pasco=' + Pasco.length); Pasco[Pasco.length] = createMarker(new GPoint(-119.20079803,46.25113297),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Ruth Livingston Elementary School",'Pasco=' + Pasco.length); Connell[Connell.length] = createMarker(new GPoint(-118.87079620,46.67269897),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Special Education Elementary School",'Connell=' + Connell.length); Pasco[Pasco.length] = createMarker(new GPoint(-118.71759033,46.44226837),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Star Elementary School",'Pasco=' + Pasco.length); Pasco[Pasco.length] = createMarker(new GPoint(-119.12027740,46.23862457),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Stevens Middle School",'Pasco=' + Pasco.length); Pasco[Pasco.length] = createMarker(new GPoint(-119.07590600,46.23370800),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Virgie Robinson Elementary School",'Pasco=' + Pasco.length); Pasco[Pasco.length] = createMarker(new GPoint(-119.07599640,46.23968506),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Whittier Elementary School",'Pasco=' + Pasco.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(Connell); map.removeOverlays(Kahlotus); map.removeOverlays(Pasco); 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(Connell);map.removeOverlays(Connell); map.removeOverlays(Kahlotus); map.removeOverlays(Pasco); map.addOverlays(Connell); centerByArray(Connell, false, false); cntMarker += Connell.length; map.addOverlays(Kahlotus); centerByArray(Kahlotus, false, false); cntMarker += Kahlotus.length; map.addOverlays(Pasco); centerByArray(Pasco, false, false); cntMarker += Pasco.length; centerByArray(Connell,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'); } }