function addMarkers() { mySelect = document.getElementById('selection'); Bemidji = [];Blackduck = [];Kelliher = [];Ponemah = [];Red_Lake = [];mySelect.options[mySelect.options.length] = new Option("Bemidji schools",'all=Bemidji'); mySelect.options[mySelect.options.length] = new Option("Blackduck schools",'all=Blackduck'); mySelect.options[mySelect.options.length] = new Option("Kelliher schools",'all=Kelliher'); mySelect.options[mySelect.options.length] = new Option("Ponemah schools",'all=Ponemah'); mySelect.options[mySelect.options.length] = new Option("Red Lake schools",'all=Red_Lake'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Bemidji[Bemidji.length] = createMarker(new GPoint(-94.88141632,47.48313522),"
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bemidji Aec High School",'Bemidji=' + Bemidji.length); Bemidji[Bemidji.length] = createMarker(new GPoint(-94.88141632,47.48313522),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Bemidji Alp",'Bemidji=' + Bemidji.length); Bemidji[Bemidji.length] = createMarker(new GPoint(-94.84210205,47.49990082),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Bemidji Bylaw",'Bemidji=' + Bemidji.length); Bemidji[Bemidji.length] = createMarker(new GPoint(-94.84210205,47.49990082),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Bemidji Mid. Targeted Services",'Bemidji=' + Bemidji.length); Bemidji[Bemidji.length] = createMarker(new GPoint(-94.92733100,47.50156000),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Bemidji Middle Alp",'Bemidji=' + Bemidji.length); Bemidji[Bemidji.length] = createMarker(new GPoint(-94.88141632,47.48313522),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Bemidji Middle School",'Bemidji=' + Bemidji.length); Bemidji[Bemidji.length] = createMarker(new GPoint(-94.84210205,47.49990082),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Bemidji Regional Interdist. Council",'Bemidji=' + Bemidji.length); Bemidji[Bemidji.length] = createMarker(new GPoint(-94.92329407,47.46858978),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Bemidji Senior High School",'Bemidji=' + Bemidji.length); Bemidji[Bemidji.length] = createMarker(new GPoint(-94.87964900,47.47314500),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Bemidji Senior Lumberjack Alc",'Bemidji=' + Bemidji.length); Blackduck[Blackduck.length] = createMarker(new GPoint(-94.47769928,47.73749924),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Blackduck Elementary School",'Blackduck=' + Blackduck.length); Blackduck[Blackduck.length] = createMarker(new GPoint(-94.47769928,47.73749924),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Blackduck Secondary School",'Blackduck=' + Blackduck.length); Bemidji[Bemidji.length] = createMarker(new GPoint(-94.88141632,47.48313522),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Bemidji=' + Bemidji.length); Bemidji[Bemidji.length] = createMarker(new GPoint(-94.92733100,47.50156000),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Evergreen Shelter",'Bemidji=' + Bemidji.length); Bemidji[Bemidji.length] = createMarker(new GPoint(-94.88141632,47.48313522),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Horace May Elementary School",'Bemidji=' + Bemidji.length); Kelliher[Kelliher.length] = createMarker(new GPoint(-94.54920197,47.96260071),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Kelliher Elementary School",'Kelliher=' + Kelliher.length); Kelliher[Kelliher.length] = createMarker(new GPoint(-94.54920197,47.96260071),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Kelliher Secondary School",'Kelliher=' + Kelliher.length); Bemidji[Bemidji.length] = createMarker(new GPoint(-94.88141632,47.48313522),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Bemidji=' + Bemidji.length); Bemidji[Bemidji.length] = createMarker(new GPoint(-94.85330200,47.45337677),"",iconGr); mySelect.options[mySelect.options.length] = new Option("North Country Voc. Coop. Ctr.",'Bemidji=' + Bemidji.length); Bemidji[Bemidji.length] = createMarker(new GPoint(-94.88141632,47.48313522),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Northern Elementary School",'Bemidji=' + Bemidji.length); Bemidji[Bemidji.length] = createMarker(new GPoint(-94.88141632,47.48313522),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Northwest Special",'Bemidji=' + Bemidji.length); Bemidji[Bemidji.length] = createMarker(new GPoint(-94.88141632,47.48313522),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Paul Bunyan Elementary School",'Bemidji=' + Bemidji.length); Bemidji[Bemidji.length] = createMarker(new GPoint(-94.84210205,47.49990082),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Paul Bunyan Homebased",'Bemidji=' + Bemidji.length); Ponemah[Ponemah.length] = createMarker(new GPoint(-94.88649750,48.02640152),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Ponemah Elementary School",'Ponemah=' + Ponemah.length); Red_Lake[Red_Lake.length] = createMarker(new GPoint(-95.05139923,47.91730118),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Red Lake Alternative Learning",'Red_Lake=' + Red_Lake.length); Red_Lake[Red_Lake.length] = createMarker(new GPoint(-95.01479900,47.87658500),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Red Lake Early Childhood Center",'Red_Lake=' + Red_Lake.length); Red_Lake[Red_Lake.length] = createMarker(new GPoint(-95.05139923,47.91730118),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Red Lake Elementary School",'Red_Lake=' + Red_Lake.length); Red_Lake[Red_Lake.length] = createMarker(new GPoint(-95.05139923,47.91730118),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Red Lake Middle School",'Red_Lake=' + Red_Lake.length); Red_Lake[Red_Lake.length] = createMarker(new GPoint(-95.05139923,47.91730118),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Red Lake School Within School",'Red_Lake=' + Red_Lake.length); Red_Lake[Red_Lake.length] = createMarker(new GPoint(-95.01479900,47.87658500),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Red Lake Senior High School",'Red_Lake=' + Red_Lake.length); Red_Lake[Red_Lake.length] = createMarker(new GPoint(-95.05139923,47.91730118),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Red Lake Targeted Services Middle School",'Red_Lake=' + Red_Lake.length); Red_Lake[Red_Lake.length] = createMarker(new GPoint(-95.05139923,47.91730118),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Redby Group Home",'Red_Lake=' + Red_Lake.length); Bemidji[Bemidji.length] = createMarker(new GPoint(-94.88111877,47.48294830),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Riverside Special",'Bemidji=' + Bemidji.length); Bemidji[Bemidji.length] = createMarker(new GPoint(-94.87999725,47.47359848),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Schoolcraft Learning Community Chtr",'Bemidji=' + Bemidji.length); Bemidji[Bemidji.length] = createMarker(new GPoint(-94.92733100,47.50156000),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Smith Elementary School",'Bemidji=' + Bemidji.length); Bemidji[Bemidji.length] = createMarker(new GPoint(-94.88141632,47.48313522),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Solway Elementary School",'Bemidji=' + Bemidji.length); Bemidji[Bemidji.length] = createMarker(new GPoint(-94.87999725,47.47359848),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Treknorth High School",'Bemidji=' + Bemidji.length); Bemidji[Bemidji.length] = createMarker(new GPoint(-94.87999725,47.47359848),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Voyageurs Expeditionary",'Bemidji=' + Bemidji.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(Bemidji); map.removeOverlays(Blackduck); map.removeOverlays(Kelliher); map.removeOverlays(Ponemah); map.removeOverlays(Red_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(Bemidji);map.removeOverlays(Bemidji); map.removeOverlays(Blackduck); map.removeOverlays(Kelliher); map.removeOverlays(Ponemah); map.removeOverlays(Red_Lake); map.addOverlays(Bemidji); centerByArray(Bemidji, false, false); cntMarker += Bemidji.length; map.addOverlays(Blackduck); centerByArray(Blackduck, false, false); cntMarker += Blackduck.length; map.addOverlays(Kelliher); centerByArray(Kelliher, false, false); cntMarker += Kelliher.length; map.addOverlays(Ponemah); centerByArray(Ponemah, false, false); cntMarker += Ponemah.length; map.addOverlays(Red_Lake); centerByArray(Red_Lake, false, false); cntMarker += Red_Lake.length; centerByArray(Bemidji,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'); } }