function addMarkers() { mySelect = document.getElementById('selection'); Bertha = [];Browerville = [];Clarissa = [];Eagle_Bend = [];Staples = [];Grey_Eagle = [];Long_Prairie = [];mySelect.options[mySelect.options.length] = new Option("Bertha schools",'all=Bertha'); mySelect.options[mySelect.options.length] = new Option("Browerville schools",'all=Browerville'); mySelect.options[mySelect.options.length] = new Option("Clarissa schools",'all=Clarissa'); mySelect.options[mySelect.options.length] = new Option("Eagle Bend schools",'all=Eagle_Bend'); mySelect.options[mySelect.options.length] = new Option("Grey Eagle schools",'all=Grey_Eagle'); mySelect.options[mySelect.options.length] = new Option("Long Prairie schools",'all=Long_Prairie'); mySelect.options[mySelect.options.length] = new Option("Staples schools",'all=Staples'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Bertha[Bertha.length] = createMarker(new GPoint(-95.05059814,46.26129913),"
Bertha Elementary School
Box 8
Bertha, MN 56437

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bertha Elementary School",'Bertha=' + Bertha.length); Bertha[Bertha.length] = createMarker(new GPoint(-95.05059814,46.26129913),"
Bertha Secondary School
Box 8
Bertha, MN 56437

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bertha Secondary School",'Bertha=' + Bertha.length); Browerville[Browerville.length] = createMarker(new GPoint(-94.81210327,46.10820007),"
Browerville Elementary School
Box 185
Browerville, MN 56438

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Browerville Elementary School",'Browerville=' + Browerville.length); Browerville[Browerville.length] = createMarker(new GPoint(-94.81210327,46.10820007),"
Browerville Secondary School
Box 185
Browerville, MN 56438

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Browerville Secondary School",'Browerville=' + Browerville.length); Clarissa[Clarissa.length] = createMarker(new GPoint(-94.94860077,46.13420105),"
Eagle Valley Elementary School
Box 468 106 Frank Street S
Clarissa, MN 56440

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Eagle Valley Elementary School",'Clarissa=' + Clarissa.length); Eagle_Bend[Eagle_Bend.length] = createMarker(new GPoint(-95.07730103,46.12969971),"
Eagle Valley Secondary School
Box 299 405 Main Street W
Eagle Bend, MN 56446

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Eagle Valley Secondary School",'Eagle_Bend=' + Eagle_Bend.length); Staples[Staples.length] = createMarker(new GPoint(-94.79280090,46.36553574),"
Freshwater Ed. Dist. Alc High School
1100 5th Street Ne Suite 2
Staples, MN 56479

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Freshwater Ed. Dist. Alc High School",'Staples=' + Staples.length); Staples[Staples.length] = createMarker(new GPoint(-94.79280090,46.36553574),"
Freshwater Targeted Services
1100 5th Street Ne Suite 2
Staples, MN 56479

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Freshwater Targeted Services",'Staples=' + Staples.length); Grey_Eagle[Grey_Eagle.length] = createMarker(new GPoint(-94.74689484,45.82448959),"
Grey Eagle Elementary School
304 State Street E
Grey Eagle, MN 56336

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Grey Eagle Elementary School",'Grey_Eagle=' + Grey_Eagle.length); Long_Prairie[Long_Prairie.length] = createMarker(new GPoint(-94.86239624,45.97171783),"
Long Prairie Elementary School
205 2nd Street S
Long Prairie, MN 56347

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Long Prairie Elementary School",'Long_Prairie=' + Long_Prairie.length); Long_Prairie[Long_Prairie.length] = createMarker(new GPoint(-94.86222839,45.97191238),"
Long Prairie Mid. School
205 2nd St. S.
Long Prairie, MN 56347

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Long Prairie Mid. School",'Long_Prairie=' + Long_Prairie.length); Long_Prairie[Long_Prairie.length] = createMarker(new GPoint(-94.85031891,45.98064041),"
Long Prairie-grey Senior High School
510 9th Street Ne
Long Prairie, MN 56347

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Long Prairie-grey Senior High School",'Long_Prairie=' + Long_Prairie.length); Staples[Staples.length] = createMarker(new GPoint(-94.79470062,46.36449814),"
Staples Elementary School
1025 4th Street Ne
Staples, MN 56479

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Staples Elementary School",'Staples=' + Staples.length); Staples[Staples.length] = createMarker(new GPoint(-94.79500580,46.35836792),"
Staples-motley Senior High School
401 Centennial Lane
Staples, MN 56479

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Staples-motley Senior High School",'Staples=' + Staples.length); Staples[Staples.length] = createMarker(new GPoint(-94.76029968,46.37419891),"
White Pine Academy
102 6th Street Ne
Staples, MN 56479

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("White Pine Academy",'Staples=' + Staples.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(Bertha); map.removeOverlays(Browerville); map.removeOverlays(Clarissa); map.removeOverlays(Eagle_Bend); map.removeOverlays(Grey_Eagle); map.removeOverlays(Long_Prairie); map.removeOverlays(Staples); 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(Bertha);map.removeOverlays(Bertha); map.removeOverlays(Browerville); map.removeOverlays(Clarissa); map.removeOverlays(Eagle_Bend); map.removeOverlays(Grey_Eagle); map.removeOverlays(Long_Prairie); map.removeOverlays(Staples); map.addOverlays(Bertha); centerByArray(Bertha, false, false); cntMarker += Bertha.length; map.addOverlays(Browerville); centerByArray(Browerville, false, false); cntMarker += Browerville.length; map.addOverlays(Clarissa); centerByArray(Clarissa, false, false); cntMarker += Clarissa.length; map.addOverlays(Eagle_Bend); centerByArray(Eagle_Bend, false, false); cntMarker += Eagle_Bend.length; map.addOverlays(Grey_Eagle); centerByArray(Grey_Eagle, false, false); cntMarker += Grey_Eagle.length; map.addOverlays(Long_Prairie); centerByArray(Long_Prairie, false, false); cntMarker += Long_Prairie.length; map.addOverlays(Staples); centerByArray(Staples, false, false); cntMarker += Staples.length; centerByArray(Bertha,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'); } }