function addMarkers() { mySelect = document.getElementById('selection'); Aguilar = [];Branson = [];Trinidad = [];Hoehne = [];Kim = [];Weston = [];mySelect.options[mySelect.options.length] = new Option("Aguilar schools",'all=Aguilar'); mySelect.options[mySelect.options.length] = new Option("Branson schools",'all=Branson'); mySelect.options[mySelect.options.length] = new Option("Hoehne schools",'all=Hoehne'); mySelect.options[mySelect.options.length] = new Option("Kim schools",'all=Kim'); mySelect.options[mySelect.options.length] = new Option("Trinidad schools",'all=Trinidad'); mySelect.options[mySelect.options.length] = new Option("Weston schools",'all=Weston'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Aguilar[Aguilar.length] = createMarker(new GPoint(-104.67939758,37.39149857),"
Aguilar Elementary School
P O Box 567
Aguilar, CO 81020

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Aguilar Elementary School",'Aguilar=' + Aguilar.length); Aguilar[Aguilar.length] = createMarker(new GPoint(-104.67939758,37.39149857),"
Aguilar Junior-senior High School
P O Box 567
Aguilar, CO 81020

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Aguilar Junior-senior High School",'Aguilar=' + Aguilar.length); Branson[Branson.length] = createMarker(new GPoint(-103.81549835,37.06769943),"
Branson Alternative School
P O Box 128
Branson, CO 80127

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Branson Alternative School",'Branson=' + Branson.length); Branson[Branson.length] = createMarker(new GPoint(-103.81549835,37.06769943),"
Branson Elementary School
P O Box 128
Branson, CO 81027

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Branson Elementary School",'Branson=' + Branson.length); Branson[Branson.length] = createMarker(new GPoint(-103.81549835,37.06769943),"
Branson Undivided High School
P O Box 128
Branson, CO 81027

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Branson Undivided High School",'Branson=' + Branson.length); Trinidad[Trinidad.length] = createMarker(new GPoint(-104.49615479,37.17087936),"
East Street Elementary School
206 East Street
Trinidad, CO 81082

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("East Street Elementary School",'Trinidad=' + Trinidad.length); Trinidad[Trinidad.length] = createMarker(new GPoint(-104.50823975,37.16299820),"
Eckhart Elementary School
1021 Pierce Street
Trinidad, CO 81082

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Eckhart Elementary School",'Trinidad=' + Trinidad.length); Trinidad[Trinidad.length] = createMarker(new GPoint(-76.99460300,38.83199600),"
Fisher's Peak Elementary School
3900 Moore''s Canyon Road
Trinidad, CO 81082

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Fisher's Peak Elementary School",'Trinidad=' + Trinidad.length); Hoehne[Hoehne.length] = createMarker(new GPoint(-104.38050079,37.28110123),"
Hoehne Elementary School
P O Box 91
Hoehne, CO 81046

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Hoehne Elementary School",'Hoehne=' + Hoehne.length); Hoehne[Hoehne.length] = createMarker(new GPoint(-104.38050079,37.28110123),"
Hoehne High School
P O Box 91
Hoehne, CO 81046

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Hoehne High School",'Hoehne=' + Hoehne.length); Hoehne[Hoehne.length] = createMarker(new GPoint(-104.38050079,37.28110123),"
Hoehne Junior High School
P O Box 91
Hoehne, CO 81046

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Hoehne Junior High School",'Hoehne=' + Hoehne.length); Kim[Kim.length] = createMarker(new GPoint(-103.34179687,37.34439850),"
Kim Elementary School
P O Box 100
Kim, CO 81049

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Kim Elementary School",'Kim=' + Kim.length); Kim[Kim.length] = createMarker(new GPoint(-103.34179687,37.34439850),"
Kim Undivided High School
P O Box 100
Kim, CO 81049

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Kim Undivided High School",'Kim=' + Kim.length); Trinidad[Trinidad.length] = createMarker(new GPoint(-104.51510620,37.17155457),"
Park Elementary School
612 Park Street
Trinidad, CO 81082

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Park Elementary School",'Trinidad=' + Trinidad.length); Weston[Weston.length] = createMarker(new GPoint(-104.79228210,37.12826538),"
Primero Elementary School
20200 State Highway 12
Weston, CO 81091

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Primero Elementary School",'Weston=' + Weston.length); Weston[Weston.length] = createMarker(new GPoint(-104.79228210,37.12826538),"
Primero Junior-senior High School
20200 State Highway 12
Weston, CO 81091

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Primero Junior-senior High School",'Weston=' + Weston.length); Trinidad[Trinidad.length] = createMarker(new GPoint(-104.51740265,37.16972733),"
Trinidad High School
816 West Street
Trinidad, CO 81082

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Trinidad High School",'Trinidad=' + Trinidad.length); Trinidad[Trinidad.length] = createMarker(new GPoint(-104.51512909,37.17155075),"
Trinidad Junior High School
614 Park Street
Trinidad, CO 81082

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Trinidad Junior High School",'Trinidad=' + Trinidad.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(Aguilar); map.removeOverlays(Branson); map.removeOverlays(Hoehne); map.removeOverlays(Kim); map.removeOverlays(Trinidad); map.removeOverlays(Weston); 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(Aguilar);map.removeOverlays(Aguilar); map.removeOverlays(Branson); map.removeOverlays(Hoehne); map.removeOverlays(Kim); map.removeOverlays(Trinidad); map.removeOverlays(Weston); map.addOverlays(Aguilar); centerByArray(Aguilar, false, false); cntMarker += Aguilar.length; map.addOverlays(Branson); centerByArray(Branson, false, false); cntMarker += Branson.length; map.addOverlays(Hoehne); centerByArray(Hoehne, false, false); cntMarker += Hoehne.length; map.addOverlays(Kim); centerByArray(Kim, false, false); cntMarker += Kim.length; map.addOverlays(Trinidad); centerByArray(Trinidad, false, false); cntMarker += Trinidad.length; map.addOverlays(Weston); centerByArray(Weston, false, false); cntMarker += Weston.length; centerByArray(Aguilar,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'); } }