function addMarkers() { mySelect = document.getElementById('selection'); Warroad = [];Badger = [];Greenbush = [];Roseau = [];Wannaska = [];mySelect.options[mySelect.options.length] = new Option("Badger schools",'all=Badger'); mySelect.options[mySelect.options.length] = new Option("Greenbush schools",'all=Greenbush'); mySelect.options[mySelect.options.length] = new Option("Roseau schools",'all=Roseau'); mySelect.options[mySelect.options.length] = new Option("Wannaska schools",'all=Wannaska'); mySelect.options[mySelect.options.length] = new Option("Warroad schools",'all=Warroad'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Warroad[Warroad.length] = createMarker(new GPoint(-95.33098602,48.91096115),"
Angle Inlet Elementary School
510 Cedar Avenue
Warroad, MN 56763

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Angle Inlet Elementary School",'Warroad=' + Warroad.length); Badger[Badger.length] = createMarker(new GPoint(-96.12809753,48.79840088),"
Badger Elementary School
P.o. Box 68
Badger, MN 56714

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Badger Elementary School",'Badger=' + Badger.length); Badger[Badger.length] = createMarker(new GPoint(-96.12809753,48.79840088),"
Badger Secondary School
Box 68, 110 Carpenter Ave.
Badger, MN 56714

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Badger Secondary School",'Badger=' + Badger.length); Warroad[Warroad.length] = createMarker(new GPoint(-95.33098602,48.91096115),"
Border Alc High School
510 Cedar Avenue Nw
Warroad, MN 56763

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Border Alc High School",'Warroad=' + Warroad.length); Greenbush[Greenbush.length] = createMarker(new GPoint(-96.18370056,48.69490051),"
Greenbush Elementary School
Box 70
Greenbush, MN 56726

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Greenbush Elementary School",'Greenbush=' + Greenbush.length); Greenbush[Greenbush.length] = createMarker(new GPoint(-96.18370056,48.69490051),"
Greenbush-middle River Senior High School
Box 70
Greenbush, MN 56726

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Greenbush-middle River Senior High School",'Greenbush=' + Greenbush.length); Roseau[Roseau.length] = createMarker(new GPoint(-95.70816040,48.77090073),"
Malung Elementary School
4107 Malung Street
Roseau, MN 56751

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Malung Elementary School",'Roseau=' + Roseau.length); Roseau[Roseau.length] = createMarker(new GPoint(-95.75738525,48.84823608),"
Roseau Elementary School
509 3rd Street Ne
Roseau, MN 56751

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Roseau Elementary School",'Roseau=' + Roseau.length); Roseau[Roseau.length] = createMarker(new GPoint(-95.75738525,48.84823608),"
Roseau Secondary School
509 3rd Street Ne
Roseau, MN 56751

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Roseau Secondary School",'Roseau=' + Roseau.length); Wannaska[Wannaska.length] = createMarker(new GPoint(-95.73455048,48.65591431),"
Wannaska Elementary School
17988 State Highway 89
Wannaska, MN 56761

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Wannaska Elementary School",'Wannaska=' + Wannaska.length); Warroad[Warroad.length] = createMarker(new GPoint(-95.33098602,48.91096115),"
Warroad Elementary School
510 Cedar Avenue
Warroad, MN 56763

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Warroad Elementary School",'Warroad=' + Warroad.length); Warroad[Warroad.length] = createMarker(new GPoint(-95.33098602,48.91096115),"
Warroad Middle School
510 Cedar Avenue
Warroad, MN 56763

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Warroad Middle School",'Warroad=' + Warroad.length); Warroad[Warroad.length] = createMarker(new GPoint(-95.33098602,48.91096115),"
Warroad Senior High School
510 Cedar Avenue
Warroad, MN 56763

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Warroad Senior High School",'Warroad=' + Warroad.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(Badger); map.removeOverlays(Greenbush); map.removeOverlays(Roseau); map.removeOverlays(Wannaska); map.removeOverlays(Warroad); 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(Warroad);map.removeOverlays(Badger); map.removeOverlays(Greenbush); map.removeOverlays(Roseau); map.removeOverlays(Wannaska); map.removeOverlays(Warroad); map.addOverlays(Badger); centerByArray(Badger, false, false); cntMarker += Badger.length; map.addOverlays(Greenbush); centerByArray(Greenbush, false, false); cntMarker += Greenbush.length; map.addOverlays(Roseau); centerByArray(Roseau, false, false); cntMarker += Roseau.length; map.addOverlays(Wannaska); centerByArray(Wannaska, false, false); cntMarker += Wannaska.length; map.addOverlays(Warroad); centerByArray(Warroad, false, false); cntMarker += Warroad.length; centerByArray(Warroad,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'); } }