function addMarkers() { mySelect = document.getElementById('selection'); Mankato = [];North_Mankato = [];Eagle_Lake = [];Janesville = [];Lake_Crystal = [];Mapleton = [];Minnesota_Lake = [];Good_Thunder = [];Amboy = [];St_Clair = [];mySelect.options[mySelect.options.length] = new Option("Amboy schools",'all=Amboy'); mySelect.options[mySelect.options.length] = new Option("Eagle Lake schools",'all=Eagle_Lake'); mySelect.options[mySelect.options.length] = new Option("Good Thunder schools",'all=Good_Thunder'); mySelect.options[mySelect.options.length] = new Option("Janesville schools",'all=Janesville'); mySelect.options[mySelect.options.length] = new Option("Lake Crystal schools",'all=Lake_Crystal'); mySelect.options[mySelect.options.length] = new Option("Mankato schools",'all=Mankato'); mySelect.options[mySelect.options.length] = new Option("Mapleton schools",'all=Mapleton'); mySelect.options[mySelect.options.length] = new Option("Minnesota Lake schools",'all=Minnesota_Lake'); mySelect.options[mySelect.options.length] = new Option("North Mankato schools",'all=North_Mankato'); mySelect.options[mySelect.options.length] = new Option("St Clair schools",'all=St_Clair'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Mankato[Mankato.length] = createMarker(new GPoint(-94.00145721,44.16650772),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bridges Community Elementary School",'Mankato=' + Mankato.length); Mankato[Mankato.length] = createMarker(new GPoint(-94.00904846,44.15713882),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Central High School Alc",'Mankato=' + Mankato.length); Mankato[Mankato.length] = createMarker(new GPoint(-94.00904846,44.15713882),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Central Mid. School Alp",'Mankato=' + Mankato.length); North_Mankato[North_Mankato.length] = createMarker(new GPoint(-94.00360107,44.16379929),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Dakota Meadows Junior Middle School",'North_Mankato=' + North_Mankato.length); Eagle_Lake[Eagle_Lake.length] = createMarker(new GPoint(-93.85790253,44.15700150),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Eagle Lake Elementary School",'Eagle_Lake=' + Eagle_Lake.length); Mankato[Mankato.length] = createMarker(new GPoint(-93.99401855,44.17449951),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Franklin Elementary School",'Mankato=' + Mankato.length); Janesville[Janesville.length] = createMarker(new GPoint(-93.69560242,44.10889816),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Janesville-waldorf-pemberton Elementary School",'Janesville=' + Janesville.length); Mankato[Mankato.length] = createMarker(new GPoint(-94.00761414,44.15382767),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'Mankato=' + Mankato.length); Mankato[Mankato.length] = createMarker(new GPoint(-93.99610138,44.15489960),"",iconGr); mySelect.options[mySelect.options.length] = new Option("K.i.d.s Program",'Mankato=' + Mankato.length); Mankato[Mankato.length] = createMarker(new GPoint(-93.96150970,44.16013718),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Kennedy Elementary School",'Mankato=' + Mankato.length); Mankato[Mankato.length] = createMarker(new GPoint(-94.00876400,44.15710100),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Life Lines Adult Conn. High School",'Mankato=' + Mankato.length); Lake_Crystal[Lake_Crystal.length] = createMarker(new GPoint(-94.23210144,44.12459946),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lk Crystal Welcome Memorial Elementary School",'Lake_Crystal=' + Lake_Crystal.length); Lake_Crystal[Lake_Crystal.length] = createMarker(new GPoint(-94.23210144,44.12459946),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Lk Crystal-wellcome Memorial Secondary School",'Lake_Crystal=' + Lake_Crystal.length); Mankato[Mankato.length] = createMarker(new GPoint(-94.00360107,44.16379929),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Mankato East Junior Middle School",'Mankato=' + Mankato.length); Mankato[Mankato.length] = createMarker(new GPoint(-94.00360107,44.16379929),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Mankato East Senior High School",'Mankato=' + Mankato.length); Mankato[Mankato.length] = createMarker(new GPoint(-94.00288900,44.16759700),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Mankato Targeted Services",'Mankato=' + Mankato.length); Mankato[Mankato.length] = createMarker(new GPoint(-94.00360107,44.16379929),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Mankato West Senior High School",'Mankato=' + Mankato.length); Mapleton[Mapleton.length] = createMarker(new GPoint(-93.93830109,43.92750168),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Maple River Central Elementary School",'Mapleton=' + Mapleton.length); Minnesota_Lake[Minnesota_Lake.length] = createMarker(new GPoint(-93.82099915,43.83919907),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Maple River East Elementary School",'Minnesota_Lake=' + Minnesota_Lake.length); Minnesota_Lake[Minnesota_Lake.length] = createMarker(new GPoint(-93.82099915,43.83919907),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Maple River East Middle School",'Minnesota_Lake=' + Minnesota_Lake.length); Mapleton[Mapleton.length] = createMarker(new GPoint(-93.93830109,43.92750168),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Maple River Senior High School",'Mapleton=' + Mapleton.length); Good_Thunder[Good_Thunder.length] = createMarker(new GPoint(-94.06250000,43.97340012),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Maple River West Elementary School",'Good_Thunder=' + Good_Thunder.length); Amboy[Amboy.length] = createMarker(new GPoint(-94.19979858,43.89130020),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Maple River West Middle School",'Amboy=' + Amboy.length); Mankato[Mankato.length] = createMarker(new GPoint(-93.97222137,44.15802383),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Riverbend Academy Charter School",'Mankato=' + Mankato.length); Mankato[Mankato.length] = createMarker(new GPoint(-94.02108765,44.15806198),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Roosevelt Elementary School",'Mankato=' + Mankato.length); St_Clair[St_Clair.length] = createMarker(new GPoint(-93.83580017,44.07659912),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Saint Clair Elementary School",'St_Clair=' + St_Clair.length); St_Clair[St_Clair.length] = createMarker(new GPoint(-93.83580017,44.07659912),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Saint Clair Secondary School",'St_Clair=' + St_Clair.length); Mankato[Mankato.length] = createMarker(new GPoint(-93.98104095,44.16313553),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Washington Elementary School",'Mankato=' + Mankato.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(Amboy); map.removeOverlays(Eagle_Lake); map.removeOverlays(Good_Thunder); map.removeOverlays(Janesville); map.removeOverlays(Lake_Crystal); map.removeOverlays(Mankato); map.removeOverlays(Mapleton); map.removeOverlays(Minnesota_Lake); map.removeOverlays(North_Mankato); map.removeOverlays(St_Clair); 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(Mankato);map.removeOverlays(Amboy); map.removeOverlays(Eagle_Lake); map.removeOverlays(Good_Thunder); map.removeOverlays(Janesville); map.removeOverlays(Lake_Crystal); map.removeOverlays(Mankato); map.removeOverlays(Mapleton); map.removeOverlays(Minnesota_Lake); map.removeOverlays(North_Mankato); map.removeOverlays(St_Clair); map.addOverlays(Amboy); centerByArray(Amboy, false, false); cntMarker += Amboy.length; map.addOverlays(Eagle_Lake); centerByArray(Eagle_Lake, false, false); cntMarker += Eagle_Lake.length; map.addOverlays(Good_Thunder); centerByArray(Good_Thunder, false, false); cntMarker += Good_Thunder.length; map.addOverlays(Janesville); centerByArray(Janesville, false, false); cntMarker += Janesville.length; map.addOverlays(Lake_Crystal); centerByArray(Lake_Crystal, false, false); cntMarker += Lake_Crystal.length; map.addOverlays(Mankato); centerByArray(Mankato, false, false); cntMarker += Mankato.length; map.addOverlays(Mapleton); centerByArray(Mapleton, false, false); cntMarker += Mapleton.length; map.addOverlays(Minnesota_Lake); centerByArray(Minnesota_Lake, false, false); cntMarker += Minnesota_Lake.length; map.addOverlays(North_Mankato); centerByArray(North_Mankato, false, false); cntMarker += North_Mankato.length; map.addOverlays(St_Clair); centerByArray(St_Clair, false, false); cntMarker += St_Clair.length; centerByArray(Mankato,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'); } }