function addMarkers() { mySelect = document.getElementById('selection'); Cheraw = [];La_Junta = [];Fowler = [];Rocky_Ford = [];Manzanola = [];Swink = [];mySelect.options[mySelect.options.length] = new Option("Cheraw schools",'all=Cheraw'); mySelect.options[mySelect.options.length] = new Option("Fowler schools",'all=Fowler'); mySelect.options[mySelect.options.length] = new Option("La Junta schools",'all=La_Junta'); mySelect.options[mySelect.options.length] = new Option("Manzanola schools",'all=Manzanola'); mySelect.options[mySelect.options.length] = new Option("Rocky Ford schools",'all=Rocky_Ford'); mySelect.options[mySelect.options.length] = new Option("Swink schools",'all=Swink'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Cheraw[Cheraw.length] = createMarker(new GPoint(-103.50969696,38.10689926),"
Cheraw Elementary School
P O Box 160
Cheraw, CO 81030

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Cheraw Elementary School",'Cheraw=' + Cheraw.length); Cheraw[Cheraw.length] = createMarker(new GPoint(-103.50969696,38.10689926),"
Cheraw High School
P O Box 160
Cheraw, CO 81030

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cheraw High School",'Cheraw=' + Cheraw.length); Cheraw[Cheraw.length] = createMarker(new GPoint(-103.50969696,38.10689926),"
Cheraw Middle School
P O Box 160
Cheraw, CO 81030

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Cheraw Middle School",'Cheraw=' + Cheraw.length); La_Junta[La_Junta.length] = createMarker(new GPoint(-103.53482819,37.98066711),"
Columbian Elementary School
800 Grace
La Junta, CO 81050

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Columbian Elementary School",'La_Junta=' + La_Junta.length); Fowler[Fowler.length] = createMarker(new GPoint(-104.07720184,38.02280045),"
Fowler Elementary School
P O Box 218
Fowler, CO 80139

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Fowler Elementary School",'Fowler=' + Fowler.length); Fowler[Fowler.length] = createMarker(new GPoint(-104.05380249,38.01800156),"
Fowler High School
P.o. Box 218
Fowler, CO 81039

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Fowler High School",'Fowler=' + Fowler.length); Fowler[Fowler.length] = createMarker(new GPoint(-104.05380249,38.01800156),"
Fowler Junior High School
P O Box 218
Fowler, CO 81039

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Fowler Junior High School",'Fowler=' + Fowler.length); Rocky_Ford[Rocky_Ford.length] = createMarker(new GPoint(-103.72473907,38.05013657),"
Jefferson Middle School
601 South 8th St.
Rocky Ford, CO 81067

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Jefferson Middle School",'Rocky_Ford=' + Rocky_Ford.length); La_Junta[La_Junta.length] = createMarker(new GPoint(-103.53934479,37.97136307),"
La Junta High School
1817 Smithland
La Junta, CO 81050

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("La Junta High School",'La_Junta=' + La_Junta.length); La_Junta[La_Junta.length] = createMarker(new GPoint(-103.52526093,37.98267746),"
La Junta Intermediate School
1401 East Sixth Street
La Junta, CO 81050

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("La Junta Intermediate School",'La_Junta=' + La_Junta.length); La_Junta[La_Junta.length] = createMarker(new GPoint(-103.53887939,37.97991562),"
La Junta Middle School
901 Smithland
La Junta, CO 81050

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("La Junta Middle School",'La_Junta=' + La_Junta.length); La_Junta[La_Junta.length] = createMarker(new GPoint(-103.55764771,37.98247910),"
La Junta Primary School
600 West Topeka
La Junta, CO 81050

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("La Junta Primary School",'La_Junta=' + La_Junta.length); Rocky_Ford[Rocky_Ford.length] = createMarker(new GPoint(-103.72473907,38.05013657),"
Liberty Elementary School
601 South 8th Street
Rocky Ford, CO 81067

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Liberty Elementary School",'Rocky_Ford=' + Rocky_Ford.length); Manzanola[Manzanola.length] = createMarker(new GPoint(-103.87729645,38.06150055),"
Manzanola Elementary School
P O Box 148
Manzanola, CO 81058

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Manzanola Elementary School",'Manzanola=' + Manzanola.length); Manzanola[Manzanola.length] = createMarker(new GPoint(-103.87729645,38.06150055),"
Manzanola Junior-senior High School
P O Box 148
Manzanola, CO 81058

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Manzanola Junior-senior High School",'Manzanola=' + Manzanola.length); Fowler[Fowler.length] = createMarker(new GPoint(-104.05380249,38.01800156),"
Park Elementary School
P O Box 218
Fowler, CO 81039

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Park Elementary School",'Fowler=' + Fowler.length); Rocky_Ford[Rocky_Ford.length] = createMarker(new GPoint(-103.72421265,38.05031967),"
Rocky Ford High School
601 South 8th Street
Rocky Ford, CO 81067

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Rocky Ford High School",'Rocky_Ford=' + Rocky_Ford.length); Swink[Swink.length] = createMarker(new GPoint(-103.62770081,38.01440048),"
Swink Elementary School
P O Box 487
Swink, CO 81077

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Swink Elementary School",'Swink=' + Swink.length); Swink[Swink.length] = createMarker(new GPoint(-103.62770081,38.01440048),"
Swink Junior-senior High School
P O Box 487
Swink, CO 81077

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Swink Junior-senior High School",'Swink=' + Swink.length); La_Junta[La_Junta.length] = createMarker(new GPoint(-103.62860107,38.00994110),"
Tiger Learning Center
1817 Smithland
La Junta, CO 81050

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Tiger Learning Center",'La_Junta=' + La_Junta.length); Rocky_Ford[Rocky_Ford.length] = createMarker(new GPoint(-103.72473907,38.05013657),"
Washington Primary School
601 South 8th Street
Rocky Ford, CO 81067

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Washington Primary School",'Rocky_Ford=' + Rocky_Ford.length); Fowler[Fowler.length] = createMarker(new GPoint(-104.05380249,38.01800156),"
West Elementary School
P O Box 218
Fowler, CO 81039

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("West Elementary School",'Fowler=' + Fowler.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(Cheraw); map.removeOverlays(Fowler); map.removeOverlays(La_Junta); map.removeOverlays(Manzanola); map.removeOverlays(Rocky_Ford); map.removeOverlays(Swink); 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(Cheraw);map.removeOverlays(Cheraw); map.removeOverlays(Fowler); map.removeOverlays(La_Junta); map.removeOverlays(Manzanola); map.removeOverlays(Rocky_Ford); map.removeOverlays(Swink); map.addOverlays(Cheraw); centerByArray(Cheraw, false, false); cntMarker += Cheraw.length; map.addOverlays(Fowler); centerByArray(Fowler, false, false); cntMarker += Fowler.length; map.addOverlays(La_Junta); centerByArray(La_Junta, false, false); cntMarker += La_Junta.length; map.addOverlays(Manzanola); centerByArray(Manzanola, false, false); cntMarker += Manzanola.length; map.addOverlays(Rocky_Ford); centerByArray(Rocky_Ford, false, false); cntMarker += Rocky_Ford.length; map.addOverlays(Swink); centerByArray(Swink, false, false); cntMarker += Swink.length; centerByArray(Cheraw,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'); } }