function addMarkers() { mySelect = document.getElementById('selection'); Cortez = [];Dolores = [];Mancos = [];Pleasant_View = [];mySelect.options[mySelect.options.length] = new Option("Cortez schools",'all=Cortez'); mySelect.options[mySelect.options.length] = new Option("Dolores schools",'all=Dolores'); mySelect.options[mySelect.options.length] = new Option("Mancos schools",'all=Mancos'); mySelect.options[mySelect.options.length] = new Option("Pleasant View schools",'all=Pleasant_View'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Cortez[Cortez.length] = createMarker(new GPoint(-108.61889648,37.35340118),"
Adult Education Program
P O Box 1420
Cortez, CO 81321

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Adult Education Program",'Cortez=' + Cortez.length); Cortez[Cortez.length] = createMarker(new GPoint(-108.84425354,37.33576584),"
Battle Rock Charter School
11247 County Road G
Cortez, CO 81321

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Battle Rock Charter School",'Cortez=' + Cortez.length); Cortez[Cortez.length] = createMarker(new GPoint(-108.58386993,37.35413742),"
Beech Street Kindergarten
510 North Beech Street
Cortez, CO 81321

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Beech Street Kindergarten",'Cortez=' + Cortez.length); Cortez[Cortez.length] = createMarker(new GPoint(-108.59127808,37.34653854),"
Cortez Middle School
450 West 2nd Street
Cortez, CO 81321

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Cortez Middle School",'Cortez=' + Cortez.length); Dolores[Dolores.length] = createMarker(new GPoint(-108.53560638,37.45802307),"
Dolores Elementary School
17631 Highway 145
Dolores, CO 81323

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Dolores Elementary School",'Dolores=' + Dolores.length); Dolores[Dolores.length] = createMarker(new GPoint(-108.53560638,37.45802307),"
Dolores High School
17631 Highway 145
Dolores, CO 81323

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Dolores High School",'Dolores=' + Dolores.length); Dolores[Dolores.length] = createMarker(new GPoint(-108.53560638,37.45802307),"
Dolores Middle School
17631 Highway 145
Dolores, CO 81323

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Dolores Middle School",'Dolores=' + Dolores.length); Cortez[Cortez.length] = createMarker(new GPoint(-108.58782196,37.35287476),"
Downey Elementary School
400 North Elm
Cortez, CO 81321

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Downey Elementary School",'Cortez=' + Cortez.length); Cortez[Cortez.length] = createMarker(new GPoint(-108.57703400,37.35097885),"
Kemper Elementary School
620 East Montezuma
Cortez, CO 81321

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Kemper Elementary School",'Cortez=' + Cortez.length); Dolores[Dolores.length] = createMarker(new GPoint(-108.55443573,37.38570404),"
Lakeview Elementary School
28567 County Road M
Dolores, CO 81323

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lakeview Elementary School",'Dolores=' + Dolores.length); Cortez[Cortez.length] = createMarker(new GPoint(-108.65655518,37.47172165),"
Lewis-arriola Elementary School
21434 Road U
Cortez, CO 81321

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lewis-arriola Elementary School",'Cortez=' + Cortez.length); Cortez[Cortez.length] = createMarker(new GPoint(-108.58100128,37.34452057),"
Manaugh Elementary School
300 East 4th Street
Cortez, CO 81321

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Manaugh Elementary School",'Cortez=' + Cortez.length); Mancos[Mancos.length] = createMarker(new GPoint(-108.29175568,37.34513855),"
Mancos Elementary School
301 Grand Avenue
Mancos, CO 81328

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mancos Elementary School",'Mancos=' + Mancos.length); Mancos[Mancos.length] = createMarker(new GPoint(-108.29233551,37.34513855),"
Mancos High School
355 West Grand Avenue
Mancos, CO 81328

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Mancos High School",'Mancos=' + Mancos.length); Mancos[Mancos.length] = createMarker(new GPoint(-108.29307556,37.34643936),"
Mancos Middle School
100 South Beech
Mancos, CO 81328

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Mancos Middle School",'Mancos=' + Mancos.length); Cortez[Cortez.length] = createMarker(new GPoint(-108.59828949,37.34136200),"
Mesa Elementary School
703 West 7th Street
Cortez, CO 81321

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mesa Elementary School",'Cortez=' + Cortez.length); Cortez[Cortez.length] = createMarker(new GPoint(-108.58737946,37.34152603),"
Montezuma-cortez High School
206 West 7th Street
Cortez, CO 81321

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Montezuma-cortez High School",'Cortez=' + Cortez.length); Pleasant_View[Pleasant_View.length] = createMarker(new GPoint(-108.77670288,37.58649826),"
Pleasant View Elementary School
P O Box 329
Pleasant View, CO 81331

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Pleasant View Elementary School",'Pleasant_View=' + Pleasant_View.length); Cortez[Cortez.length] = createMarker(new GPoint(-108.58105469,37.34649658),"
Preschool/jumpstart Elementary School
210 South Washington Street
Cortez, CO 81321

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Preschool/jumpstart Elementary School",'Cortez=' + Cortez.length); Cortez[Cortez.length] = createMarker(new GPoint(-108.61889648,37.35340118),"
Southwest Open Charter School
P O Box Dd
Cortez, CO 81321

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Southwest Open Charter School",'Cortez=' + Cortez.length); Dolores[Dolores.length] = createMarker(new GPoint(-108.53560638,37.45802307),"
Teddy Bear Preschool
17631 Highway 145
Dolores, CO 81323

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Teddy Bear Preschool",'Dolores=' + Dolores.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(Cortez); map.removeOverlays(Dolores); map.removeOverlays(Mancos); map.removeOverlays(Pleasant_View); 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(Cortez);map.removeOverlays(Cortez); map.removeOverlays(Dolores); map.removeOverlays(Mancos); map.removeOverlays(Pleasant_View); map.addOverlays(Cortez); centerByArray(Cortez, false, false); cntMarker += Cortez.length; map.addOverlays(Dolores); centerByArray(Dolores, false, false); cntMarker += Dolores.length; map.addOverlays(Mancos); centerByArray(Mancos, false, false); cntMarker += Mancos.length; map.addOverlays(Pleasant_View); centerByArray(Pleasant_View, false, false); cntMarker += Pleasant_View.length; centerByArray(Cortez,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'); } }