function addMarkers() { mySelect = document.getElementById('selection'); Balaton = [];Marshall = [];Cottonwood = [];Wood_Lake = [];Lynd = [];Minneota = [];Russell = [];Tracy = [];mySelect.options[mySelect.options.length] = new Option("Balaton schools",'all=Balaton'); mySelect.options[mySelect.options.length] = new Option("Cottonwood schools",'all=Cottonwood'); mySelect.options[mySelect.options.length] = new Option("Lynd schools",'all=Lynd'); mySelect.options[mySelect.options.length] = new Option("Marshall schools",'all=Marshall'); mySelect.options[mySelect.options.length] = new Option("Minneota schools",'all=Minneota'); mySelect.options[mySelect.options.length] = new Option("Russell schools",'all=Russell'); mySelect.options[mySelect.options.length] = new Option("Tracy schools",'all=Tracy'); mySelect.options[mySelect.options.length] = new Option("Wood Lake schools",'all=Wood_Lake'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Balaton[Balaton.length] = createMarker(new GPoint(-95.88719940,44.21889877),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Balaton Elementary School",'Balaton=' + Balaton.length); Marshall[Marshall.length] = createMarker(new GPoint(-95.78170776,44.45026398),"",iconRd); mySelect.options[mySelect.options.length] = new Option("East Side Elementary School",'Marshall=' + Marshall.length); Cottonwood[Cottonwood.length] = createMarker(new GPoint(-95.69409943,44.59849930),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lakeview Elementary School",'Cottonwood=' + Cottonwood.length); Wood_Lake[Wood_Lake.length] = createMarker(new GPoint(-95.53839874,44.64260101),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Lakeview Middle School",'Wood_Lake=' + Wood_Lake.length); Cottonwood[Cottonwood.length] = createMarker(new GPoint(-95.69409943,44.59849930),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Lakeview Secondary School",'Cottonwood=' + Cottonwood.length); Lynd[Lynd.length] = createMarker(new GPoint(-95.91089630,44.40029907),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lynd Elementary School",'Lynd=' + Lynd.length); Marshall[Marshall.length] = createMarker(new GPoint(-95.78994751,44.44953156),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Marshall Junior Middle School",'Marshall=' + Marshall.length); Marshall[Marshall.length] = createMarker(new GPoint(-95.78590393,44.44035339),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Marshall Senior High School",'Marshall=' + Marshall.length); Marshall[Marshall.length] = createMarker(new GPoint(-95.76170349,44.45034409),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Mec Learning Alternatives",'Marshall=' + Marshall.length); Marshall[Marshall.length] = createMarker(new GPoint(-95.79167300,44.44901000),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Mec Targeted Services",'Marshall=' + Marshall.length); Minneota[Minneota.length] = createMarker(new GPoint(-95.98570251,44.60039902),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Minneota Elementary School",'Minneota=' + Minneota.length); Minneota[Minneota.length] = createMarker(new GPoint(-95.98570251,44.60039902),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Minneota Secondary School",'Minneota=' + Minneota.length); Marshall[Marshall.length] = createMarker(new GPoint(-95.76900482,44.44296265),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Park Side Elementary School",'Marshall=' + Marshall.length); Russell[Russell.length] = createMarker(new GPoint(-95.95480347,44.32709885),"",iconBl); mySelect.options[mySelect.options.length] = new Option("R.t.r. Middle School",'Russell=' + Russell.length); Tracy[Tracy.length] = createMarker(new GPoint(-95.62360382,44.22776413),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Tracy Elementary School",'Tracy=' + Tracy.length); Tracy[Tracy.length] = createMarker(new GPoint(-95.62784576,44.22426987),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Tracy Secondary School",'Tracy=' + Tracy.length); Marshall[Marshall.length] = createMarker(new GPoint(-95.79656219,44.44294739),"",iconRd); mySelect.options[mySelect.options.length] = new Option("West Side Elementary School",'Marshall=' + Marshall.length); Balaton[Balaton.length] = createMarker(new GPoint(-95.88719940,44.21889877),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Yankton Country Charter School",'Balaton=' + Balaton.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(Balaton); map.removeOverlays(Cottonwood); map.removeOverlays(Lynd); map.removeOverlays(Marshall); map.removeOverlays(Minneota); map.removeOverlays(Russell); map.removeOverlays(Tracy); map.removeOverlays(Wood_Lake); 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(Balaton);map.removeOverlays(Balaton); map.removeOverlays(Cottonwood); map.removeOverlays(Lynd); map.removeOverlays(Marshall); map.removeOverlays(Minneota); map.removeOverlays(Russell); map.removeOverlays(Tracy); map.removeOverlays(Wood_Lake); map.addOverlays(Balaton); centerByArray(Balaton, false, false); cntMarker += Balaton.length; map.addOverlays(Cottonwood); centerByArray(Cottonwood, false, false); cntMarker += Cottonwood.length; map.addOverlays(Lynd); centerByArray(Lynd, false, false); cntMarker += Lynd.length; map.addOverlays(Marshall); centerByArray(Marshall, false, false); cntMarker += Marshall.length; map.addOverlays(Minneota); centerByArray(Minneota, false, false); cntMarker += Minneota.length; map.addOverlays(Russell); centerByArray(Russell, false, false); cntMarker += Russell.length; map.addOverlays(Tracy); centerByArray(Tracy, false, false); cntMarker += Tracy.length; map.addOverlays(Wood_Lake); centerByArray(Wood_Lake, false, false); cntMarker += Wood_Lake.length; centerByArray(Balaton,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'); } }