function addMarkers() { mySelect = document.getElementById('selection'); Wendover = [];Tooele = [];Dugway = [];Grantsville = [];Ibapah = [];Stansbury = [];Stansbury_Park = [];Vernon = [];mySelect.options[mySelect.options.length] = new Option("Dugway schools",'all=Dugway'); mySelect.options[mySelect.options.length] = new Option("Grantsville schools",'all=Grantsville'); mySelect.options[mySelect.options.length] = new Option("Ibapah schools",'all=Ibapah'); mySelect.options[mySelect.options.length] = new Option("Stansbury schools",'all=Stansbury'); mySelect.options[mySelect.options.length] = new Option("Stansbury Park schools",'all=Stansbury_Park'); mySelect.options[mySelect.options.length] = new Option("Tooele schools",'all=Tooele'); mySelect.options[mySelect.options.length] = new Option("Vernon schools",'all=Vernon'); mySelect.options[mySelect.options.length] = new Option("Wendover schools",'all=Wendover'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Wendover[Wendover.length] = createMarker(new GPoint(-113.54679871,40.20320129),"
Anna Smith Elementary School
Box 879
Wendover, UT 84083

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Anna Smith Elementary School",'Wendover=' + Wendover.length); Wendover[Wendover.length] = createMarker(new GPoint(-114.03556061,40.73756027),"
Callao Elementary School
Callao Rt 225
Wendover, UT 84083

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Callao Elementary School",'Wendover=' + Wendover.length); Tooele[Tooele.length] = createMarker(new GPoint(-112.28799400,40.53687900),"
Copper Canyon School
1600 N Broadway
Tooele, UT 84074

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Copper Canyon School",'Tooele=' + Tooele.length); Dugway[Dugway.length] = createMarker(new GPoint(-112.74629974,40.22518158),"
Dugway Elementary School
Bldg 5000 Valdez Circle
Dugway, UT 84022

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Dugway Elementary School",'Dugway=' + Dugway.length); Dugway[Dugway.length] = createMarker(new GPoint(-112.74685669,40.22875977),"
Dugway High School
Bldg 5020 5th St
Dugway, UT 84022

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Dugway High School",'Dugway=' + Dugway.length); Tooele[Tooele.length] = createMarker(new GPoint(-112.28331757,40.52785492),"
East Elementary School
135 S 7th Street
Tooele, UT 84074

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("East Elementary School",'Tooele=' + Tooele.length); Grantsville[Grantsville.length] = createMarker(new GPoint(-112.46878815,40.59986115),"
Grantsville Elementary School
175 W Main
Grantsville, UT 84029

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Grantsville Elementary School",'Grantsville=' + Grantsville.length); Grantsville[Grantsville.length] = createMarker(new GPoint(-112.45539856,40.59669876),"
Grantsville High School
155 E Cherry St
Grantsville, UT 84029

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Grantsville High School",'Grantsville=' + Grantsville.length); Grantsville[Grantsville.length] = createMarker(new GPoint(-112.46675900,40.59992700),"
Grantsville Home Study
155 E Cherry St
Grantsville, UT 84029

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Grantsville Home Study",'Grantsville=' + Grantsville.length); Grantsville[Grantsville.length] = createMarker(new GPoint(-112.46398163,40.59074020),"
Grantsville Middle School
318 S Hale
Grantsville, UT 84029

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Grantsville Middle School",'Grantsville=' + Grantsville.length); Tooele[Tooele.length] = createMarker(new GPoint(-112.29197693,40.53566360),"
Harris Elementary School
251 N 1st St
Tooele, UT 84074

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Harris Elementary School",'Tooele=' + Tooele.length); Ibapah[Ibapah.length] = createMarker(new GPoint(-113.98365021,40.03939056),"
Ibapah Elementary School
116 Eagle
Ibapah, UT 84034

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Ibapah Elementary School",'Ibapah=' + Ibapah.length); Tooele[Tooele.length] = createMarker(new GPoint(-112.27564240,40.55135727),"
Middle Canyon Elementary School
751 E 1000 N
Tooele, UT 84074

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Middle Canyon Elementary School",'Tooele=' + Tooele.length); Tooele[Tooele.length] = createMarker(new GPoint(-112.31391907,40.53671265),"
Northlake Elementary School
268 N Coleman
Tooele, UT 84074

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Northlake Elementary School",'Tooele=' + Tooele.length); Tooele[Tooele.length] = createMarker(new GPoint(-112.30597687,40.56423569),"
Overlake Elementary School
2052 N 170 W
Tooele, UT 84074

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Overlake Elementary School",'Tooele=' + Tooele.length); Stansbury[Stansbury.length] = createMarker(new GPoint(-112.29401400,40.62653700),"
Rose Springs School
5349 N Insbrook Place
Stansbury, UT 84074

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Rose Springs School",'Stansbury=' + Stansbury.length); Stansbury_Park[Stansbury_Park.length] = createMarker(new GPoint(-112.29071808,40.63423920),"
Stansbury Elementary School
485 Country Club Dr
Stansbury Park, UT 84074

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Stansbury Elementary School",'Stansbury_Park=' + Stansbury_Park.length); Tooele[Tooele.length] = createMarker(new GPoint(-112.32109833,40.55339813),"
Tooele High (home Study)
50 S 200 W
Tooele, UT 84074

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Tooele High (home Study)",'Tooele=' + Tooele.length); Tooele[Tooele.length] = createMarker(new GPoint(-112.29563141,40.53059006),"
Tooele High (south Campus)
Tooele Army Depot Bldg S110
Tooele, UT 84074

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Tooele High (south Campus)",'Tooele=' + Tooele.length); Tooele[Tooele.length] = createMarker(new GPoint(-112.30533600,40.52873611),"
Tooele High School
301 W Vine St
Tooele, UT 84074

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Tooele High School",'Tooele=' + Tooele.length); Tooele[Tooele.length] = createMarker(new GPoint(-112.31181335,40.53083801),"
Tooele Junior High School
411 W Vine St
Tooele, UT 84074

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Tooele Junior High School",'Tooele=' + Tooele.length); Vernon[Vernon.length] = createMarker(new GPoint(-112.43083191,40.09201050),"
Vernon Elementary School
70 N Main
Vernon, UT 84080

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Vernon Elementary School",'Vernon=' + Vernon.length); Wendover[Wendover.length] = createMarker(new GPoint(-113.54679871,40.20320129),"
Wendover High School
P O Box 610
Wendover, UT 84083

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Wendover High School",'Wendover=' + Wendover.length); Tooele[Tooele.length] = createMarker(new GPoint(-112.30976105,40.52496338),"
West Elementary School
451 W 300 S
Tooele, UT 84074

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("West Elementary School",'Tooele=' + Tooele.length); Grantsville[Grantsville.length] = createMarker(new GPoint(-112.44911957,40.58685303),"
Willow Elementary School
439 S Willow St
Grantsville, UT 84029

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Willow Elementary School",'Grantsville=' + Grantsville.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(Dugway); map.removeOverlays(Grantsville); map.removeOverlays(Ibapah); map.removeOverlays(Stansbury); map.removeOverlays(Stansbury_Park); map.removeOverlays(Tooele); map.removeOverlays(Vernon); map.removeOverlays(Wendover); 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(Wendover);map.removeOverlays(Dugway); map.removeOverlays(Grantsville); map.removeOverlays(Ibapah); map.removeOverlays(Stansbury); map.removeOverlays(Stansbury_Park); map.removeOverlays(Tooele); map.removeOverlays(Vernon); map.removeOverlays(Wendover); map.addOverlays(Dugway); centerByArray(Dugway, false, false); cntMarker += Dugway.length; map.addOverlays(Grantsville); centerByArray(Grantsville, false, false); cntMarker += Grantsville.length; map.addOverlays(Ibapah); centerByArray(Ibapah, false, false); cntMarker += Ibapah.length; map.addOverlays(Stansbury); centerByArray(Stansbury, false, false); cntMarker += Stansbury.length; map.addOverlays(Stansbury_Park); centerByArray(Stansbury_Park, false, false); cntMarker += Stansbury_Park.length; map.addOverlays(Tooele); centerByArray(Tooele, false, false); cntMarker += Tooele.length; map.addOverlays(Vernon); centerByArray(Vernon, false, false); cntMarker += Vernon.length; map.addOverlays(Wendover); centerByArray(Wendover, false, false); cntMarker += Wendover.length; centerByArray(Wendover,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'); } }