function addMarkers() { mySelect = document.getElementById('selection'); Blanding = [];Montezuma_Creek = [];Bluff = [];Halls_Crossing = [];Lasal = [];Lake_Powell = [];Mexican_Hat = [];Monticello = [];Monument_Valley = [];Tonalea = [];mySelect.options[mySelect.options.length] = new Option("Blanding schools",'all=Blanding'); mySelect.options[mySelect.options.length] = new Option("Bluff schools",'all=Bluff'); mySelect.options[mySelect.options.length] = new Option("Halls Crossing schools",'all=Halls_Crossing'); mySelect.options[mySelect.options.length] = new Option("Lake Powell schools",'all=Lake_Powell'); mySelect.options[mySelect.options.length] = new Option("Lasal schools",'all=Lasal'); mySelect.options[mySelect.options.length] = new Option("Mexican Hat schools",'all=Mexican_Hat'); mySelect.options[mySelect.options.length] = new Option("Montezuma Creek schools",'all=Montezuma_Creek'); mySelect.options[mySelect.options.length] = new Option("Monticello schools",'all=Monticello'); mySelect.options[mySelect.options.length] = new Option("Monument Valley schools",'all=Monument_Valley'); mySelect.options[mySelect.options.length] = new Option("Tonalea schools",'all=Tonalea'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Blanding[Blanding.length] = createMarker(new GPoint(-109.47637177,37.63245392),"
",iconBl); mySelect.options[mySelect.options.length] = new Option("Albert R Lyman Middle School",'Blanding=' + Blanding.length); Montezuma_Creek[Montezuma_Creek.length] = createMarker(new GPoint(-109.32044983,37.26919937),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Aneth Community School",'Montezuma_Creek=' + Montezuma_Creek.length); Blanding[Blanding.length] = createMarker(new GPoint(-109.47963715,37.62092972),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Blanding Elementary School",'Blanding=' + Blanding.length); Bluff[Bluff.length] = createMarker(new GPoint(-109.56230164,37.28290176),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bluff Elementary School",'Bluff=' + Bluff.length); Blanding[Blanding.length] = createMarker(new GPoint(-10.00000000,10.00000000),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Canyonlands Youth Home",'Blanding=' + Blanding.length); Halls_Crossing[Halls_Crossing.length] = createMarker(new GPoint(-110.33370209,37.50439835),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Halls Crossing Elementary School",'Halls_Crossing=' + Halls_Crossing.length); Lasal[Lasal.length] = createMarker(new GPoint(-109.24770355,38.31200027),"",iconRd); mySelect.options[mySelect.options.length] = new Option("La Sal Elementary School",'Lasal=' + Lasal.length); Lake_Powell[Lake_Powell.length] = createMarker(new GPoint(-110.33370209,37.50439835),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lake Powell Elementary School",'Lake_Powell=' + Lake_Powell.length); Lake_Powell[Lake_Powell.length] = createMarker(new GPoint(-110.71379100,37.45570900),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Lake Powell School",'Lake_Powell=' + Lake_Powell.length); Mexican_Hat[Mexican_Hat.length] = createMarker(new GPoint(-109.97149658,37.11980057),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mexican Hat Elementary School",'Mexican_Hat=' + Mexican_Hat.length); Montezuma_Creek[Montezuma_Creek.length] = createMarker(new GPoint(-109.18630219,37.62720108),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Montezuma Creek Elementary School",'Montezuma_Creek=' + Montezuma_Creek.length); Monticello[Monticello.length] = createMarker(new GPoint(-109.29479980,37.92639923),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Monticello Elementary School",'Monticello=' + Monticello.length); Monticello[Monticello.length] = createMarker(new GPoint(-109.29479980,37.92639923),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Monticello High School",'Monticello=' + Monticello.length); Monument_Valley[Monument_Valley.length] = createMarker(new GPoint(-110.44750214,37.03760147),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Monument Valley High School",'Monument_Valley=' + Monument_Valley.length); Tonalea[Tonalea.length] = createMarker(new GPoint(-110.87210083,35.99200058),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Navajo Mountain High School",'Tonalea=' + Tonalea.length); Blanding[Blanding.length] = createMarker(new GPoint(-109.47634125,37.62907028),"",iconGr); mySelect.options[mySelect.options.length] = new Option("San Juan High School",'Blanding=' + Blanding.length); Montezuma_Creek[Montezuma_Creek.length] = createMarker(new GPoint(-109.18630219,37.62720108),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Whitehorse High School",'Montezuma_Creek=' + Montezuma_Creek.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(Blanding); map.removeOverlays(Bluff); map.removeOverlays(Halls_Crossing); map.removeOverlays(Lake_Powell); map.removeOverlays(Lasal); map.removeOverlays(Mexican_Hat); map.removeOverlays(Montezuma_Creek); map.removeOverlays(Monticello); map.removeOverlays(Monument_Valley); map.removeOverlays(Tonalea); 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(Blanding);map.removeOverlays(Blanding); map.removeOverlays(Bluff); map.removeOverlays(Halls_Crossing); map.removeOverlays(Lake_Powell); map.removeOverlays(Lasal); map.removeOverlays(Mexican_Hat); map.removeOverlays(Montezuma_Creek); map.removeOverlays(Monticello); map.removeOverlays(Monument_Valley); map.removeOverlays(Tonalea); map.addOverlays(Blanding); centerByArray(Blanding, false, false); cntMarker += Blanding.length; map.addOverlays(Bluff); centerByArray(Bluff, false, false); cntMarker += Bluff.length; map.addOverlays(Halls_Crossing); centerByArray(Halls_Crossing, false, false); cntMarker += Halls_Crossing.length; map.addOverlays(Lake_Powell); centerByArray(Lake_Powell, false, false); cntMarker += Lake_Powell.length; map.addOverlays(Lasal); centerByArray(Lasal, false, false); cntMarker += Lasal.length; map.addOverlays(Mexican_Hat); centerByArray(Mexican_Hat, false, false); cntMarker += Mexican_Hat.length; map.addOverlays(Montezuma_Creek); centerByArray(Montezuma_Creek, false, false); cntMarker += Montezuma_Creek.length; map.addOverlays(Monticello); centerByArray(Monticello, false, false); cntMarker += Monticello.length; map.addOverlays(Monument_Valley); centerByArray(Monument_Valley, false, false); cntMarker += Monument_Valley.length; map.addOverlays(Tonalea); centerByArray(Tonalea, false, false); cntMarker += Tonalea.length; centerByArray(Blanding,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'); } }