function addMarkers() { mySelect = document.getElementById('selection'); Manti = [];Ephraim = [];Fairview = [];Fountain_Green = [];Gunnison = [];Moroni = [];Mt_Pleasant = [];Spring_City = [];mySelect.options[mySelect.options.length] = new Option("Ephraim schools",'all=Ephraim'); mySelect.options[mySelect.options.length] = new Option("Fairview schools",'all=Fairview'); mySelect.options[mySelect.options.length] = new Option("Fountain Green schools",'all=Fountain_Green'); mySelect.options[mySelect.options.length] = new Option("Gunnison schools",'all=Gunnison'); mySelect.options[mySelect.options.length] = new Option("Manti schools",'all=Manti'); mySelect.options[mySelect.options.length] = new Option("Moroni schools",'all=Moroni'); mySelect.options[mySelect.options.length] = new Option("Mt Pleasant schools",'all=Mt_Pleasant'); mySelect.options[mySelect.options.length] = new Option("Spring City schools",'all=Spring_City'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Manti[Manti.length] = createMarker(new GPoint(-111.56169891,39.35749817),"
",iconGr); mySelect.options[mySelect.options.length] = new Option("Aftec-palisades Pals (yic)",'Manti=' + Manti.length); Ephraim[Ephraim.length] = createMarker(new GPoint(-111.58702087,39.35707855),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Ephraim Elementary School",'Ephraim=' + Ephraim.length); Ephraim[Ephraim.length] = createMarker(new GPoint(-111.58389282,39.35002136),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Ephraim Middle School",'Ephraim=' + Ephraim.length); Fairview[Fairview.length] = createMarker(new GPoint(-111.41829681,39.75329971),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Fairview Elementary School",'Fairview=' + Fairview.length); Fountain_Green[Fountain_Green.length] = createMarker(new GPoint(-111.63439941,39.63000107),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Fountain Green Elementary School",'Fountain_Green=' + Fountain_Green.length); Gunnison[Gunnison.length] = createMarker(new GPoint(-111.81916046,39.13843536),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Gunnison Valley Elementary School",'Gunnison=' + Gunnison.length); Gunnison[Gunnison.length] = createMarker(new GPoint(-111.82240295,39.15829849),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Gunnison Valley High School",'Gunnison=' + Gunnison.length); Gunnison[Gunnison.length] = createMarker(new GPoint(-111.82240295,39.15829849),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Gunnison Valley Middle School",'Gunnison=' + Gunnison.length); Manti[Manti.length] = createMarker(new GPoint(-111.63990784,39.26386261),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Manti Elementary School",'Manti=' + Manti.length); Manti[Manti.length] = createMarker(new GPoint(-111.63897705,39.27266312),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Manti High School",'Manti=' + Manti.length); Moroni[Moroni.length] = createMarker(new GPoint(-111.58733368,39.52653122),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Moroni Elementary School",'Moroni=' + Moroni.length); Mt_Pleasant[Mt_Pleasant.length] = createMarker(new GPoint(-111.45310211,39.54528046),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mt Pleasant Elementary School",'Mt_Pleasant=' + Mt_Pleasant.length); Mt_Pleasant[Mt_Pleasant.length] = createMarker(new GPoint(-111.44800568,39.53646469),"",iconGr); mySelect.options[mySelect.options.length] = new Option("North Sanpete High School",'Mt_Pleasant=' + Mt_Pleasant.length); Moroni[Moroni.length] = createMarker(new GPoint(-111.44249725,39.54299927),"",iconBl); mySelect.options[mySelect.options.length] = new Option("North Sanpete Middle School",'Moroni=' + Moroni.length); Mt_Pleasant[Mt_Pleasant.length] = createMarker(new GPoint(-111.51000214,39.49980164),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Pine Creek Ranch-ascent (yic) High School",'Mt_Pleasant=' + Mt_Pleasant.length); Spring_City[Spring_City.length] = createMarker(new GPoint(-111.49607849,39.48234177),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Spring City Elementary School",'Spring_City=' + Spring_City.length); Ephraim[Ephraim.length] = createMarker(new GPoint(-111.56169891,39.35749817),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Ywec (yic)",'Ephraim=' + Ephraim.length); Ephraim[Ephraim.length] = createMarker(new GPoint(-111.97051900,40.55902100),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Ywec-s (yic)",'Ephraim=' + Ephraim.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(Ephraim); map.removeOverlays(Fairview); map.removeOverlays(Fountain_Green); map.removeOverlays(Gunnison); map.removeOverlays(Manti); map.removeOverlays(Moroni); map.removeOverlays(Mt_Pleasant); map.removeOverlays(Spring_City); 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(Manti);map.removeOverlays(Ephraim); map.removeOverlays(Fairview); map.removeOverlays(Fountain_Green); map.removeOverlays(Gunnison); map.removeOverlays(Manti); map.removeOverlays(Moroni); map.removeOverlays(Mt_Pleasant); map.removeOverlays(Spring_City); map.addOverlays(Ephraim); centerByArray(Ephraim, false, false); cntMarker += Ephraim.length; map.addOverlays(Fairview); centerByArray(Fairview, false, false); cntMarker += Fairview.length; map.addOverlays(Fountain_Green); centerByArray(Fountain_Green, false, false); cntMarker += Fountain_Green.length; map.addOverlays(Gunnison); centerByArray(Gunnison, false, false); cntMarker += Gunnison.length; map.addOverlays(Manti); centerByArray(Manti, false, false); cntMarker += Manti.length; map.addOverlays(Moroni); centerByArray(Moroni, false, false); cntMarker += Moroni.length; map.addOverlays(Mt_Pleasant); centerByArray(Mt_Pleasant, false, false); cntMarker += Mt_Pleasant.length; map.addOverlays(Spring_City); centerByArray(Spring_City, false, false); cntMarker += Spring_City.length; centerByArray(Manti,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'); } }