function addMarkers() { mySelect = document.getElementById('selection'); Logan = [];Hyrum = [];Hyde_Park = [];North_Logan = [];Lewiston = [];Millville = [];Nibley = [];Richmond = [];Providence = [];Smithfield = [];River_Heights = [];Wellsville = [];mySelect.options[mySelect.options.length] = new Option("Hyde Park schools",'all=Hyde_Park'); mySelect.options[mySelect.options.length] = new Option("Hyrum schools",'all=Hyrum'); mySelect.options[mySelect.options.length] = new Option("Lewiston schools",'all=Lewiston'); mySelect.options[mySelect.options.length] = new Option("Logan schools",'all=Logan'); mySelect.options[mySelect.options.length] = new Option("Millville schools",'all=Millville'); mySelect.options[mySelect.options.length] = new Option("Nibley schools",'all=Nibley'); mySelect.options[mySelect.options.length] = new Option("North Logan schools",'all=North_Logan'); mySelect.options[mySelect.options.length] = new Option("Providence schools",'all=Providence'); mySelect.options[mySelect.options.length] = new Option("Richmond schools",'all=Richmond'); mySelect.options[mySelect.options.length] = new Option("River Heights schools",'all=River_Heights'); mySelect.options[mySelect.options.length] = new Option("Smithfield schools",'all=Smithfield'); mySelect.options[mySelect.options.length] = new Option("Wellsville schools",'all=Wellsville'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Logan[Logan.length] = createMarker(new GPoint(-111.82418060,41.74142838),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Adams Elementary School",'Logan=' + Logan.length); Logan[Logan.length] = createMarker(new GPoint(-111.80812073,41.74367905),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Best (yic)",'Logan=' + Logan.length); Logan[Logan.length] = createMarker(new GPoint(-111.84408800,41.75354600),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bridger School",'Logan=' + Logan.length); Logan[Logan.length] = createMarker(new GPoint(-111.84110260,41.75783539),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Cache Alternative High School",'Logan=' + Logan.length); Hyrum[Hyrum.length] = createMarker(new GPoint(-111.81894100,41.63170700),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Canyon School",'Hyrum=' + Hyrum.length); Hyde_Park[Hyde_Park.length] = createMarker(new GPoint(-111.82451630,41.80040359),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Cedar Ridge Middle School",'Hyde_Park=' + Hyde_Park.length); Logan[Logan.length] = createMarker(new GPoint(-111.83348846,41.73508835),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Edith Bowen Elementary School",'Logan=' + Logan.length); Logan[Logan.length] = createMarker(new GPoint(-111.84377289,41.73711395),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Ellis Elementary School",'Logan=' + Logan.length); Logan[Logan.length] = createMarker(new GPoint(-111.83512878,41.73239517),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Fast Forward High School",'Logan=' + Logan.length); North_Logan[North_Logan.length] = createMarker(new GPoint(-111.82287598,41.77725220),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Greenville Elementary School",'North_Logan=' + North_Logan.length); Logan[Logan.length] = createMarker(new GPoint(-111.79931641,41.74868393),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hillcrest Elementary School",'Logan=' + Logan.length); Lewiston[Lewiston.length] = createMarker(new GPoint(-111.85377502,41.97185516),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lewiston Elementary School",'Lewiston=' + Lewiston.length); Hyrum[Hyrum.length] = createMarker(new GPoint(-111.85546112,41.63222122),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Hyrum=' + Hyrum.length); Logan[Logan.length] = createMarker(new GPoint(-111.83917999,41.72936249),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Logan High School",'Logan=' + Logan.length); Logan[Logan.length] = createMarker(new GPoint(-111.84371185,41.72433853),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Logan South Campus High School",'Logan=' + Logan.length); Millville[Millville.length] = createMarker(new GPoint(-111.82219696,41.68159866),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Millville Elementary School",'Millville=' + Millville.length); Hyrum[Hyrum.length] = createMarker(new GPoint(-111.85100900,41.63397400),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Mountain Crest High School",'Hyrum=' + Hyrum.length); Logan[Logan.length] = createMarker(new GPoint(-111.82958221,41.74784851),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Mt Logan Middle School",'Logan=' + Logan.length); Nibley[Nibley.length] = createMarker(new GPoint(-111.84944153,41.68616104),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Nibley Elementary School",'Nibley=' + Nibley.length); Richmond[Richmond.length] = createMarker(new GPoint(-111.81245422,41.91042328),"",iconBl); mySelect.options[mySelect.options.length] = new Option("North Cache Cntr-jr High School",'Richmond=' + Richmond.length); Logan[Logan.length] = createMarker(new GPoint(-111.81301880,41.78232193),"",iconRd); mySelect.options[mySelect.options.length] = new Option("North Park Elementary School",'Logan=' + Logan.length); Logan[Logan.length] = createMarker(new GPoint(-111.80812073,41.74367905),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Observ & Assess (yic) High School",'Logan=' + Logan.length); Richmond[Richmond.length] = createMarker(new GPoint(-111.81178284,41.91959381),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Park Elementary School",'Richmond=' + Richmond.length); Providence[Providence.length] = createMarker(new GPoint(-111.81936646,41.68163681),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Providence Elementary School",'Providence=' + Providence.length); Logan[Logan.length] = createMarker(new GPoint(-111.81709290,41.72116470),"",iconRd); mySelect.options[mySelect.options.length] = new Option("River Heights Elementary School",'Logan=' + Logan.length); Smithfield[Smithfield.length] = createMarker(new GPoint(-111.82608795,41.82562256),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Sky View High School",'Smithfield=' + Smithfield.length); Hyrum[Hyrum.length] = createMarker(new GPoint(-111.86796570,41.63460159),"",iconBl); mySelect.options[mySelect.options.length] = new Option("South Cache Cntr-jr High School",'Hyrum=' + Hyrum.length); Logan[Logan.length] = createMarker(new GPoint(-111.80812073,41.74367905),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Special Services Elementary School",'Logan=' + Logan.length); Providence[Providence.length] = createMarker(new GPoint(-111.82723236,41.70996475),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Spring Creek Middle School",'Providence=' + Providence.length); Smithfield[Smithfield.length] = createMarker(new GPoint(-111.83486176,41.83641434),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Summit Elementary School",'Smithfield=' + Smithfield.length); Smithfield[Smithfield.length] = createMarker(new GPoint(-111.82018280,41.83194733),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sunrise Elementary School",'Smithfield=' + Smithfield.length); Nibley[Nibley.length] = createMarker(new GPoint(-111.84046100,41.70693700),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Thomas Edison - South",'Nibley=' + Nibley.length); North_Logan[North_Logan.length] = createMarker(new GPoint(-111.82902527,41.77993011),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Thomas Edison School",'North_Logan=' + North_Logan.length); River_Heights[River_Heights.length] = createMarker(new GPoint(-111.80812073,41.74367905),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Valley View School (yic)",'River_Heights=' + River_Heights.length); Wellsville[Wellsville.length] = createMarker(new GPoint(-111.93201447,41.63648224),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wellsville Elementary School",'Wellsville=' + Wellsville.length); Richmond[Richmond.length] = createMarker(new GPoint(-111.81375122,41.92464447),"",iconBl); mySelect.options[mySelect.options.length] = new Option("White Pine Middle School",'Richmond=' + Richmond.length); Wellsville[Wellsville.length] = createMarker(new GPoint(-111.93953705,41.64901352),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Willow Valley Middle School",'Wellsville=' + Wellsville.length); Logan[Logan.length] = createMarker(new GPoint(-111.82228088,41.72959137),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wilson Elementary School",'Logan=' + Logan.length); Logan[Logan.length] = createMarker(new GPoint(-111.85977936,41.71983719),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Woodruff Elementary School",'Logan=' + Logan.length); Logan[Logan.length] = createMarker(new GPoint(-111.83484900,41.73618500),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Young Mothers Program High School",'Logan=' + Logan.length); North_Logan[North_Logan.length] = createMarker(new GPoint(-111.80812073,41.74367905),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Youth Track (yic) High School",'North_Logan=' + North_Logan.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(Hyde_Park); map.removeOverlays(Hyrum); map.removeOverlays(Lewiston); map.removeOverlays(Logan); map.removeOverlays(Millville); map.removeOverlays(Nibley); map.removeOverlays(North_Logan); map.removeOverlays(Providence); map.removeOverlays(Richmond); map.removeOverlays(River_Heights); map.removeOverlays(Smithfield); map.removeOverlays(Wellsville); 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(Logan);map.removeOverlays(Hyde_Park); map.removeOverlays(Hyrum); map.removeOverlays(Lewiston); map.removeOverlays(Logan); map.removeOverlays(Millville); map.removeOverlays(Nibley); map.removeOverlays(North_Logan); map.removeOverlays(Providence); map.removeOverlays(Richmond); map.removeOverlays(River_Heights); map.removeOverlays(Smithfield); map.removeOverlays(Wellsville); map.addOverlays(Hyde_Park); centerByArray(Hyde_Park, false, false); cntMarker += Hyde_Park.length; map.addOverlays(Hyrum); centerByArray(Hyrum, false, false); cntMarker += Hyrum.length; map.addOverlays(Lewiston); centerByArray(Lewiston, false, false); cntMarker += Lewiston.length; map.addOverlays(Logan); centerByArray(Logan, false, false); cntMarker += Logan.length; map.addOverlays(Millville); centerByArray(Millville, false, false); cntMarker += Millville.length; map.addOverlays(Nibley); centerByArray(Nibley, false, false); cntMarker += Nibley.length; map.addOverlays(North_Logan); centerByArray(North_Logan, false, false); cntMarker += North_Logan.length; map.addOverlays(Providence); centerByArray(Providence, false, false); cntMarker += Providence.length; map.addOverlays(Richmond); centerByArray(Richmond, false, false); cntMarker += Richmond.length; map.addOverlays(River_Heights); centerByArray(River_Heights, false, false); cntMarker += River_Heights.length; map.addOverlays(Smithfield); centerByArray(Smithfield, false, false); cntMarker += Smithfield.length; map.addOverlays(Wellsville); centerByArray(Wellsville, false, false); cntMarker += Wellsville.length; centerByArray(Logan,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'); } }