function addMarkers() { mySelect = document.getElementById('selection'); Adrian = [];Brewster = [];Worthington = [];Ellsworth = [];Round_Lake = [];Bigelow = [];mySelect.options[mySelect.options.length] = new Option("Adrian schools",'all=Adrian'); mySelect.options[mySelect.options.length] = new Option("Bigelow schools",'all=Bigelow'); mySelect.options[mySelect.options.length] = new Option("Brewster schools",'all=Brewster'); mySelect.options[mySelect.options.length] = new Option("Ellsworth schools",'all=Ellsworth'); mySelect.options[mySelect.options.length] = new Option("Round Lake schools",'all=Round_Lake'); mySelect.options[mySelect.options.length] = new Option("Worthington schools",'all=Worthington'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Adrian[Adrian.length] = createMarker(new GPoint(-95.92500305,43.62369919),"
Adrian Elementary School
Box 40 515 Oklahoma Avenue
Adrian, MN 56110

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Adrian Elementary School",'Adrian=' + Adrian.length); Adrian[Adrian.length] = createMarker(new GPoint(-95.92500305,43.62369919),"
Adrian Middle School
Box 40
Adrian, MN 56110

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Adrian Middle School",'Adrian=' + Adrian.length); Adrian[Adrian.length] = createMarker(new GPoint(-95.92500305,43.62369919),"
Adrian Secondary School
Box 40 415 Kentucky Ave.
Adrian, MN 56110

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Adrian Secondary School",'Adrian=' + Adrian.length); Brewster[Brewster.length] = createMarker(new GPoint(-95.47949982,43.70679855),"
Brewster Elementary School
Box 309
Brewster, MN 56119

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Brewster Elementary School",'Brewster=' + Brewster.length); Worthington[Worthington.length] = createMarker(new GPoint(-95.59819794,43.62730026),"
District 518 Sp. Ed.
117 11th Avenue
Worthington, MN 56187

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("District 518 Sp. Ed.",'Worthington=' + Worthington.length); Worthington[Worthington.length] = createMarker(new GPoint(-95.57938385,43.61643600),"
Early Childhood Elementary School
117 11th Avenue
Worthington, MN 56187

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Early Childhood Elementary School",'Worthington=' + Worthington.length); Ellsworth[Ellsworth.length] = createMarker(new GPoint(-96.00589752,43.52999878),"
Ellsworth Elementary School
Box 8
Ellsworth, MN 56129

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Ellsworth Elementary School",'Ellsworth=' + Ellsworth.length); Ellsworth[Ellsworth.length] = createMarker(new GPoint(-96.00589752,43.52999878),"
Ellsworth Secondary School
Box 8
Ellsworth, MN 56129

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Ellsworth Secondary School",'Ellsworth=' + Ellsworth.length); Worthington[Worthington.length] = createMarker(new GPoint(-95.59819794,43.62730026),"
Prairie Academy
1680 Airport Road
Worthington, MN 56187

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Prairie Academy",'Worthington=' + Worthington.length); Worthington[Worthington.length] = createMarker(new GPoint(-95.62361145,43.60713577),"
Prairie Elementary School
1700 1st Avenue Sw
Worthington, MN 56187

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Prairie Elementary School",'Worthington=' + Worthington.length); Round_Lake[Round_Lake.length] = createMarker(new GPoint(-95.46550751,43.53809357),"
Round Lake Secondary School
445 Harrison Street
Round Lake, MN 56167

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Round Lake Secondary School",'Round_Lake=' + Round_Lake.length); Worthington[Worthington.length] = createMarker(new GPoint(-95.61340332,43.62603760),"
Worthington Alc High School
117 11th Avenue
Worthington, MN 56187

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Worthington Alc High School",'Worthington=' + Worthington.length); Bigelow[Bigelow.length] = createMarker(new GPoint(-95.69100200,43.50658000),"
Worthington Area Language Academy
Po Box 185
Bigelow, MN 56117

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Worthington Area Language Academy",'Bigelow=' + Bigelow.length); Worthington[Worthington.length] = createMarker(new GPoint(-95.62905884,43.62822342),"
Worthington Middle School
1401 Crailsheim Road
Worthington, MN 56187

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Worthington Middle School",'Worthington=' + Worthington.length); Worthington[Worthington.length] = createMarker(new GPoint(-95.59689331,43.62763596),"
Worthington Senior High School
1211 Clary Street
Worthington, MN 56187

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Worthington Senior High School",'Worthington=' + Worthington.length); Worthington[Worthington.length] = createMarker(new GPoint(-95.61646900,43.63103000),"
Worthington-targeted Services
117 11th Avenue
Worthington, MN 56187

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Worthington-targeted Services",'Worthington=' + Worthington.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(Adrian); map.removeOverlays(Bigelow); map.removeOverlays(Brewster); map.removeOverlays(Ellsworth); map.removeOverlays(Round_Lake); map.removeOverlays(Worthington); 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(Adrian);map.removeOverlays(Adrian); map.removeOverlays(Bigelow); map.removeOverlays(Brewster); map.removeOverlays(Ellsworth); map.removeOverlays(Round_Lake); map.removeOverlays(Worthington); map.addOverlays(Adrian); centerByArray(Adrian, false, false); cntMarker += Adrian.length; map.addOverlays(Bigelow); centerByArray(Bigelow, false, false); cntMarker += Bigelow.length; map.addOverlays(Brewster); centerByArray(Brewster, false, false); cntMarker += Brewster.length; map.addOverlays(Ellsworth); centerByArray(Ellsworth, false, false); cntMarker += Ellsworth.length; map.addOverlays(Round_Lake); centerByArray(Round_Lake, false, false); cntMarker += Round_Lake.length; map.addOverlays(Worthington); centerByArray(Worthington, false, false); cntMarker += Worthington.length; centerByArray(Adrian,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'); } }