function addMarkers() { mySelect = document.getElementById('selection'); Clara_City = [];Maynard = [];Milan = [];Montevideo = [];Granite_Falls = [];Montevedio = [];mySelect.options[mySelect.options.length] = new Option("Clara City schools",'all=Clara_City'); mySelect.options[mySelect.options.length] = new Option("Granite Falls schools",'all=Granite_Falls'); mySelect.options[mySelect.options.length] = new Option("Maynard schools",'all=Maynard'); mySelect.options[mySelect.options.length] = new Option("Milan schools",'all=Milan'); mySelect.options[mySelect.options.length] = new Option("Montevedio schools",'all=Montevedio'); mySelect.options[mySelect.options.length] = new Option("Montevideo schools",'all=Montevideo'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Clara_City[Clara_City.length] = createMarker(new GPoint(-95.35800171,44.98720169),"
M.a.c.c.r.a.y. Alp High School
Box 690
Clara City, MN 56222

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("M.a.c.c.r.a.y. Alp High School",'Clara_City=' + Clara_City.length); Clara_City[Clara_City.length] = createMarker(new GPoint(-95.35800171,44.98720169),"
M.a.c.c.r.a.y. Junior Middle School
Box 690
Clara City, MN 56222

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("M.a.c.c.r.a.y. Junior Middle School",'Clara_City=' + Clara_City.length); Clara_City[Clara_City.length] = createMarker(new GPoint(-95.35800171,44.98720169),"
M.a.c.c.r.a.y. Senior High School
Box 690
Clara City, MN 56222

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("M.a.c.c.r.a.y. Senior High School",'Clara_City=' + Clara_City.length); Maynard[Maynard.length] = createMarker(new GPoint(-95.46900177,44.93159866),"
M.a.c.c.r.a.y. West Elementary School
Box 276
Maynard, MN 56260

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("M.a.c.c.r.a.y. West Elementary School",'Maynard=' + Maynard.length); Milan[Milan.length] = createMarker(new GPoint(-95.91461945,45.11223602),"
Milan Elementary School
408 S 4th Street
Milan, MN 56262

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Milan Elementary School",'Milan=' + Milan.length); Montevideo[Montevideo.length] = createMarker(new GPoint(-95.72945404,44.94808197),"
Minnesota Valley Alc-seatbased High School
Box 471
Montevideo, MN 56265

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Minnesota Valley Alc-seatbased High School",'Montevideo=' + Montevideo.length); Montevideo[Montevideo.length] = createMarker(new GPoint(-95.71749900,44.95171000),"
Mn River Valley Alc-summer
Box 471
Montevideo, MN 56265

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Mn River Valley Alc-summer",'Montevideo=' + Montevideo.length); Montevideo[Montevideo.length] = createMarker(new GPoint(-95.71749900,44.95171000),"
Mn River Valley Targeted Services
Box 471
Montevideo, MN 56265

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Mn River Valley Targeted Services",'Montevideo=' + Montevideo.length); Granite_Falls[Granite_Falls.length] = createMarker(new GPoint(-95.53916168,44.80953598),"
Mn Valley Alc - Granite Falls High School
895 Prentice, Ste. 2
Granite Falls, MN 56241

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Mn Valley Alc - Granite Falls High School",'Granite_Falls=' + Granite_Falls.length); Montevedio[Montevedio.length] = createMarker(new GPoint(-95.69339752,44.99660110),"
Mn Valley Alc - Ind. Study High School
Box 471
Montevedio, MN 56265

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Mn Valley Alc - Ind. Study High School",'Montevedio=' + Montevedio.length); Montevideo[Montevideo.length] = createMarker(new GPoint(-95.70655823,44.93824387),"
Montevideo Middle School
2001 William Avenue
Montevideo, MN 56265

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Montevideo Middle School",'Montevideo=' + Montevideo.length); Montevideo[Montevideo.length] = createMarker(new GPoint(-95.70815277,44.93819427),"
Montevideo Senior High School
1501 William Avenue
Montevideo, MN 56265

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Montevideo Senior High School",'Montevideo=' + Montevideo.length); Montevideo[Montevideo.length] = createMarker(new GPoint(-95.71989441,44.95853806),"
Ramsey Elementary School
501 Hamilton Avenue
Montevideo, MN 56265

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Ramsey Elementary School",'Montevideo=' + Montevideo.length); Montevideo[Montevideo.length] = createMarker(new GPoint(-95.71050262,44.94247818),"
Sanford Elementary School
412 S 13th Street
Montevideo, MN 56265

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Sanford Elementary School",'Montevideo=' + Montevideo.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(Clara_City); map.removeOverlays(Granite_Falls); map.removeOverlays(Maynard); map.removeOverlays(Milan); map.removeOverlays(Montevedio); map.removeOverlays(Montevideo); 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(Clara_City);map.removeOverlays(Clara_City); map.removeOverlays(Granite_Falls); map.removeOverlays(Maynard); map.removeOverlays(Milan); map.removeOverlays(Montevedio); map.removeOverlays(Montevideo); map.addOverlays(Clara_City); centerByArray(Clara_City, false, false); cntMarker += Clara_City.length; map.addOverlays(Granite_Falls); centerByArray(Granite_Falls, false, false); cntMarker += Granite_Falls.length; map.addOverlays(Maynard); centerByArray(Maynard, false, false); cntMarker += Maynard.length; map.addOverlays(Milan); centerByArray(Milan, false, false); cntMarker += Milan.length; map.addOverlays(Montevedio); centerByArray(Montevedio, false, false); cntMarker += Montevedio.length; map.addOverlays(Montevideo); centerByArray(Montevideo, false, false); cntMarker += Montevideo.length; centerByArray(Clara_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'); } }