function addMarkers() { mySelect = document.getElementById('selection'); Olivia = [];Bird_Island = [];Buffalo_Lake = [];Hector = [];Franklin = [];Fairfax = [];Sacred_Heart = [];Renville = [];mySelect.options[mySelect.options.length] = new Option("Bird Island schools",'all=Bird_Island'); mySelect.options[mySelect.options.length] = new Option("Buffalo Lake schools",'all=Buffalo_Lake'); mySelect.options[mySelect.options.length] = new Option("Fairfax schools",'all=Fairfax'); mySelect.options[mySelect.options.length] = new Option("Franklin schools",'all=Franklin'); mySelect.options[mySelect.options.length] = new Option("Hector schools",'all=Hector'); mySelect.options[mySelect.options.length] = new Option("Olivia schools",'all=Olivia'); mySelect.options[mySelect.options.length] = new Option("Renville schools",'all=Renville'); mySelect.options[mySelect.options.length] = new Option("Sacred Heart schools",'all=Sacred_Heart'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Olivia[Olivia.length] = createMarker(new GPoint(-94.98963165,44.77019882),"
Bold Senior High School
701 S 9th Street
Olivia, MN 56277

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bold Senior High School",'Olivia=' + Olivia.length); Bird_Island[Bird_Island.length] = createMarker(new GPoint(-94.86650085,44.75780106),"
Bold-bird Island Elementary School
110 S 9th Street
Bird Island, MN 55310

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bold-bird Island Elementary School",'Bird_Island=' + Bird_Island.length); Buffalo_Lake[Buffalo_Lake.length] = createMarker(new GPoint(-94.59200287,44.77650070),"
Buffalo Lake-hector Elementary School
Box 278 220 W 3rd Street
Buffalo Lake, MN 55314

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Buffalo Lake-hector Elementary School",'Buffalo_Lake=' + Buffalo_Lake.length); Hector[Hector.length] = createMarker(new GPoint(-94.71269989,44.75640106),"
Buffalo Lake-hector Secondary School
Box 307 220 W 3rd Street
Hector, MN 55342

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Buffalo Lake-hector Secondary School",'Hector=' + Hector.length); Franklin[Franklin.length] = createMarker(new GPoint(-93.94770050,45.73559952),"
Cedar Mountain Elementary School
Box 38
Franklin, MN 55333

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Cedar Mountain Elementary School",'Franklin=' + Franklin.length); Fairfax[Fairfax.length] = createMarker(new GPoint(-94.73290253,44.54159927),"
G.f.w. Middle School
Box 489
Fairfax, MN 55332

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("G.f.w. Middle School",'Fairfax=' + Fairfax.length); Sacred_Heart[Sacred_Heart.length] = createMarker(new GPoint(-95.19280243,44.78889847),"
Renville Cty. W. Elementary School
Box 10
Sacred Heart, MN 55285

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Renville Cty. W. Elementary School",'Sacred_Heart=' + Sacred_Heart.length); Renville[Renville.length] = createMarker(new GPoint(-95.19280243,44.78889847),"
Renville Cty. West Senior High School
Box 338
Renville, MN 56284

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Renville Cty. West Senior High School",'Renville=' + Renville.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(Bird_Island); map.removeOverlays(Buffalo_Lake); map.removeOverlays(Fairfax); map.removeOverlays(Franklin); map.removeOverlays(Hector); map.removeOverlays(Olivia); map.removeOverlays(Renville); map.removeOverlays(Sacred_Heart); 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(Olivia);map.removeOverlays(Bird_Island); map.removeOverlays(Buffalo_Lake); map.removeOverlays(Fairfax); map.removeOverlays(Franklin); map.removeOverlays(Hector); map.removeOverlays(Olivia); map.removeOverlays(Renville); map.removeOverlays(Sacred_Heart); map.addOverlays(Bird_Island); centerByArray(Bird_Island, false, false); cntMarker += Bird_Island.length; map.addOverlays(Buffalo_Lake); centerByArray(Buffalo_Lake, false, false); cntMarker += Buffalo_Lake.length; map.addOverlays(Fairfax); centerByArray(Fairfax, false, false); cntMarker += Fairfax.length; map.addOverlays(Franklin); centerByArray(Franklin, false, false); cntMarker += Franklin.length; map.addOverlays(Hector); centerByArray(Hector, false, false); cntMarker += Hector.length; map.addOverlays(Olivia); centerByArray(Olivia, false, false); cntMarker += Olivia.length; map.addOverlays(Renville); centerByArray(Renville, false, false); cntMarker += Renville.length; map.addOverlays(Sacred_Heart); centerByArray(Sacred_Heart, false, false); cntMarker += Sacred_Heart.length; centerByArray(Olivia,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'); } }