function addMarkers() { mySelect = document.getElementById('selection'); Wray = [];Idalia = [];Yuma = [];Joes = [];mySelect.options[mySelect.options.length] = new Option("Idalia schools",'all=Idalia'); mySelect.options[mySelect.options.length] = new Option("Joes schools",'all=Joes'); mySelect.options[mySelect.options.length] = new Option("Wray schools",'all=Wray'); mySelect.options[mySelect.options.length] = new Option("Yuma schools",'all=Yuma'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Wray[Wray.length] = createMarker(new GPoint(-102.22560120,40.10150146),"
Buchanan Middle School
620 West 7th Street
Wray, CO 80758

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Buchanan Middle School",'Wray=' + Wray.length); Idalia[Idalia.length] = createMarker(new GPoint(-102.21160126,39.71250153),"
Idalia Elementary School
P O Box 40
Idalia, CO 80735

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Idalia Elementary School",'Idalia=' + Idalia.length); Idalia[Idalia.length] = createMarker(new GPoint(-102.21160126,39.71250153),"
Idalia Junior-senior High School
P O Box 40
Idalia, CO 80735

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Idalia Junior-senior High School",'Idalia=' + Idalia.length); Yuma[Yuma.length] = createMarker(new GPoint(-102.72257996,40.12989807),"
Kenneth P Morris Primary School
416 South Elm Street
Yuma, CO 80759

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Kenneth P Morris Primary School",'Yuma=' + Yuma.length); Joes[Joes.length] = createMarker(new GPoint(-102.63800049,39.67070007),"
Liberty Elementary School
P O Box 112
Joes, CO 80822

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Liberty Elementary School",'Joes=' + Joes.length); Joes[Joes.length] = createMarker(new GPoint(-102.63800049,39.67070007),"
Liberty Junior-senior High School
P O Box 112
Joes, CO 80822

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Liberty Junior-senior High School",'Joes=' + Joes.length); Yuma[Yuma.length] = createMarker(new GPoint(-102.73078156,40.12211609),"
Little Indians Preschool
709 West Third Street
Yuma, CO 80759

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Little Indians Preschool",'Yuma=' + Yuma.length); Wray[Wray.length] = createMarker(new GPoint(-102.22560120,40.10150146),"
Wray Elementary School
30074 County Road 35
Wray, CO 80758

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Wray Elementary School",'Wray=' + Wray.length); Wray[Wray.length] = createMarker(new GPoint(-102.22560120,40.10150146),"
Wray High School
30074 County Road 35
Wray, CO 80758

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Wray High School",'Wray=' + Wray.length); Yuma[Yuma.length] = createMarker(new GPoint(-102.72267151,40.11626434),"
Yuma High School
1000 South Albany
Yuma, CO 80759

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Yuma High School",'Yuma=' + Yuma.length); Yuma[Yuma.length] = createMarker(new GPoint(-102.73078156,40.12126160),"
Yuma Middle School
500 South Elm
Yuma, CO 80759

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Yuma Middle School",'Yuma=' + Yuma.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(Idalia); map.removeOverlays(Joes); map.removeOverlays(Wray); map.removeOverlays(Yuma); 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(Wray);map.removeOverlays(Idalia); map.removeOverlays(Joes); map.removeOverlays(Wray); map.removeOverlays(Yuma); map.addOverlays(Idalia); centerByArray(Idalia, false, false); cntMarker += Idalia.length; map.addOverlays(Joes); centerByArray(Joes, false, false); cntMarker += Joes.length; map.addOverlays(Wray); centerByArray(Wray, false, false); cntMarker += Wray.length; map.addOverlays(Yuma); centerByArray(Yuma, false, false); cntMarker += Yuma.length; centerByArray(Wray,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'); } }