function addMarkers() { mySelect = document.getElementById('selection'); Medford = [];Applegate = [];Phoenix = [];Ashland = [];Butte_Falls = [];Central_Point = [];Eagle_Point = [];Trail = [];Rogue_River = [];Gold_Hill = [];Jacksonville = [];White_City = [];Prospect = [];Shady_Cove = [];Talent = [];mySelect.options[mySelect.options.length] = new Option("Applegate schools",'all=Applegate'); mySelect.options[mySelect.options.length] = new Option("Ashland schools",'all=Ashland'); mySelect.options[mySelect.options.length] = new Option("Butte Falls schools",'all=Butte_Falls'); mySelect.options[mySelect.options.length] = new Option("Central Point schools",'all=Central_Point'); mySelect.options[mySelect.options.length] = new Option("Eagle Point schools",'all=Eagle_Point'); mySelect.options[mySelect.options.length] = new Option("Gold Hill schools",'all=Gold_Hill'); mySelect.options[mySelect.options.length] = new Option("Jacksonville schools",'all=Jacksonville'); mySelect.options[mySelect.options.length] = new Option("Medford schools",'all=Medford'); mySelect.options[mySelect.options.length] = new Option("Phoenix schools",'all=Phoenix'); mySelect.options[mySelect.options.length] = new Option("Prospect schools",'all=Prospect'); mySelect.options[mySelect.options.length] = new Option("Rogue River schools",'all=Rogue_River'); mySelect.options[mySelect.options.length] = new Option("Shady Cove schools",'all=Shady_Cove'); mySelect.options[mySelect.options.length] = new Option("Talent schools",'all=Talent'); mySelect.options[mySelect.options.length] = new Option("Trail schools",'all=Trail'); mySelect.options[mySelect.options.length] = new Option("White City schools",'all=White_City'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Medford[Medford.length] = createMarker(new GPoint(-122.83628845,42.36267471),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Abraham Lincoln Elementary School",'Medford=' + Medford.length); Applegate[Applegate.length] = createMarker(new GPoint(-123.15338898,42.25366211),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Applegate Elementary School",'Applegate=' + Applegate.length); Phoenix[Phoenix.length] = createMarker(new GPoint(-122.81710052,42.27410126),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Armadillo Technical Institute",'Phoenix=' + Phoenix.length); Ashland[Ashland.length] = createMarker(new GPoint(-122.69948578,42.19025421),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Ashland High School",'Ashland=' + Ashland.length); Ashland[Ashland.length] = createMarker(new GPoint(-122.68801117,42.19096375),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Ashland Middle School",'Ashland=' + Ashland.length); Ashland[Ashland.length] = createMarker(new GPoint(-122.67131042,42.17590332),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bellview Elementary School",'Ashland=' + Ashland.length); Butte_Falls[Butte_Falls.length] = createMarker(new GPoint(-122.49990082,42.57049942),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Butte Falls Elementary School",'Butte_Falls=' + Butte_Falls.length); Butte_Falls[Butte_Falls.length] = createMarker(new GPoint(-122.49990082,42.57049942),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Butte Falls High School",'Butte_Falls=' + Butte_Falls.length); Central_Point[Central_Point.length] = createMarker(new GPoint(-122.91104889,42.37167358),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Central Point Elementary School",'Central_Point=' + Central_Point.length); Central_Point[Central_Point.length] = createMarker(new GPoint(-122.92675018,42.38298035),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Crater High School",'Central_Point=' + Central_Point.length); Eagle_Point[Eagle_Point.length] = createMarker(new GPoint(-122.77469635,42.47919846),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Eagle Point High School",'Eagle_Point=' + Eagle_Point.length); Eagle_Point[Eagle_Point.length] = createMarker(new GPoint(-122.77469635,42.47919846),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Eagle Point Middle School",'Eagle_Point=' + Eagle_Point.length); Eagle_Point[Eagle_Point.length] = createMarker(new GPoint(-122.77469635,42.47919846),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Eagle Rock Elementary School",'Eagle_Point=' + Eagle_Point.length); Trail[Trail.length] = createMarker(new GPoint(-122.74624634,42.66740036),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Elk Trail Elementary School",'Trail=' + Trail.length); Rogue_River[Rogue_River.length] = createMarker(new GPoint(-123.14119720,42.56359863),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Evans Valley Elementary School",'Rogue_River=' + Rogue_River.length); Medford[Medford.length] = createMarker(new GPoint(-122.90708160,42.29426956),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Griffin Creek Elementary School",'Medford=' + Medford.length); Gold_Hill[Gold_Hill.length] = createMarker(new GPoint(-123.05357361,42.43450546),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Hanby Middle School",'Gold_Hill=' + Gold_Hill.length); Medford[Medford.length] = createMarker(new GPoint(-122.85320282,42.33123779),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Hedrick Middle School",'Medford=' + Medford.length); Ashland[Ashland.length] = createMarker(new GPoint(-122.71228027,42.20985794),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Helman Elementary School",'Ashland=' + Ashland.length); Medford[Medford.length] = createMarker(new GPoint(-122.84107208,42.32061768),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hoover Elementary School",'Medford=' + Medford.length); Medford[Medford.length] = createMarker(new GPoint(-122.89034271,42.35814667),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Howard Elementary School",'Medford=' + Medford.length); Medford[Medford.length] = createMarker(new GPoint(-122.88699341,42.33113861),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jackson Elementary School",'Medford=' + Medford.length); Jacksonville[Jacksonville.length] = createMarker(new GPoint(-122.95895386,42.31648636),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jacksonville Elementary School",'Jacksonville=' + Jacksonville.length); Medford[Medford.length] = createMarker(new GPoint(-122.86751556,42.30968475),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'Medford=' + Medford.length); Central_Point[Central_Point.length] = createMarker(new GPoint(-122.91017151,42.37910080),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jewett Elementary School",'Central_Point=' + Central_Point.length); Medford[Medford.length] = createMarker(new GPoint(-122.85231018,42.35854721),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Kennedy Elementary School",'Medford=' + Medford.length); Eagle_Point[Eagle_Point.length] = createMarker(new GPoint(-122.63582611,42.42787552),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lake Creek Learning Center",'Eagle_Point=' + Eagle_Point.length); Eagle_Point[Eagle_Point.length] = createMarker(new GPoint(-122.77469635,42.47919846),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Little Butte School",'Eagle_Point=' + Eagle_Point.length); Medford[Medford.length] = createMarker(new GPoint(-122.83273315,42.34546280),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lone Pine Elementary School",'Medford=' + Medford.length); Medford[Medford.length] = createMarker(new GPoint(-122.88059998,42.32853699),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Mcloughlin Middle School",'Medford=' + Medford.length); Medford[Medford.length] = createMarker(new GPoint(-122.87198639,42.31763840),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Medford Opportunity High School",'Medford=' + Medford.length); White_City[White_City.length] = createMarker(new GPoint(-122.83718872,42.43107224),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mountain View Elementary School",'White_City=' + White_City.length); Medford[Medford.length] = createMarker(new GPoint(-122.85240936,42.34603882),"",iconGr); mySelect.options[mySelect.options.length] = new Option("North Medford High School",'Medford=' + Medford.length); Medford[Medford.length] = createMarker(new GPoint(-122.90947723,42.32393646),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Oak Grove Elementary School",'Medford=' + Medford.length); Medford[Medford.length] = createMarker(new GPoint(-122.83131409,42.30965042),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Orchard Hill Elementary School",'Medford=' + Medford.length); Gold_Hill[Gold_Hill.length] = createMarker(new GPoint(-123.06290436,42.43338013),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Patrick Elementary School",'Gold_Hill=' + Gold_Hill.length); Phoenix[Phoenix.length] = createMarker(new GPoint(-122.81710052,42.27410126),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Phoenix Elementary School",'Phoenix=' + Phoenix.length); Phoenix[Phoenix.length] = createMarker(new GPoint(-122.81710052,42.27410126),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Phoenix High School",'Phoenix=' + Phoenix.length); Ashland[Ashland.length] = createMarker(new GPoint(-122.39823914,42.10947800),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pinehurst Elementary School",'Ashland=' + Ashland.length); Prospect[Prospect.length] = createMarker(new GPoint(-122.51921844,42.84857941),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Prospect School",'Prospect=' + Prospect.length); Central_Point[Central_Point.length] = createMarker(new GPoint(-122.92015839,42.37283707),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Richardson Elementary School",'Central_Point=' + Central_Point.length); Rogue_River[Rogue_River.length] = createMarker(new GPoint(-123.14119720,42.56359863),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Rogue River Elementary School",'Rogue_River=' + Rogue_River.length); Rogue_River[Rogue_River.length] = createMarker(new GPoint(-123.14119720,42.56359863),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Rogue River High School",'Rogue_River=' + Rogue_River.length); Rogue_River[Rogue_River.length] = createMarker(new GPoint(-123.14119720,42.56359863),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Rogue River Middle School",'Rogue_River=' + Rogue_River.length); Medford[Medford.length] = createMarker(new GPoint(-122.85771179,42.32968903),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Roosevelt Elementary School",'Medford=' + Medford.length); Jacksonville[Jacksonville.length] = createMarker(new GPoint(-123.04270172,42.23505402),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Ruch Elementary School",'Jacksonville=' + Jacksonville.length); Central_Point[Central_Point.length] = createMarker(new GPoint(-122.93518066,42.49429321),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sams Valley Elementary School",'Central_Point=' + Central_Point.length); Central_Point[Central_Point.length] = createMarker(new GPoint(-122.92411041,42.38845444),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Scenic Middle School",'Central_Point=' + Central_Point.length); Shady_Cove[Shady_Cove.length] = createMarker(new GPoint(-122.81999969,42.61080170),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Shady Cove School",'Shady_Cove=' + Shady_Cove.length); Medford[Medford.length] = createMarker(new GPoint(-122.87426758,42.31604767),"",iconGr); mySelect.options[mySelect.options.length] = new Option("South Medford High School",'Medford=' + Medford.length); Ashland[Ashland.length] = createMarker(new GPoint(-122.68238068,42.18356323),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Southern Oregon Cstc Elementary School",'Ashland=' + Ashland.length); Talent[Talent.length] = createMarker(new GPoint(-122.78639984,42.23899841),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Talent Elementary School",'Talent=' + Talent.length); Talent[Talent.length] = createMarker(new GPoint(-122.78639984,42.23899841),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Talent Middle School",'Talent=' + Talent.length); Ashland[Ashland.length] = createMarker(new GPoint(-122.68801117,42.18836212),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Walker Elementary School",'Ashland=' + Ashland.length); Medford[Medford.length] = createMarker(new GPoint(-122.88278198,42.31710815),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Washington Elementary School",'Medford=' + Medford.length); White_City[White_City.length] = createMarker(new GPoint(-122.83838900,42.43831500),"",iconRd); mySelect.options[mySelect.options.length] = new Option("White City Elementary School",'White_City=' + White_City.length); White_City[White_City.length] = createMarker(new GPoint(-122.85500336,42.33301926),"",iconBl); mySelect.options[mySelect.options.length] = new Option("White Mountain Middle School",'White_City=' + White_City.length); Medford[Medford.length] = createMarker(new GPoint(-122.86730957,42.34556198),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wilson Elementary School",'Medford=' + Medford.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(Applegate); map.removeOverlays(Ashland); map.removeOverlays(Butte_Falls); map.removeOverlays(Central_Point); map.removeOverlays(Eagle_Point); map.removeOverlays(Gold_Hill); map.removeOverlays(Jacksonville); map.removeOverlays(Medford); map.removeOverlays(Phoenix); map.removeOverlays(Prospect); map.removeOverlays(Rogue_River); map.removeOverlays(Shady_Cove); map.removeOverlays(Talent); map.removeOverlays(Trail); map.removeOverlays(White_City); 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(Medford);map.removeOverlays(Applegate); map.removeOverlays(Ashland); map.removeOverlays(Butte_Falls); map.removeOverlays(Central_Point); map.removeOverlays(Eagle_Point); map.removeOverlays(Gold_Hill); map.removeOverlays(Jacksonville); map.removeOverlays(Medford); map.removeOverlays(Phoenix); map.removeOverlays(Prospect); map.removeOverlays(Rogue_River); map.removeOverlays(Shady_Cove); map.removeOverlays(Talent); map.removeOverlays(Trail); map.removeOverlays(White_City); map.addOverlays(Applegate); centerByArray(Applegate, false, false); cntMarker += Applegate.length; map.addOverlays(Ashland); centerByArray(Ashland, false, false); cntMarker += Ashland.length; map.addOverlays(Butte_Falls); centerByArray(Butte_Falls, false, false); cntMarker += Butte_Falls.length; map.addOverlays(Central_Point); centerByArray(Central_Point, false, false); cntMarker += Central_Point.length; map.addOverlays(Eagle_Point); centerByArray(Eagle_Point, false, false); cntMarker += Eagle_Point.length; map.addOverlays(Gold_Hill); centerByArray(Gold_Hill, false, false); cntMarker += Gold_Hill.length; map.addOverlays(Jacksonville); centerByArray(Jacksonville, false, false); cntMarker += Jacksonville.length; map.addOverlays(Medford); centerByArray(Medford, false, false); cntMarker += Medford.length; map.addOverlays(Phoenix); centerByArray(Phoenix, false, false); cntMarker += Phoenix.length; map.addOverlays(Prospect); centerByArray(Prospect, false, false); cntMarker += Prospect.length; map.addOverlays(Rogue_River); centerByArray(Rogue_River, false, false); cntMarker += Rogue_River.length; map.addOverlays(Shady_Cove); centerByArray(Shady_Cove, false, false); cntMarker += Shady_Cove.length; map.addOverlays(Talent); centerByArray(Talent, false, false); cntMarker += Talent.length; map.addOverlays(Trail); centerByArray(Trail, false, false); cntMarker += Trail.length; map.addOverlays(White_City); centerByArray(White_City, false, false); cntMarker += White_City.length; centerByArray(Medford,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'); } }