function addMarkers() { mySelect = document.getElementById('selection'); Richfield = [];Koosharem = [];Monroe = [];Salina = [];mySelect.options[mySelect.options.length] = new Option("Koosharem schools",'all=Koosharem'); mySelect.options[mySelect.options.length] = new Option("Monroe schools",'all=Monroe'); mySelect.options[mySelect.options.length] = new Option("Richfield schools",'all=Richfield'); mySelect.options[mySelect.options.length] = new Option("Salina schools",'all=Salina'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Richfield[Richfield.length] = createMarker(new GPoint(-112.08811951,38.76903152),"
Ashman Elementary School
70 North 200 West
Richfield, UT 84701

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Ashman Elementary School",'Richfield=' + Richfield.length); Richfield[Richfield.length] = createMarker(new GPoint(-112.09619141,38.76913452),"
Cedar Ridge High School
50 North 650 West
Richfield, UT 84701

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cedar Ridge High School",'Richfield=' + Richfield.length); Richfield[Richfield.length] = createMarker(new GPoint(-112.06735229,38.77416992),"
Central Utah Youth Home
180 East 600 North
Richfield, UT 84701

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Central Utah Youth Home",'Richfield=' + Richfield.length); Koosharem[Koosharem.length] = createMarker(new GPoint(-112.08345032,38.76823807),"
Koosharem Elementary School
75 E Center
Koosharem, UT 84744

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Koosharem Elementary School",'Koosharem=' + Koosharem.length); Monroe[Monroe.length] = createMarker(new GPoint(-112.12231445,38.63213730),"
Monroe Elementary School
40 W Center St
Monroe, UT 84754

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Monroe Elementary School",'Monroe=' + Monroe.length); Salina[Salina.length] = createMarker(new GPoint(-111.86592102,38.96335602),"
North Sevier High School
350 West 400 North
Salina, UT 84654

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("North Sevier High School",'Salina=' + Salina.length); Salina[Salina.length] = createMarker(new GPoint(-111.86161041,38.95920181),"
North Sevier Middle School
135 North 100 West
Salina, UT 84654

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("North Sevier Middle School",'Salina=' + Salina.length); Richfield[Richfield.length] = createMarker(new GPoint(-112.08911896,38.77523804),"
Pahvant Elementary School
240 W 500 N
Richfield, UT 84701

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Pahvant Elementary School",'Richfield=' + Richfield.length); Richfield[Richfield.length] = createMarker(new GPoint(-112.09537506,38.76297760),"
Red Hills Middle School
400 South 600 West
Richfield, UT 84701

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Red Hills Middle School",'Richfield=' + Richfield.length); Richfield[Richfield.length] = createMarker(new GPoint(-112.09400940,38.76673889),"
Richfield High School
510 West 100 South
Richfield, UT 84701

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Richfield High School",'Richfield=' + Richfield.length); Richfield[Richfield.length] = createMarker(new GPoint(-111.93930054,38.72520065),"
Richfield Preschool
80 W Center
Richfield, UT 84701

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Richfield Preschool",'Richfield=' + Richfield.length); Salina[Salina.length] = createMarker(new GPoint(-111.86382294,38.96183777),"
Salina Elementary School
210 West 300 North
Salina, UT 84654

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Salina Elementary School",'Salina=' + Salina.length); Richfield[Richfield.length] = createMarker(new GPoint(-111.93930054,38.72520065),"
Seiver-richfield
Po Box 638
Richfield, UT 84701

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Seiver-richfield",'Richfield=' + Richfield.length); Monroe[Monroe.length] = createMarker(new GPoint(-112.12967682,38.63005447),"
South Sevier High School
430 West 100 South
Monroe, UT 84754

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("South Sevier High School",'Monroe=' + Monroe.length); Monroe[Monroe.length] = createMarker(new GPoint(-112.11479950,38.63186264),"
South Sevier Middle School
300 E Center
Monroe, UT 84754

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("South Sevier Middle School",'Monroe=' + Monroe.length); Monroe[Monroe.length] = createMarker(new GPoint(-112.12239838,38.62990189),"
Storm Ridge (yic) High School
157 W Old Hwy 89
Monroe, UT 84754

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Storm Ridge (yic) High School",'Monroe=' + Monroe.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(Koosharem); map.removeOverlays(Monroe); map.removeOverlays(Richfield); map.removeOverlays(Salina); 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(Richfield);map.removeOverlays(Koosharem); map.removeOverlays(Monroe); map.removeOverlays(Richfield); map.removeOverlays(Salina); map.addOverlays(Koosharem); centerByArray(Koosharem, false, false); cntMarker += Koosharem.length; map.addOverlays(Monroe); centerByArray(Monroe, false, false); cntMarker += Monroe.length; map.addOverlays(Richfield); centerByArray(Richfield, false, false); cntMarker += Richfield.length; map.addOverlays(Salina); centerByArray(Salina, false, false); cntMarker += Salina.length; centerByArray(Richfield,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'); } }