function addMarkers() { mySelect = document.getElementById('selection'); Island_City = [];La_Grande = [];Cove = [];Elgin = [];Imbler = [];North_Powder = [];Union = [];mySelect.options[mySelect.options.length] = new Option("Cove schools",'all=Cove'); mySelect.options[mySelect.options.length] = new Option("Elgin schools",'all=Elgin'); mySelect.options[mySelect.options.length] = new Option("Imbler schools",'all=Imbler'); mySelect.options[mySelect.options.length] = new Option("Island City schools",'all=Island_City'); mySelect.options[mySelect.options.length] = new Option("La Grande schools",'all=La_Grande'); mySelect.options[mySelect.options.length] = new Option("North Powder schools",'all=North_Powder'); mySelect.options[mySelect.options.length] = new Option("Union schools",'all=Union'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Island_City[Island_City.length] = createMarker(new GPoint(-118.18859863,45.28129959),"
Camp Hilgard High School
10100 N Mcalister Rd
Island City, OR 97850

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Camp Hilgard High School",'Island_City=' + Island_City.length); La_Grande[La_Grande.length] = createMarker(new GPoint(-118.10388947,45.32106400),"
Central Elementary School
402 K Ave
La Grande, OR 97850

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'La_Grande=' + La_Grande.length); Cove[Cove.length] = createMarker(new GPoint(-117.83090210,45.34450150),"
Cove School
Po Box 68
Cove, OR 97824

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cove School",'Cove=' + Cove.length); Elgin[Elgin.length] = createMarker(new GPoint(-117.91929626,45.66809845),"
Elgin High School
Po Box 68
Elgin, OR 97827

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Elgin High School",'Elgin=' + Elgin.length); La_Grande[La_Grande.length] = createMarker(new GPoint(-118.08659363,45.33363724),"
Greenwood Elementary School
2300 N Spruce St
La Grande, OR 97850

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Greenwood Elementary School",'La_Grande=' + La_Grande.length); Imbler[Imbler.length] = createMarker(new GPoint(-117.92189789,45.45740128),"
Imbler Elementary School
Po Box 164
Imbler, OR 97841

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Imbler Elementary School",'Imbler=' + Imbler.length); Imbler[Imbler.length] = createMarker(new GPoint(-117.92189789,45.45740128),"
Imbler High School
Po Box 164
Imbler, OR 97841

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Imbler High School",'Imbler=' + Imbler.length); Island_City[Island_City.length] = createMarker(new GPoint(-118.04669952,45.33826447),"
Island City Elementary School
10201 W 4th St
Island City, OR 97850

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Island City Elementary School",'Island_City=' + Island_City.length); La_Grande[La_Grande.length] = createMarker(new GPoint(-118.10034180,45.32106400),"
La Grande High School
708 K Ave
La Grande, OR 97850

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("La Grande High School",'La_Grande=' + La_Grande.length); La_Grande[La_Grande.length] = createMarker(new GPoint(-118.09669495,45.32138062),"
La Grande Middle School
1108 4th St
La Grande, OR 97850

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("La Grande Middle School",'La_Grande=' + La_Grande.length); North_Powder[North_Powder.length] = createMarker(new GPoint(-117.98380280,45.06240082),"
Powder Valley School
Po Box 10
North Powder, OR 97867

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Powder Valley School",'North_Powder=' + North_Powder.length); La_Grande[La_Grande.length] = createMarker(new GPoint(-118.09910583,45.33618927),"
Riveria Elementary School
2609 2nd St
La Grande, OR 97850

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Riveria Elementary School",'La_Grande=' + La_Grande.length); Elgin[Elgin.length] = createMarker(new GPoint(-117.91929626,45.66809845),"
Stella Mayfield Elementary School
Po Box 35
Elgin, OR 97827

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Stella Mayfield Elementary School",'Elgin=' + Elgin.length); Island_City[Island_City.length] = createMarker(new GPoint(-118.04528500,45.34228500),"
Union County Education Center
10214 Wallowa Lake Hwy
Island City, OR 97850

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Union County Education Center",'Island_City=' + Island_City.length); Union[Union.length] = createMarker(new GPoint(-117.78549957,45.16500092),"
Union Elementary School
Po Box 868
Union, OR 97883

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Union Elementary School",'Union=' + Union.length); Union[Union.length] = createMarker(new GPoint(-117.78549957,45.16500092),"
Union High School
Po Box 908
Union, OR 97883

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Union High School",'Union=' + Union.length); La_Grande[La_Grande.length] = createMarker(new GPoint(-118.07930756,45.32357788),"
Willow Elementary School
1305 Willow St
La Grande, OR 97850

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Willow Elementary School",'La_Grande=' + La_Grande.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(Cove); map.removeOverlays(Elgin); map.removeOverlays(Imbler); map.removeOverlays(Island_City); map.removeOverlays(La_Grande); map.removeOverlays(North_Powder); map.removeOverlays(Union); 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(Island_City);map.removeOverlays(Cove); map.removeOverlays(Elgin); map.removeOverlays(Imbler); map.removeOverlays(Island_City); map.removeOverlays(La_Grande); map.removeOverlays(North_Powder); map.removeOverlays(Union); map.addOverlays(Cove); centerByArray(Cove, false, false); cntMarker += Cove.length; map.addOverlays(Elgin); centerByArray(Elgin, false, false); cntMarker += Elgin.length; map.addOverlays(Imbler); centerByArray(Imbler, false, false); cntMarker += Imbler.length; map.addOverlays(Island_City); centerByArray(Island_City, false, false); cntMarker += Island_City.length; map.addOverlays(La_Grande); centerByArray(La_Grande, false, false); cntMarker += La_Grande.length; map.addOverlays(North_Powder); centerByArray(North_Powder, false, false); cntMarker += North_Powder.length; map.addOverlays(Union); centerByArray(Union, false, false); cntMarker += Union.length; centerByArray(Island_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'); } }