function addMarkers() { mySelect = document.getElementById('selection'); Fairmont = [];Blue_Earth = [];Granada = [];Trimont = [];Sherburn = [];Winnebago = [];Truman = [];Welcome = [];mySelect.options[mySelect.options.length] = new Option("Blue Earth schools",'all=Blue_Earth'); mySelect.options[mySelect.options.length] = new Option("Fairmont schools",'all=Fairmont'); mySelect.options[mySelect.options.length] = new Option("Granada schools",'all=Granada'); mySelect.options[mySelect.options.length] = new Option("Sherburn schools",'all=Sherburn'); mySelect.options[mySelect.options.length] = new Option("Trimont schools",'all=Trimont'); mySelect.options[mySelect.options.length] = new Option("Truman schools",'all=Truman'); mySelect.options[mySelect.options.length] = new Option("Welcome schools",'all=Welcome'); mySelect.options[mySelect.options.length] = new Option("Winnebago schools",'all=Winnebago'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Fairmont[Fairmont.length] = createMarker(new GPoint(-94.45975494,43.64178085),"
Budd Elementary School
1001 Albion Avenue
Fairmont, MN 56031

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Budd Elementary School",'Fairmont=' + Fairmont.length); Blue_Earth[Blue_Earth.length] = createMarker(new GPoint(-94.30746460,43.54302979),"
East Chain Elementary School
395 - 280th Avenue
Blue Earth, MN 56013

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("East Chain Elementary School",'Blue_Earth=' + Blue_Earth.length); Fairmont[Fairmont.length] = createMarker(new GPoint(-94.45299530,43.64720917),"
Fairmont Middle School
714 Victoria Street
Fairmont, MN 56031

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Fairmont Middle School",'Fairmont=' + Fairmont.length); Fairmont[Fairmont.length] = createMarker(new GPoint(-94.44892120,43.63734818),"
Fairmont Senior High School
900 Johnson Street
Fairmont, MN 56031

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Fairmont Senior High School",'Fairmont=' + Fairmont.length); Granada[Granada.length] = createMarker(new GPoint(-94.31980133,43.65959930),"
Granada-huntley Secondary School
Po Box 17
Granada, MN 56039

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Granada-huntley Secondary School",'Granada=' + Granada.length); Fairmont[Fairmont.length] = createMarker(new GPoint(-94.43990326,43.66274643),"
Great Plains Academy
1100 Indus St
Fairmont, MN 56031

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Great Plains Academy",'Fairmont=' + Fairmont.length); Fairmont[Fairmont.length] = createMarker(new GPoint(-94.46010900,43.65216500),"
Lincoln Day Facility
115 S Park Street
Fairmont, MN 56031

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Lincoln Day Facility",'Fairmont=' + Fairmont.length); Fairmont[Fairmont.length] = createMarker(new GPoint(-94.46086884,43.66394043),"
Lincoln Elementary School
1200 N. Park St.
Fairmont, MN 56031

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Fairmont=' + Fairmont.length); Trimont[Trimont.length] = createMarker(new GPoint(-94.72059631,43.78310013),"
Martin Cty. W. Junior Middle School
Po Box 408
Trimont, MN 56176

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Martin Cty. W. Junior Middle School",'Trimont=' + Trimont.length); Sherburn[Sherburn.length] = createMarker(new GPoint(-94.73860168,43.66260147),"
Martin Cty. W. Senior High School
16 W 5th Street
Sherburn, MN 56171

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Martin Cty. W. Senior High School",'Sherburn=' + Sherburn.length); Fairmont[Fairmont.length] = createMarker(new GPoint(-94.46060944,43.65286636),"
S.plains Targeted Services
115 S. Park St.
Fairmont, MN 56031

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("S.plains Targeted Services",'Fairmont=' + Fairmont.length); Sherburn[Sherburn.length] = createMarker(new GPoint(-94.73860168,43.66260147),"
Sherburn Elementary School
105 E 5th Street
Sherburn, MN 56171

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Sherburn Elementary School",'Sherburn=' + Sherburn.length); Fairmont[Fairmont.length] = createMarker(new GPoint(-94.46076965,43.65255737),"
Southern Plains Alc High School
115 S Park Street
Fairmont, MN 56031

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Southern Plains Alc High School",'Fairmont=' + Fairmont.length); Winnebago[Winnebago.length] = createMarker(new GPoint(-94.46086884,43.66336441),"
Southern Plains Alc Winnebago High School
1155 Park St.
Winnebago, MN 56031

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Southern Plains Alc Winnebago High School",'Winnebago=' + Winnebago.length); Fairmont[Fairmont.length] = createMarker(new GPoint(-94.46060944,43.65286636),"
Southern Plains Ed. Coop. Elementary School
115 S Park Street
Fairmont, MN 56031

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Southern Plains Ed. Coop. Elementary School",'Fairmont=' + Fairmont.length); Trimont[Trimont.length] = createMarker(new GPoint(-94.72059631,43.78310013),"
Trimont Elementary School
Box 408
Trimont, MN 56176

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Trimont Elementary School",'Trimont=' + Trimont.length); Truman[Truman.length] = createMarker(new GPoint(-94.43440247,43.81980133),"
Truman Elementary School
Box 276
Truman, MN 56088

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Truman Elementary School",'Truman=' + Truman.length); Truman[Truman.length] = createMarker(new GPoint(-94.43440247,43.81980133),"
Truman Secondary School
Box 276
Truman, MN 56088

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Truman Secondary School",'Truman=' + Truman.length); Welcome[Welcome.length] = createMarker(new GPoint(-94.62290192,43.67509842),"
Welcome Elementary School
Box 268
Welcome, MN 56181

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Welcome Elementary School",'Welcome=' + Welcome.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(Blue_Earth); map.removeOverlays(Fairmont); map.removeOverlays(Granada); map.removeOverlays(Sherburn); map.removeOverlays(Trimont); map.removeOverlays(Truman); map.removeOverlays(Welcome); map.removeOverlays(Winnebago); 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(Fairmont);map.removeOverlays(Blue_Earth); map.removeOverlays(Fairmont); map.removeOverlays(Granada); map.removeOverlays(Sherburn); map.removeOverlays(Trimont); map.removeOverlays(Truman); map.removeOverlays(Welcome); map.removeOverlays(Winnebago); map.addOverlays(Blue_Earth); centerByArray(Blue_Earth, false, false); cntMarker += Blue_Earth.length; map.addOverlays(Fairmont); centerByArray(Fairmont, false, false); cntMarker += Fairmont.length; map.addOverlays(Granada); centerByArray(Granada, false, false); cntMarker += Granada.length; map.addOverlays(Sherburn); centerByArray(Sherburn, false, false); cntMarker += Sherburn.length; map.addOverlays(Trimont); centerByArray(Trimont, false, false); cntMarker += Trimont.length; map.addOverlays(Truman); centerByArray(Truman, false, false); cntMarker += Truman.length; map.addOverlays(Welcome); centerByArray(Welcome, false, false); cntMarker += Welcome.length; map.addOverlays(Winnebago); centerByArray(Winnebago, false, false); cntMarker += Winnebago.length; centerByArray(Fairmont,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'); } }