function addMarkers() { mySelect = document.getElementById('selection'); Canon_City = [];Cotopaxi = [];Florence = [];Penrose = [];mySelect.options[mySelect.options.length] = new Option("Canon City schools",'all=Canon_City'); mySelect.options[mySelect.options.length] = new Option("Cotopaxi schools",'all=Cotopaxi'); mySelect.options[mySelect.options.length] = new Option("Florence schools",'all=Florence'); mySelect.options[mySelect.options.length] = new Option("Penrose schools",'all=Penrose'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Canon_City[Canon_City.length] = createMarker(new GPoint(-105.23293304,38.44977570),"
Canon City High School
1313 College
Canon City, CO 81212

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Canon City High School",'Canon_City=' + Canon_City.length); Canon_City[Canon_City.length] = createMarker(new GPoint(-105.22274017,38.39957047),"
Canon City Middle School
1215 Main Steeet
Canon City, CO 81212

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Canon City Middle School",'Canon_City=' + Canon_City.length); Cotopaxi[Cotopaxi.length] = createMarker(new GPoint(-105.51599884,38.34479904),"
Cotopaxi Elementary School
P O Box 385
Cotopaxi, CO 81223

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Cotopaxi Elementary School",'Cotopaxi=' + Cotopaxi.length); Cotopaxi[Cotopaxi.length] = createMarker(new GPoint(-105.62096600,38.39344500),"
Cotopaxi Home-school Partnership School
P O Box 385
Cotopaxi, CO 81223

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cotopaxi Home-school Partnership School",'Cotopaxi=' + Cotopaxi.length); Cotopaxi[Cotopaxi.length] = createMarker(new GPoint(-105.51599884,38.34479904),"
Cotopaxi Junior-senior High School
P O Box 385
Cotopaxi, CO 81223

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cotopaxi Junior-senior High School",'Cotopaxi=' + Cotopaxi.length); Florence[Florence.length] = createMarker(new GPoint(-105.12036133,38.39172363),"
Florence High School
215 North Maple Avenue
Florence, CO 81226

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Florence High School",'Florence=' + Florence.length); Florence[Florence.length] = createMarker(new GPoint(-105.12203217,38.39508438),"
Fremont Elementary School
500 West 5th Street
Florence, CO 81226

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Fremont Elementary School",'Florence=' + Florence.length); Florence[Florence.length] = createMarker(new GPoint(-105.12203217,38.39508438),"
Fremont Middle School
500 West 5th Street
Florence, CO 81226

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Fremont Middle School",'Florence=' + Florence.length); Canon_City[Canon_City.length] = createMarker(new GPoint(-105.24024200,38.44195175),"
Garden Park High School
201 North Sixth Street
Canon City, CO 81212

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Garden Park High School",'Canon_City=' + Canon_City.length); Canon_City[Canon_City.length] = createMarker(new GPoint(-105.21435547,38.45333481),"
Harrison Elementary School
485 North Cottonwood
Canon City, CO 81212

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Harrison Elementary School",'Canon_City=' + Canon_City.length); Canon_City[Canon_City.length] = createMarker(new GPoint(-105.23931122,38.43264389),"
Lincoln Elementary School
420 Myrtle Avenue
Canon City, CO 81212

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Canon_City=' + Canon_City.length); Canon_City[Canon_City.length] = createMarker(new GPoint(-105.24227142,38.43299484),"
Madison Exploratory School
202 East Douglas
Canon City, CO 81212

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Madison Exploratory School",'Canon_City=' + Canon_City.length); Canon_City[Canon_City.length] = createMarker(new GPoint(-105.21422577,38.43150711),"
Mc Kinley Elementary School
1240 Mc Kinley
Canon City, CO 81212

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mc Kinley Elementary School",'Canon_City=' + Canon_City.length); Canon_City[Canon_City.length] = createMarker(new GPoint(-105.20887756,38.46142578),"
Mount View Core Knowledge Charter School
809 Field Avenue
Canon City, CO 81212

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mount View Core Knowledge Charter School",'Canon_City=' + Canon_City.length); Florence[Florence.length] = createMarker(new GPoint(-105.12144470,38.39496613),"
Peakview Academy Alternative School
403 West 5th
Florence, CO 81226

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Peakview Academy Alternative School",'Florence=' + Florence.length); Penrose[Penrose.length] = createMarker(new GPoint(-105.01982880,38.42212677),"
Penrose Elementary School
100 Illinois
Penrose, CO 81240

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Penrose Elementary School",'Penrose=' + Penrose.length); Penrose[Penrose.length] = createMarker(new GPoint(-105.01982880,38.42212677),"
Penrose Middle School
100 Illinois
Penrose, CO 81240

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Penrose Middle School",'Penrose=' + Penrose.length); Canon_City[Canon_City.length] = createMarker(new GPoint(-105.23892212,38.46773529),"
Skyline Elementary School
2855 North 9th Street
Canon City, CO 81212

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Skyline Elementary School",'Canon_City=' + Canon_City.length); Canon_City[Canon_City.length] = createMarker(new GPoint(-105.23824310,38.44707108),"
Washington Elementary School
606 North 9th Street
Canon City, CO 81212

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Washington Elementary School",'Canon_City=' + Canon_City.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(Canon_City); map.removeOverlays(Cotopaxi); map.removeOverlays(Florence); map.removeOverlays(Penrose); 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(Canon_City);map.removeOverlays(Canon_City); map.removeOverlays(Cotopaxi); map.removeOverlays(Florence); map.removeOverlays(Penrose); map.addOverlays(Canon_City); centerByArray(Canon_City, false, false); cntMarker += Canon_City.length; map.addOverlays(Cotopaxi); centerByArray(Cotopaxi, false, false); cntMarker += Cotopaxi.length; map.addOverlays(Florence); centerByArray(Florence, false, false); cntMarker += Florence.length; map.addOverlays(Penrose); centerByArray(Penrose, false, false); cntMarker += Penrose.length; centerByArray(Canon_City,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'); } }