function addMarkers() { mySelect = document.getElementById('selection'); Salt_Lake_City = [];West_Valley = [];Murray = [];Roy = [];Ivins = [];Orem = [];mySelect.options[mySelect.options.length] = new Option("Ivins magnet schools",'all=Ivins'); mySelect.options[mySelect.options.length] = new Option("Murray magnet schools",'all=Murray'); mySelect.options[mySelect.options.length] = new Option("Orem magnet schools",'all=Orem'); mySelect.options[mySelect.options.length] = new Option("Roy magnet schools",'all=Roy'); mySelect.options[mySelect.options.length] = new Option("Salt Lake City magnet schools",'all=Salt_Lake_City'); mySelect.options[mySelect.options.length] = new Option("West Valley magnet schools",'all=West_Valley'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Salt_Lake_City[Salt_Lake_City.length] = createMarker(new GPoint(-111.81590271,40.73830032),"
AcademyFor Math, Engin & Sci (ames)
5715 S 1300 E
Salt Lake City, UT 84121

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option(" AcademyFor Math, Engin & Sci (ames)",'Salt_Lake_City=' + Salt_Lake_City.length); Salt_Lake_City[Salt_Lake_City.length] = createMarker(new GPoint(-111.50888300,40.72530200),"
Beehive Science & Technology Academy (bsta)
3098 S Highland Dr Suite 100
Salt Lake City, UT 84106

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Beehive Science & Technology Academy (bsta)",'Salt_Lake_City=' + Salt_Lake_City.length); West_Valley[West_Valley.length] = createMarker(new GPoint(-111.97716400,40.72375300),"
East Hollywood High School
2185 S 3600 W
West Valley, UT 84119

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("East Hollywood High School",'West_Valley=' + West_Valley.length); Salt_Lake_City[Salt_Lake_City.length] = createMarker(new GPoint(-111.96981900,40.65308500),"
Fox Hills Magnet School
3775 W 6020 S
Salt Lake City, UT 84118

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Fox Hills Magnet School",'Salt_Lake_City=' + Salt_Lake_City.length); Salt_Lake_City[Salt_Lake_City.length] = createMarker(new GPoint(-111.92108154,40.76192474),"
Guadalupe Elementary School
340 S Goshen
Salt Lake City, UT 84104

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Guadalupe Elementary School",'Salt_Lake_City=' + Salt_Lake_City.length); Murray[Murray.length] = createMarker(new GPoint(-111.90979004,40.65891266),"
Horizon Elementary School
5180 S 700 W
Murray, UT 84123

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Horizon Elementary School",'Murray=' + Murray.length); Salt_Lake_City[Salt_Lake_City.length] = createMarker(new GPoint(-111.82165900,40.67983000),"
Morningside Magnet School
4170 S 3000 E
Salt Lake City, UT 84124

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Morningside Magnet School",'Salt_Lake_City=' + Salt_Lake_City.length); Roy[Roy.length] = createMarker(new GPoint(-112.04522200,41.16165700),"
No Utah Academy For Math Engin & Sci (nuames)
P.o. Box 248
Roy, UT 84067

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("No Utah Academy For Math Engin & Sci (nuames)",'Roy=' + Roy.length); Salt_Lake_City[Salt_Lake_City.length] = createMarker(new GPoint(-111.88331604,40.77447510),"
Salt Lake Arts Academy
844 South 200 East
Salt Lake City, UT 84111

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Salt Lake Arts Academy",'Salt_Lake_City=' + Salt_Lake_City.length); Ivins[Ivins.length] = createMarker(new GPoint(-113.65709686,37.17324066),"
Tuacahn High School For Perform Arts
1100 Tuacahn Dr
Ivins, UT 84738

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Tuacahn High School For Perform Arts",'Ivins=' + Ivins.length); Orem[Orem.length] = createMarker(new GPoint(-111.71787000,40.28263800),"
Utah County Academy Of Science (ucas)
940 W 800 S
Orem, UT 84058

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Utah County Academy Of Science (ucas)",'Orem=' + Orem.length); maxLng = -111.50888300; maxLat = 41.16165700; minLng = -113.65709686; minLat = 37.17324066; reCenterMap(); map.removeOverlays(Ivins); map.removeOverlays(Murray); map.removeOverlays(Orem); map.removeOverlays(Roy); map.removeOverlays(Salt_Lake_City); map.removeOverlays(West_Valley); setTimeout(function(){map.addOverlays(Ivins)},1000); setTimeout(function(){map.addOverlays(Murray)},1000); setTimeout(function(){map.addOverlays(Orem)},1000); setTimeout(function(){map.addOverlays(Roy)},1000); setTimeout(function(){map.addOverlays(Salt_Lake_City)},1000); setTimeout(function(){map.addOverlays(West_Valley)},1000); } // 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(Ivins); map.removeOverlays(Murray); map.removeOverlays(Orem); map.removeOverlays(Roy); map.removeOverlays(Salt_Lake_City); map.removeOverlays(West_Valley); 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(Salt_Lake_City);map.removeOverlays(Ivins); map.removeOverlays(Murray); map.removeOverlays(Orem); map.removeOverlays(Roy); map.removeOverlays(Salt_Lake_City); map.removeOverlays(West_Valley); map.addOverlays(Ivins); centerByArray(Ivins, false, false); cntMarker += Ivins.length; map.addOverlays(Murray); centerByArray(Murray, false, false); cntMarker += Murray.length; map.addOverlays(Orem); centerByArray(Orem, false, false); cntMarker += Orem.length; map.addOverlays(Roy); centerByArray(Roy, false, false); cntMarker += Roy.length; map.addOverlays(Salt_Lake_City); centerByArray(Salt_Lake_City, false, false); cntMarker += Salt_Lake_City.length; map.addOverlays(West_Valley); centerByArray(West_Valley, false, false); cntMarker += West_Valley.length; centerByArray(Salt_Lake_City,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'); } }