function addMarkers() { mySelect = document.getElementById('selection'); Atlanta = [];Mountain_Home = [];Glenns_Ferry = [];Mountain_Home_Afb = [];Pine = [];mySelect.options[mySelect.options.length] = new Option("Atlanta schools",'all=Atlanta'); mySelect.options[mySelect.options.length] = new Option("Glenns Ferry schools",'all=Glenns_Ferry'); mySelect.options[mySelect.options.length] = new Option("Mountain Home schools",'all=Mountain_Home'); mySelect.options[mySelect.options.length] = new Option("Mountain Home Afb schools",'all=Mountain_Home_Afb'); mySelect.options[mySelect.options.length] = new Option("Pine schools",'all=Pine'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Atlanta[Atlanta.length] = createMarker(new GPoint(-115.33969879,43.59400177),"
Atlanta Elementary-junior High School
Post Office Box 24
Atlanta, ID 83601

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Atlanta Elementary-junior High School",'Atlanta=' + Atlanta.length); Mountain_Home[Mountain_Home.length] = createMarker(new GPoint(-115.69181824,43.13262939),"
East Elementary School
775 North 10th East St.
Mountain Home, ID 83647

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("East Elementary School",'Mountain_Home=' + Mountain_Home.length); Glenns_Ferry[Glenns_Ferry.length] = createMarker(new GPoint(-115.30868530,42.95817947),"
Glenns Ferry Elementary School
639 N Bannock St
Glenns Ferry, ID 83623

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Glenns Ferry Elementary School",'Glenns_Ferry=' + Glenns_Ferry.length); Glenns_Ferry[Glenns_Ferry.length] = createMarker(new GPoint(-115.30868530,42.95817947),"
Glenns Ferry High School
639 N Bannock Ave
Glenns Ferry, ID 83623

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Glenns Ferry High School",'Glenns_Ferry=' + Glenns_Ferry.length); Glenns_Ferry[Glenns_Ferry.length] = createMarker(new GPoint(-115.30868530,42.95817947),"
Glenns Ferry Middle School
639 N Bannock Ave
Glenns Ferry, ID 83623

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Glenns Ferry Middle School",'Glenns_Ferry=' + Glenns_Ferry.length); Mountain_Home[Mountain_Home.length] = createMarker(new GPoint(-115.68880463,43.13306046),"
Hacker Middle School
550 E Jackson St
Mountain Home, ID 83647

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Hacker Middle School",'Mountain_Home=' + Mountain_Home.length); Mountain_Home[Mountain_Home.length] = createMarker(new GPoint(-115.69343900,43.13144500),"
Idaho Virtual High Charter School
1993 E 8th N Suite 105
Mountain Home, ID 83647

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Idaho Virtual High Charter School",'Mountain_Home=' + Mountain_Home.length); Mountain_Home[Mountain_Home.length] = createMarker(new GPoint(-115.70220947,43.12163544),"
Idaho Virtual High School
1993 E 8th N Suite 105
Mountain Home, ID 83647

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Idaho Virtual High School",'Mountain_Home=' + Mountain_Home.length); Mountain_Home_Afb[Mountain_Home_Afb.length] = createMarker(new GPoint(-115.86703491,43.04620743),"
Liberty Elementary School
200 Gunfighter Ave
Mountain Home Afb, ID 83648

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Liberty Elementary School",'Mountain_Home_Afb=' + Mountain_Home_Afb.length); Mountain_Home[Mountain_Home.length] = createMarker(new GPoint(-115.67999268,43.12673569),"
Mountain Home Junior High School
1600 E 6th S St
Mountain Home, ID 83647

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Mountain Home Junior High School",'Mountain_Home=' + Mountain_Home.length); Mountain_Home[Mountain_Home.length] = createMarker(new GPoint(-115.69181824,43.13262939),"
Mountain Home Senior High School
300 South 11th East St
Mountain Home, ID 83647

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Mountain Home Senior High School",'Mountain_Home=' + Mountain_Home.length); Mountain_Home_Afb[Mountain_Home_Afb.length] = createMarker(new GPoint(-115.86685944,43.04660034),"
Mtn Home Afb Primary School
100 Gunfighter Ave
Mountain Home Afb, ID 83648

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mtn Home Afb Primary School",'Mountain_Home_Afb=' + Mountain_Home_Afb.length); Mountain_Home[Mountain_Home.length] = createMarker(new GPoint(-115.67754364,43.14519882),"
North Elementary School
290 E 12th N St
Mountain Home, ID 83647

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("North Elementary School",'Mountain_Home=' + Mountain_Home.length); Pine[Pine.length] = createMarker(new GPoint(-115.71260071,43.14020157),"
Pine Elem-jr High School
Hc 87 Box 190
Pine, ID 83647

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Pine Elem-jr High School",'Pine=' + Pine.length); Mountain_Home[Mountain_Home.length] = createMarker(new GPoint(-115.57398987,43.50379562),"
Prairie Elem-jr High School
73 Smith Creek Road
Mountain Home, ID 83647

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Prairie Elem-jr High School",'Mountain_Home=' + Mountain_Home.length); Mountain_Home[Mountain_Home.length] = createMarker(new GPoint(-115.69448853,43.13485336),"
Richard Mckenna Alt. High School
470 N 3rd E, Suite 4
Mountain Home, ID 83647

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Richard Mckenna Alt. High School",'Mountain_Home=' + Mountain_Home.length); Mountain_Home_Afb[Mountain_Home_Afb.length] = createMarker(new GPoint(-115.84120941,43.05596161),"
Stephensen Middle School
300 Gunfighter Avenue
Mountain Home Afb, ID 83648

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Stephensen Middle School",'Mountain_Home_Afb=' + Mountain_Home_Afb.length); Mountain_Home[Mountain_Home.length] = createMarker(new GPoint(-115.69181824,43.13262939),"
West Elementary School
415 W 2nd N
Mountain Home, ID 83647

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("West Elementary School",'Mountain_Home=' + Mountain_Home.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(Atlanta); map.removeOverlays(Glenns_Ferry); map.removeOverlays(Mountain_Home); map.removeOverlays(Mountain_Home_Afb); map.removeOverlays(Pine); 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(Atlanta);map.removeOverlays(Atlanta); map.removeOverlays(Glenns_Ferry); map.removeOverlays(Mountain_Home); map.removeOverlays(Mountain_Home_Afb); map.removeOverlays(Pine); map.addOverlays(Atlanta); centerByArray(Atlanta, false, false); cntMarker += Atlanta.length; map.addOverlays(Glenns_Ferry); centerByArray(Glenns_Ferry, false, false); cntMarker += Glenns_Ferry.length; map.addOverlays(Mountain_Home); centerByArray(Mountain_Home, false, false); cntMarker += Mountain_Home.length; map.addOverlays(Mountain_Home_Afb); centerByArray(Mountain_Home_Afb, false, false); cntMarker += Mountain_Home_Afb.length; map.addOverlays(Pine); centerByArray(Pine, false, false); cntMarker += Pine.length; centerByArray(Atlanta,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'); } }