function addMarkers() { mySelect = document.getElementById('selection'); Beaverton = [];Beaverton[Beaverton.length] = createMarker(new GPoint(-122.86804962,45.48568344),"
",iconGr); mySelect.options[mySelect.options.length] = new Option("Aloha High School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.79430389,45.49386978),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Arts & Communication High School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.79430389,45.49386978),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Arts & Communication Middle School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.81835175,45.50666809),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Barnes Elementary School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.85209656,45.50456619),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Beaver Acres Elementary School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.81219482,45.48626709),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Beaverton High School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.85619354,45.54360580),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bethany Elementary School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.83788300,45.47523499),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Chehalem Elementary School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.84783173,45.50660706),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Community School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.80326843,45.44754028),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Conestoga Middle School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.85160065,45.46444321),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cooper Mountain Elementary School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.85190582,45.51636124),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Elmonica Elementary School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.86309052,45.46690750),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Errol Hassell Elementary School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.81882477,45.47423172),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Fir Grove Elementary School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.85449982,45.53038788),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Five Oaks Middle School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.80280304,45.45404053),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Greenway Elementary School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.81970215,45.46916199),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Highland Park Middle School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.81890106,45.45466232),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hiteon Elementary School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.87579346,45.48973083),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Kinnaman Elementary School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.77756500,45.46643448),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mckay Elementary School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.86730194,45.53077316),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mckinley Elementary School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.82215881,45.51574326),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Meadow Park Middle School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.84783173,45.50660706),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Merlo Night School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.85697937,45.47985458),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Mountain View Middle School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.84346008,45.44576263),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Nancy Ryles Elementary School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.83515930,45.53833008),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Oak Hills Elementary School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.84584045,45.43111038),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Scholls Heights Elementary School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.84783173,45.50660706),"",iconGr); mySelect.options[mySelect.options.length] = new Option("School Of Science & Technology",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.83695221,45.45853806),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sexton Mountain Elementary School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.80559540,45.45057297),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Southridge High School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.79315948,45.46916199),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Vose Elementary School",'Beaverton=' + Beaverton.length); Beaverton[Beaverton.length] = createMarker(new GPoint(-122.77946472,45.46286011),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Whitford Middle School",'Beaverton=' + Beaverton.length); map.removeOverlays(Beaverton); setTimeout(function(){map.addOverlays(Beaverton)},1000); maxLng = -122.77756500; maxLat = 45.54360580; minLng = -122.87579346; minLat = 45.43111038; reCenterMap(); } // 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(Beaverton); 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(Beaverton);map.removeOverlays(Beaverton); map.addOverlays(Beaverton); centerByArray(Beaverton, false, false); cntMarker += Beaverton.length; centerByArray(Beaverton,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'); } }