function addMarkers() { mySelect = document.getElementById('selection'); Cedar_City = [];Cedar_Cty = [];Enoch = [];Beryl = [];Parowan = [];mySelect.options[mySelect.options.length] = new Option("Beryl schools",'all=Beryl'); mySelect.options[mySelect.options.length] = new Option("Cedar City schools",'all=Cedar_City'); mySelect.options[mySelect.options.length] = new Option("Cedar Cty schools",'all=Cedar_Cty'); mySelect.options[mySelect.options.length] = new Option("Enoch schools",'all=Enoch'); mySelect.options[mySelect.options.length] = new Option("Parowan schools",'all=Parowan'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Cedar_City[Cedar_City.length] = createMarker(new GPoint(-113.06700134,37.71260071),"
Canyon View High School
166 W 1925 N
Cedar City, UT 84720

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Canyon View High School",'Cedar_City=' + Cedar_City.length); Cedar_City[Cedar_City.length] = createMarker(new GPoint(-113.07278442,37.66636276),"
Cedar City High School
703 W 600 S
Cedar City, UT 84720

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cedar City High School",'Cedar_City=' + Cedar_City.length); Cedar_City[Cedar_City.length] = createMarker(new GPoint(-113.06187439,37.70964432),"
Cedar City Middle School
2215 Royal Hunte Dr
Cedar City, UT 84720

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Cedar City Middle School",'Cedar_City=' + Cedar_City.length); Cedar_Cty[Cedar_Cty.length] = createMarker(new GPoint(-113.05737305,37.67633820),"
Cedar East Elementary School
255 E College Ave
Cedar Cty, UT 84720

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Cedar East Elementary School",'Cedar_Cty=' + Cedar_Cty.length); Cedar_City[Cedar_City.length] = createMarker(new GPoint(-113.07085419,37.68103790),"
Cedar North Elementary School
550 W 200 N
Cedar City, UT 84720

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Cedar North Elementary School",'Cedar_City=' + Cedar_City.length); Cedar_City[Cedar_City.length] = createMarker(new GPoint(-113.07012939,37.67026138),"
Cedar South Elementary School
499 W 400 S
Cedar City, UT 84720

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Cedar South Elementary School",'Cedar_City=' + Cedar_City.length); Enoch[Enoch.length] = createMarker(new GPoint(-113.03007507,37.76317215),"
Enoch Elementary School
4701 N Wagon Wheel
Enoch, UT 84720

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Enoch Elementary School",'Enoch=' + Enoch.length); Beryl[Beryl.length] = createMarker(new GPoint(-113.68609619,37.82669830),"
Escalante Valley Elementary School
202 N Beryl Hwy
Beryl, UT 84714

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Escalante Valley Elementary School",'Beryl=' + Beryl.length); Cedar_City[Cedar_City.length] = createMarker(new GPoint(-113.05458069,37.71253967),"
Fiddlers Canyon Elementary School
475 E 1935 N
Cedar City, UT 84720

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Fiddlers Canyon Elementary School",'Cedar_City=' + Cedar_City.length); Cedar_City[Cedar_City.length] = createMarker(new GPoint(-113.06176400,37.67795000),"
Foothill High - Detention
270 E 1600 N
Cedar City, UT 84720

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Foothill High - Detention",'Cedar_City=' + Cedar_City.length); Cedar_City[Cedar_City.length] = createMarker(new GPoint(-113.05813599,37.70616150),"
Foothill High School
270 E 1600 N
Cedar City, UT 84720

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Foothill High School",'Cedar_City=' + Cedar_City.length); Parowan[Parowan.length] = createMarker(new GPoint(-112.77742767,37.88763809),"
Parowan Elementary School
128 W 100 N
Parowan, UT 84761

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Parowan Elementary School",'Parowan=' + Parowan.length); Parowan[Parowan.length] = createMarker(new GPoint(-112.82752228,37.84527969),"
Parowan High School
50 W 100 N
Parowan, UT 84761

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Parowan High School",'Parowan=' + Parowan.length); Cedar_City[Cedar_City.length] = createMarker(new GPoint(-113.06812286,37.66330338),"
Southwest Educ Academy
510 W 800 S
Cedar City, UT 84720

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Southwest Educ Academy",'Cedar_City=' + Cedar_City.length); Cedar_City[Cedar_City.length] = createMarker(new GPoint(-97.71384700,30.27877300),"
Success Academy
351 W University Blvd
Cedar City, UT 84720

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Success Academy",'Cedar_City=' + Cedar_City.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(Beryl); map.removeOverlays(Cedar_City); map.removeOverlays(Cedar_Cty); map.removeOverlays(Enoch); map.removeOverlays(Parowan); 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(Cedar_City);map.removeOverlays(Beryl); map.removeOverlays(Cedar_City); map.removeOverlays(Cedar_Cty); map.removeOverlays(Enoch); map.removeOverlays(Parowan); map.addOverlays(Beryl); centerByArray(Beryl, false, false); cntMarker += Beryl.length; map.addOverlays(Cedar_City); centerByArray(Cedar_City, false, false); cntMarker += Cedar_City.length; map.addOverlays(Cedar_Cty); centerByArray(Cedar_Cty, false, false); cntMarker += Cedar_Cty.length; map.addOverlays(Enoch); centerByArray(Enoch, false, false); cntMarker += Enoch.length; map.addOverlays(Parowan); centerByArray(Parowan, false, false); cntMarker += Parowan.length; centerByArray(Cedar_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'); } }