function addMarkers() { mySelect = document.getElementById('selection'); Lake_City = [];Elgin = [];Kellogg = [];Plainview = [];Wabasha = [];Mazeppa = [];mySelect.options[mySelect.options.length] = new Option("Elgin schools",'all=Elgin'); mySelect.options[mySelect.options.length] = new Option("Kellogg schools",'all=Kellogg'); mySelect.options[mySelect.options.length] = new Option("Lake City schools",'all=Lake_City'); mySelect.options[mySelect.options.length] = new Option("Mazeppa schools",'all=Mazeppa'); mySelect.options[mySelect.options.length] = new Option("Plainview schools",'all=Plainview'); mySelect.options[mySelect.options.length] = new Option("Wabasha schools",'all=Wabasha'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Lake_City[Lake_City.length] = createMarker(new GPoint(-92.28389740,44.43399811),"
Bluff View Elementary School
Box 454
Lake City, MN 55041

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bluff View Elementary School",'Lake_City=' + Lake_City.length); Elgin[Elgin.length] = createMarker(new GPoint(-92.26959991,44.13499832),"
Elgin Elementary School
Box 364
Elgin, MN 55932

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Elgin Elementary School",'Elgin=' + Elgin.length); Elgin[Elgin.length] = createMarker(new GPoint(-92.26959991,44.13499832),"
Elgin Secondary School
Box 364
Elgin, MN 55932

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Elgin Secondary School",'Elgin=' + Elgin.length); Kellogg[Kellogg.length] = createMarker(new GPoint(-92.00141144,44.30883789),"
Hiawatha Valley Targeted Services
209 Winona Avenue
Kellogg, MN 55945

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Hiawatha Valley Targeted Services",'Kellogg=' + Kellogg.length); Lake_City[Lake_City.length] = createMarker(new GPoint(-92.28389740,44.43399811),"
Lincoln Secondary School
Box 454
Lake City, MN 55041

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Lincoln Secondary School",'Lake_City=' + Lake_City.length); Plainview[Plainview.length] = createMarker(new GPoint(-92.17288971,44.16513824),"
Plainview Elementary School
500 W Broadway
Plainview, MN 55964

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Plainview Elementary School",'Plainview=' + Plainview.length); Plainview[Plainview.length] = createMarker(new GPoint(-92.17288971,44.16513824),"
Plainview Secondary School
500 W Broadway
Plainview, MN 55964

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Plainview Secondary School",'Plainview=' + Plainview.length); Kellogg[Kellogg.length] = createMarker(new GPoint(-91.99826050,44.30862808),"
River Valley Academy Acl
209 Winona Avenue
Kellogg, MN 55945

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("River Valley Academy Acl",'Kellogg=' + Kellogg.length); Wabasha[Wabasha.length] = createMarker(new GPoint(-92.01057434,44.35487747),"
Wabasha-kellogg Elementary School
2113 Hiawatha Drive E
Wabasha, MN 55981

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Wabasha-kellogg Elementary School",'Wabasha=' + Wabasha.length); Wabasha[Wabasha.length] = createMarker(new GPoint(-92.01057434,44.35487747),"
Wabasha-kellogg Secondary School
2113 Hiawatha Dr. E.
Wabasha, MN 55981

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Wabasha-kellogg Secondary School",'Wabasha=' + Wabasha.length); Mazeppa[Mazeppa.length] = createMarker(new GPoint(-92.53029633,44.28110123),"
Zumbrota-mazeppa Middle School
Box 222
Mazeppa, MN 55956

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Zumbrota-mazeppa Middle School",'Mazeppa=' + Mazeppa.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(Elgin); map.removeOverlays(Kellogg); map.removeOverlays(Lake_City); map.removeOverlays(Mazeppa); map.removeOverlays(Plainview); map.removeOverlays(Wabasha); 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(Lake_City);map.removeOverlays(Elgin); map.removeOverlays(Kellogg); map.removeOverlays(Lake_City); map.removeOverlays(Mazeppa); map.removeOverlays(Plainview); map.removeOverlays(Wabasha); map.addOverlays(Elgin); centerByArray(Elgin, false, false); cntMarker += Elgin.length; map.addOverlays(Kellogg); centerByArray(Kellogg, false, false); cntMarker += Kellogg.length; map.addOverlays(Lake_City); centerByArray(Lake_City, false, false); cntMarker += Lake_City.length; map.addOverlays(Mazeppa); centerByArray(Mazeppa, false, false); cntMarker += Mazeppa.length; map.addOverlays(Plainview); centerByArray(Plainview, false, false); cntMarker += Plainview.length; map.addOverlays(Wabasha); centerByArray(Wabasha, false, false); cntMarker += Wabasha.length; centerByArray(Lake_City,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'); } }