function addMarkers() { mySelect = document.getElementById('selection'); Durango = [];Bayfield = [];Hesperus = [];Ignacio = [];mySelect.options[mySelect.options.length] = new Option("Bayfield schools",'all=Bayfield'); mySelect.options[mySelect.options.length] = new Option("Durango schools",'all=Durango'); mySelect.options[mySelect.options.length] = new Option("Hesperus schools",'all=Hesperus'); mySelect.options[mySelect.options.length] = new Option("Ignacio schools",'all=Ignacio'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Durango[Durango.length] = createMarker(new GPoint(-107.83523560,37.40105438),"
Animas Valley Elementary School
373 Hermosa Meadows Road
Durango, CO 81301

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Animas Valley Elementary School",'Durango=' + Durango.length); Bayfield[Bayfield.length] = createMarker(new GPoint(-107.59796143,37.22521973),"
Bayfield Elementary School
511 E Mustang Ln, 24 Clover Dr
Bayfield, CO 81122

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bayfield Elementary School",'Bayfield=' + Bayfield.length); Bayfield[Bayfield.length] = createMarker(new GPoint(-107.59796143,37.22521973),"
Bayfield High School
800 Co Rd 501, 24 Clover Dr
Bayfield, CO 81122

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bayfield High School",'Bayfield=' + Bayfield.length); Bayfield[Bayfield.length] = createMarker(new GPoint(-107.59796143,37.22521973),"
Bayfield Middle School
615 E. Oak, 24 Clover Dr
Bayfield, CO 81122

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Bayfield Middle School",'Bayfield=' + Bayfield.length); Durango[Durango.length] = createMarker(new GPoint(-107.87940216,37.27759552),"
Durango High School
2390 Main Avenue
Durango, CO 81301

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Durango High School",'Durango=' + Durango.length); Durango[Durango.length] = createMarker(new GPoint(-107.87699890,37.27585602),"
Durango Second Chance
301 East 12th Street
Durango, CO 81301

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Durango Second Chance",'Durango=' + Durango.length); Durango[Durango.length] = createMarker(new GPoint(-107.86335754,37.22764587),"
Escalante Middle School
141 Baker Lane
Durango, CO 81301

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Escalante Middle School",'Durango=' + Durango.length); Durango[Durango.length] = createMarker(new GPoint(-107.87834930,37.27614975),"
Excel Charter School
215 East 12th Street
Durango, CO 81301

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Excel Charter School",'Durango=' + Durango.length); Durango[Durango.length] = createMarker(new GPoint(-107.79573059,37.21503448),"
Florida Mesa Elementary School
216 Highway 172
Durango, CO 81301

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Florida Mesa Elementary School",'Durango=' + Durango.length); Hesperus[Hesperus.length] = createMarker(new GPoint(-108.11364746,37.15727234),"
Fort Lewis Mesa Elementary School
11274 Highway 140
Hesperus, CO 81326

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Fort Lewis Mesa Elementary School",'Hesperus=' + Hesperus.length); Ignacio[Ignacio.length] = createMarker(new GPoint(-107.65720367,37.09700012),"
Ignacio Elementary School
P O Box 460
Ignacio, CO 81137

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Ignacio Elementary School",'Ignacio=' + Ignacio.length); Ignacio[Ignacio.length] = createMarker(new GPoint(-107.65720367,37.09700012),"
Ignacio High School
P O Box 460
Ignacio, CO 81137

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Ignacio High School",'Ignacio=' + Ignacio.length); Ignacio[Ignacio.length] = createMarker(new GPoint(-107.65720367,37.09700012),"
Ignacio Intermediate School
P O Box 460
Ignacio, CO 81137

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Ignacio Intermediate School",'Ignacio=' + Ignacio.length); Ignacio[Ignacio.length] = createMarker(new GPoint(-107.65720367,37.09700012),"
Ignacio Junior High School
P O Box 460
Ignacio, CO 81137

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Ignacio Junior High School",'Ignacio=' + Ignacio.length); Durango[Durango.length] = createMarker(new GPoint(-107.87753296,37.29225540),"
Miller Middle School
2608 Junction Street
Durango, CO 81301

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Miller Middle School",'Durango=' + Durango.length); Durango[Durango.length] = createMarker(new GPoint(-107.87799072,37.29055405),"
Needham Elementary School
2425 West Third Avenue
Durango, CO 81301

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Needham Elementary School",'Durango=' + Durango.length); Durango[Durango.length] = createMarker(new GPoint(-107.87562561,37.26761627),"
Park Elementary School
623 East 5th Street
Durango, CO 81301

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Park Elementary School",'Durango=' + Durango.length); Ignacio[Ignacio.length] = createMarker(new GPoint(-107.63318000,37.11509900),"
Pine River Valley High School
Po Box 710
Ignacio, CO 81137

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Pine River Valley High School",'Ignacio=' + Ignacio.length); Durango[Durango.length] = createMarker(new GPoint(-107.86657715,37.29242325),"
Riverview Elementary School
2900 Mesa Avenue
Durango, CO 81301

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Riverview Elementary School",'Durango=' + Durango.length); Durango[Durango.length] = createMarker(new GPoint(-107.86306000,37.12213516),"
Sunnyside Elementary School
75 Cr 218
Durango, CO 81301

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Sunnyside Elementary School",'Durango=' + Durango.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(Bayfield); map.removeOverlays(Durango); map.removeOverlays(Hesperus); map.removeOverlays(Ignacio); 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(Durango);map.removeOverlays(Bayfield); map.removeOverlays(Durango); map.removeOverlays(Hesperus); map.removeOverlays(Ignacio); map.addOverlays(Bayfield); centerByArray(Bayfield, false, false); cntMarker += Bayfield.length; map.addOverlays(Durango); centerByArray(Durango, false, false); cntMarker += Durango.length; map.addOverlays(Hesperus); centerByArray(Hesperus, false, false); cntMarker += Hesperus.length; map.addOverlays(Ignacio); centerByArray(Ignacio, false, false); cntMarker += Ignacio.length; centerByArray(Durango,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'); } }