function addMarkers() { mySelect = document.getElementById('selection'); Sterling = [];Iliff = [];Fleming = [];Merino = [];Peetz = [];mySelect.options[mySelect.options.length] = new Option("Fleming schools",'all=Fleming'); mySelect.options[mySelect.options.length] = new Option("Iliff schools",'all=Iliff'); mySelect.options[mySelect.options.length] = new Option("Merino schools",'all=Merino'); mySelect.options[mySelect.options.length] = new Option("Peetz schools",'all=Peetz'); mySelect.options[mySelect.options.length] = new Option("Sterling schools",'all=Sterling'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Sterling[Sterling.length] = createMarker(new GPoint(-103.22174072,40.60908890),"
Ayres Elementary School
1812 Robin Road
Sterling, CO 80751

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Ayres Elementary School",'Sterling=' + Sterling.length); Iliff[Iliff.length] = createMarker(new GPoint(-103.06665802,40.75928116),"
Caliche Elementary School
Route 1
Iliff, CO 80736

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Caliche Elementary School",'Iliff=' + Iliff.length); Iliff[Iliff.length] = createMarker(new GPoint(-103.06665802,40.75928116),"
Caliche Junior-senior High School
Route 1
Iliff, CO 80736

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Caliche Junior-senior High School",'Iliff=' + Iliff.length); Sterling[Sterling.length] = createMarker(new GPoint(-103.22379303,40.62933731),"
Campbell Elementary School
902 Clark Street
Sterling, CO 80751

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Campbell Elementary School",'Sterling=' + Sterling.length); Fleming[Fleming.length] = createMarker(new GPoint(-102.84091949,40.68447113),"
Fleming Elementary School
506 North Fremont Ave
Fleming, CO 80728

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Fleming Elementary School",'Fleming=' + Fleming.length); Fleming[Fleming.length] = createMarker(new GPoint(-102.84091949,40.68447113),"
Fleming High School
506 North Fremont Ave
Fleming, CO 80728

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Fleming High School",'Fleming=' + Fleming.length); Sterling[Sterling.length] = createMarker(new GPoint(-103.19683838,40.64606476),"
Hagen Elementary School
301 Hagen Street
Sterling, CO 80751

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Hagen Elementary School",'Sterling=' + Sterling.length); Merino[Merino.length] = createMarker(new GPoint(-103.35583496,40.48528290),"
Merino Elementary School
442 Lee
Merino, CO 80741

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Merino Elementary School",'Merino=' + Merino.length); Merino[Merino.length] = createMarker(new GPoint(-103.35572815,40.48295593),"
Merino Junior Senior High School
315 Lee
Merino, CO 80741

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Merino Junior Senior High School",'Merino=' + Merino.length); Peetz[Peetz.length] = createMarker(new GPoint(-103.10939789,40.94950104),"
Peetz Elementary School
Po Box 39
Peetz, CO 80747

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Peetz Elementary School",'Peetz=' + Peetz.length); Peetz[Peetz.length] = createMarker(new GPoint(-103.10939789,40.94950104),"
Peetz Junior-senior High School
Po Box 39
Peetz, CO 80747

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Peetz Junior-senior High School",'Peetz=' + Peetz.length); Sterling[Sterling.length] = createMarker(new GPoint(-103.22898102,40.62405396),"
Smith High School
201 South 11th Avenue
Sterling, CO 80751

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Smith High School",'Sterling=' + Sterling.length); Sterling[Sterling.length] = createMarker(new GPoint(-103.21679687,40.63256454),"
Sterling High School
407 West Broadway
Sterling, CO 80751

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Sterling High School",'Sterling=' + Sterling.length); Sterling[Sterling.length] = createMarker(new GPoint(-103.21737671,40.63847733),"
Sterling Middle School
1177 Pawnee Street
Sterling, CO 80751

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Sterling Middle School",'Sterling=' + Sterling.length); Sterling[Sterling.length] = createMarker(new GPoint(-103.20597839,40.63729477),"
Stevens Elementary School
1215 North 5th Street
Sterling, CO 80751

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Stevens Elementary School",'Sterling=' + Sterling.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(Fleming); map.removeOverlays(Iliff); map.removeOverlays(Merino); map.removeOverlays(Peetz); map.removeOverlays(Sterling); 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(Sterling);map.removeOverlays(Fleming); map.removeOverlays(Iliff); map.removeOverlays(Merino); map.removeOverlays(Peetz); map.removeOverlays(Sterling); map.addOverlays(Fleming); centerByArray(Fleming, false, false); cntMarker += Fleming.length; map.addOverlays(Iliff); centerByArray(Iliff, false, false); cntMarker += Iliff.length; map.addOverlays(Merino); centerByArray(Merino, false, false); cntMarker += Merino.length; map.addOverlays(Peetz); centerByArray(Peetz, false, false); cntMarker += Peetz.length; map.addOverlays(Sterling); centerByArray(Sterling, false, false); cntMarker += Sterling.length; centerByArray(Sterling,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'); } }