function addMarkers() { mySelect = document.getElementById('selection'); Amity = [];Newberg = [];Carlton = [];Sheridan = [];Mcminnville = [];Dayton = [];Dundee = [];Lafayette = [];Willamina = [];Yamhill = [];mySelect.options[mySelect.options.length] = new Option("Amity schools",'all=Amity'); mySelect.options[mySelect.options.length] = new Option("Carlton schools",'all=Carlton'); mySelect.options[mySelect.options.length] = new Option("Dayton schools",'all=Dayton'); mySelect.options[mySelect.options.length] = new Option("Dundee schools",'all=Dundee'); mySelect.options[mySelect.options.length] = new Option("Lafayette schools",'all=Lafayette'); mySelect.options[mySelect.options.length] = new Option("Mcminnville schools",'all=Mcminnville'); mySelect.options[mySelect.options.length] = new Option("Newberg schools",'all=Newberg'); mySelect.options[mySelect.options.length] = new Option("Sheridan schools",'all=Sheridan'); mySelect.options[mySelect.options.length] = new Option("Willamina schools",'all=Willamina'); mySelect.options[mySelect.options.length] = new Option("Yamhill schools",'all=Yamhill'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Amity[Amity.length] = createMarker(new GPoint(-123.20149994,45.10449982),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Amity Elementary School",'Amity=' + Amity.length); Amity[Amity.length] = createMarker(new GPoint(-123.20149994,45.10449982),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Amity High School",'Amity=' + Amity.length); Amity[Amity.length] = createMarker(new GPoint(-123.20149994,45.10449982),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Amity Middle School",'Amity=' + Amity.length); Newberg[Newberg.length] = createMarker(new GPoint(-122.98036194,45.32453537),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Antonia Crater Elementary School",'Newberg=' + Newberg.length); Carlton[Carlton.length] = createMarker(new GPoint(-123.17729950,45.29190063),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Carlton Elementary School",'Carlton=' + Carlton.length); Sheridan[Sheridan.length] = createMarker(new GPoint(-123.39966583,45.09256363),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Chapman Grade School",'Sheridan=' + Sheridan.length); Newberg[Newberg.length] = createMarker(new GPoint(-122.98247528,45.32443619),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Chehalem Valley Middle School",'Newberg=' + Newberg.length); Mcminnville[Mcminnville.length] = createMarker(new GPoint(-123.21719360,45.20166397),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Columbus Elementary School",'Mcminnville=' + Mcminnville.length); Mcminnville[Mcminnville.length] = createMarker(new GPoint(-123.18792725,45.21233368),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cook Elementary School",'Mcminnville=' + Mcminnville.length); Dayton[Dayton.length] = createMarker(new GPoint(-123.07830048,45.21913528),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Dayton Grade School",'Dayton=' + Dayton.length); Dayton[Dayton.length] = createMarker(new GPoint(-123.08378601,45.21641541),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Dayton High School",'Dayton=' + Dayton.length); Dayton[Dayton.length] = createMarker(new GPoint(-123.08378601,45.21641541),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Dayton Junior High School",'Dayton=' + Dayton.length); Dundee[Dundee.length] = createMarker(new GPoint(-123.00983429,45.27991104),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Dundee Elementary School",'Dundee=' + Dundee.length); Mcminnville[Mcminnville.length] = createMarker(new GPoint(-123.20889282,45.21203995),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Duniway Middle School",'Mcminnville=' + Mcminnville.length); Newberg[Newberg.length] = createMarker(new GPoint(-122.97228241,45.29393768),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Edwards Elementary School",'Newberg=' + Newberg.length); Newberg[Newberg.length] = createMarker(new GPoint(-123.05834961,45.33041000),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Ewing Young Elementary School",'Newberg=' + Newberg.length); Sheridan[Sheridan.length] = createMarker(new GPoint(-123.39874268,45.10119629),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Faulconer Elementary School",'Sheridan=' + Sheridan.length); Mcminnville[Mcminnville.length] = createMarker(new GPoint(-123.18715668,45.23442078),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Grandhaven Elementary School",'Mcminnville=' + Mcminnville.length); Sheridan[Sheridan.length] = createMarker(new GPoint(-123.39520264,45.09533310),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Japanese Program",'Sheridan=' + Sheridan.length); Newberg[Newberg.length] = createMarker(new GPoint(-122.94999695,45.31065750),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mabel Rush Elementary School",'Newberg=' + Newberg.length); Mcminnville[Mcminnville.length] = createMarker(new GPoint(-123.19207764,45.21873856),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Mcminnville High School",'Mcminnville=' + Mcminnville.length); Mcminnville[Mcminnville.length] = createMarker(new GPoint(-123.20310211,45.21803665),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Memorial Elementary School",'Mcminnville=' + Mcminnville.length); Newberg[Newberg.length] = createMarker(new GPoint(-122.95099640,45.31443787),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Mountain View Middle School",'Newberg=' + Newberg.length); Newberg[Newberg.length] = createMarker(new GPoint(-122.95070648,45.31256485),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Newberg Senior High School",'Newberg=' + Newberg.length); Mcminnville[Mcminnville.length] = createMarker(new GPoint(-123.20964813,45.20933533),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Newby Elementary School",'Mcminnville=' + Mcminnville.length); Sheridan[Sheridan.length] = createMarker(new GPoint(-123.39520264,45.09531021),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Opportunity House",'Sheridan=' + Sheridan.length); Mcminnville[Mcminnville.length] = createMarker(new GPoint(-123.18702698,45.22213745),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Patton Middle School",'Mcminnville=' + Mcminnville.length); Sheridan[Sheridan.length] = createMarker(new GPoint(-123.39520264,45.09533310),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Sheridan High School",'Sheridan=' + Sheridan.length); Lafayette[Lafayette.length] = createMarker(new GPoint(-123.11270142,45.24580002),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wascher Elementary School",'Lafayette=' + Lafayette.length); Willamina[Willamina.length] = createMarker(new GPoint(-123.47763824,45.08526230),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Willamina Elementary School",'Willamina=' + Willamina.length); Willamina[Willamina.length] = createMarker(new GPoint(-123.47763824,45.08526230),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Willamina High School",'Willamina=' + Willamina.length); Yamhill[Yamhill.length] = createMarker(new GPoint(-123.18608856,45.34163666),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Yamhill Grade School",'Yamhill=' + Yamhill.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(Amity); map.removeOverlays(Carlton); map.removeOverlays(Dayton); map.removeOverlays(Dundee); map.removeOverlays(Lafayette); map.removeOverlays(Mcminnville); map.removeOverlays(Newberg); map.removeOverlays(Sheridan); map.removeOverlays(Willamina); map.removeOverlays(Yamhill); 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(Amity);map.removeOverlays(Amity); map.removeOverlays(Carlton); map.removeOverlays(Dayton); map.removeOverlays(Dundee); map.removeOverlays(Lafayette); map.removeOverlays(Mcminnville); map.removeOverlays(Newberg); map.removeOverlays(Sheridan); map.removeOverlays(Willamina); map.removeOverlays(Yamhill); map.addOverlays(Amity); centerByArray(Amity, false, false); cntMarker += Amity.length; map.addOverlays(Carlton); centerByArray(Carlton, false, false); cntMarker += Carlton.length; map.addOverlays(Dayton); centerByArray(Dayton, false, false); cntMarker += Dayton.length; map.addOverlays(Dundee); centerByArray(Dundee, false, false); cntMarker += Dundee.length; map.addOverlays(Lafayette); centerByArray(Lafayette, false, false); cntMarker += Lafayette.length; map.addOverlays(Mcminnville); centerByArray(Mcminnville, false, false); cntMarker += Mcminnville.length; map.addOverlays(Newberg); centerByArray(Newberg, false, false); cntMarker += Newberg.length; map.addOverlays(Sheridan); centerByArray(Sheridan, false, false); cntMarker += Sheridan.length; map.addOverlays(Willamina); centerByArray(Willamina, false, false); cntMarker += Willamina.length; map.addOverlays(Yamhill); centerByArray(Yamhill, false, false); cntMarker += Yamhill.length; centerByArray(Amity,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'); } }