function addMarkers() { mySelect = document.getElementById('selection'); Chatfield = [];Preston = [];Harmony = [];Spring_Valley = [];Wykoff = [];Lanesboro = [];Mabel = [];Rushford = [];Peterson = [];mySelect.options[mySelect.options.length] = new Option("Chatfield schools",'all=Chatfield'); mySelect.options[mySelect.options.length] = new Option("Harmony schools",'all=Harmony'); mySelect.options[mySelect.options.length] = new Option("Lanesboro schools",'all=Lanesboro'); mySelect.options[mySelect.options.length] = new Option("Mabel schools",'all=Mabel'); mySelect.options[mySelect.options.length] = new Option("Peterson schools",'all=Peterson'); mySelect.options[mySelect.options.length] = new Option("Preston schools",'all=Preston'); mySelect.options[mySelect.options.length] = new Option("Rushford schools",'all=Rushford'); mySelect.options[mySelect.options.length] = new Option("Spring Valley schools",'all=Spring_Valley'); mySelect.options[mySelect.options.length] = new Option("Wykoff schools",'all=Wykoff'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Chatfield[Chatfield.length] = createMarker(new GPoint(-92.19252777,43.85086441),"
Chosen Valley Elementary School
405 S Main
Chatfield, MN 55923

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Chosen Valley Elementary School",'Chatfield=' + Chatfield.length); Preston[Preston.length] = createMarker(new GPoint(-92.09619904,43.66650009),"
Fillmore Central Elementary School
Box 50
Preston, MN 55965

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Fillmore Central Elementary School",'Preston=' + Preston.length); Preston[Preston.length] = createMarker(new GPoint(-92.09619904,43.66650009),"
Fillmore Central Middle School
Box 50
Preston, MN 55965

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Fillmore Central Middle School",'Preston=' + Preston.length); Harmony[Harmony.length] = createMarker(new GPoint(-92.04609680,43.56359863),"
Fillmore Central Senior High School
Box 599
Harmony, MN 55939

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Fillmore Central Senior High School",'Harmony=' + Harmony.length); Spring_Valley[Spring_Valley.length] = createMarker(new GPoint(-92.39093781,43.68508530),"
Kingsland Alternative Program High School
Box 189
Spring Valley, MN 55975

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Kingsland Alternative Program High School",'Spring_Valley=' + Spring_Valley.length); Spring_Valley[Spring_Valley.length] = createMarker(new GPoint(-92.39102936,43.68400955),"
Kingsland Elementary School
409 S Broadway Avenue
Spring Valley, MN 55975

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Kingsland Elementary School",'Spring_Valley=' + Spring_Valley.length); Wykoff[Wykoff.length] = createMarker(new GPoint(-92.26629639,43.71789932),"
Kingsland Middle School
Box 96
Wykoff, MN 55990

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Kingsland Middle School",'Wykoff=' + Wykoff.length); Spring_Valley[Spring_Valley.length] = createMarker(new GPoint(-92.38899231,43.69473267),"
Kingsland Senior High School
705 N Section Avenue
Spring Valley, MN 55975

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Kingsland Senior High School",'Spring_Valley=' + Spring_Valley.length); Lanesboro[Lanesboro.length] = createMarker(new GPoint(-91.97660828,43.71663666),"
Lanesboro Elementary School
100 Kirkwood Street E
Lanesboro, MN 55949

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lanesboro Elementary School",'Lanesboro=' + Lanesboro.length); Lanesboro[Lanesboro.length] = createMarker(new GPoint(-91.97660828,43.71663666),"
Lanesboro Secondary School
100 Kirkwood
Lanesboro, MN 55949

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Lanesboro Secondary School",'Lanesboro=' + Lanesboro.length); Mabel[Mabel.length] = createMarker(new GPoint(-91.77480316,43.56290054),"
Mabel-canton Elementary School
Box 337
Mabel, MN 55954

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mabel-canton Elementary School",'Mabel=' + Mabel.length); Mabel[Mabel.length] = createMarker(new GPoint(-91.77108900,43.52305000),"
Mabel-canton Middle School
Box 337
Mabel, MN 55954

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Mabel-canton Middle School",'Mabel=' + Mabel.length); Mabel[Mabel.length] = createMarker(new GPoint(-91.77480316,43.56290054),"
Mabel-canton Secondary School
Box 337
Mabel, MN 55954

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Mabel-canton Secondary School",'Mabel=' + Mabel.length); Harmony[Harmony.length] = createMarker(new GPoint(-92.01002400,43.55282500),"
Root River Day Treatment School
Box 544
Harmony, MN 55939

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Root River Day Treatment School",'Harmony=' + Harmony.length); Harmony[Harmony.length] = createMarker(new GPoint(-92.04609680,43.56359863),"
Root River Ed. District
Box 544
Harmony, MN 55939

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Root River Ed. District",'Harmony=' + Harmony.length); Rushford[Rushford.length] = createMarker(new GPoint(-91.74890137,43.81719971),"
Rushford-peterson Elementary School
P.o. Box 627
Rushford, MN 55971

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Rushford-peterson Elementary School",'Rushford=' + Rushford.length); Peterson[Peterson.length] = createMarker(new GPoint(-91.83519745,43.77830124),"
Rushford-peterson Middle School
P.o. Box 8
Peterson, MN 55962

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Rushford-peterson Middle School",'Peterson=' + Peterson.length); Rushford[Rushford.length] = createMarker(new GPoint(-91.74890137,43.81719971),"
Rushford-peterson Senior High School
P.o. Box 627
Rushford, MN 55971

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Rushford-peterson Senior High School",'Rushford=' + Rushford.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(Chatfield); map.removeOverlays(Harmony); map.removeOverlays(Lanesboro); map.removeOverlays(Mabel); map.removeOverlays(Peterson); map.removeOverlays(Preston); map.removeOverlays(Rushford); map.removeOverlays(Spring_Valley); map.removeOverlays(Wykoff); 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(Chatfield);map.removeOverlays(Chatfield); map.removeOverlays(Harmony); map.removeOverlays(Lanesboro); map.removeOverlays(Mabel); map.removeOverlays(Peterson); map.removeOverlays(Preston); map.removeOverlays(Rushford); map.removeOverlays(Spring_Valley); map.removeOverlays(Wykoff); map.addOverlays(Chatfield); centerByArray(Chatfield, false, false); cntMarker += Chatfield.length; map.addOverlays(Harmony); centerByArray(Harmony, false, false); cntMarker += Harmony.length; map.addOverlays(Lanesboro); centerByArray(Lanesboro, false, false); cntMarker += Lanesboro.length; map.addOverlays(Mabel); centerByArray(Mabel, false, false); cntMarker += Mabel.length; map.addOverlays(Peterson); centerByArray(Peterson, false, false); cntMarker += Peterson.length; map.addOverlays(Preston); centerByArray(Preston, false, false); cntMarker += Preston.length; map.addOverlays(Rushford); centerByArray(Rushford, false, false); cntMarker += Rushford.length; map.addOverlays(Spring_Valley); centerByArray(Spring_Valley, false, false); cntMarker += Spring_Valley.length; map.addOverlays(Wykoff); centerByArray(Wykoff, false, false); cntMarker += Wykoff.length; centerByArray(Chatfield,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'); } }