function addMarkers() { mySelect = document.getElementById('selection'); Grants_Pass = [];Cave_Junction = [];Williams = [];Wolf_Creek = [];mySelect.options[mySelect.options.length] = new Option("Cave Junction schools",'all=Cave_Junction'); mySelect.options[mySelect.options.length] = new Option("Grants Pass schools",'all=Grants_Pass'); mySelect.options[mySelect.options.length] = new Option("Williams schools",'all=Williams'); mySelect.options[mySelect.options.length] = new Option("Wolf Creek schools",'all=Wolf_Creek'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Grants_Pass[Grants_Pass.length] = createMarker(new GPoint(-123.34503174,42.41081238),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Allen Dale Elementary School",'Grants_Pass=' + Grants_Pass.length); Cave_Junction[Cave_Junction.length] = createMarker(new GPoint(-123.65219879,42.16953659),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Evergreen Elementary School",'Cave_Junction=' + Cave_Junction.length); Grants_Pass[Grants_Pass.length] = createMarker(new GPoint(-123.32466400,42.44316500),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Family Friends Day Treatment Center",'Grants_Pass=' + Grants_Pass.length); Grants_Pass[Grants_Pass.length] = createMarker(new GPoint(-123.37512207,42.50599670),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Fleming Middle School",'Grants_Pass=' + Grants_Pass.length); Grants_Pass[Grants_Pass.length] = createMarker(new GPoint(-123.30908203,42.42156601),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Fruitdale Elementary School",'Grants_Pass=' + Grants_Pass.length); Grants_Pass[Grants_Pass.length] = createMarker(new GPoint(-123.41567993,42.44662857),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Ft Vannoy Elementary School",'Grants_Pass=' + Grants_Pass.length); Grants_Pass[Grants_Pass.length] = createMarker(new GPoint(-123.31778717,42.44393921),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Grants Pass High School",'Grants_Pass=' + Grants_Pass.length); Grants_Pass[Grants_Pass.length] = createMarker(new GPoint(-123.34172058,42.32642746),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Hidden Valley High School",'Grants_Pass=' + Grants_Pass.length); Grants_Pass[Grants_Pass.length] = createMarker(new GPoint(-123.33231354,42.45980072),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Highland Elementary School",'Grants_Pass=' + Grants_Pass.length); Cave_Junction[Cave_Junction.length] = createMarker(new GPoint(-123.65280151,42.16939926),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Illinois Valley High School",'Cave_Junction=' + Cave_Junction.length); Grants_Pass[Grants_Pass.length] = createMarker(new GPoint(-123.43273163,42.40663528),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jerome Prairie Elementary School",'Grants_Pass=' + Grants_Pass.length); Grants_Pass[Grants_Pass.length] = createMarker(new GPoint(-123.31278229,42.45066833),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Grants_Pass=' + Grants_Pass.length); Grants_Pass[Grants_Pass.length] = createMarker(new GPoint(-123.33444977,42.34753799),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Lincoln Savage Middle School",'Grants_Pass=' + Grants_Pass.length); Cave_Junction[Cave_Junction.length] = createMarker(new GPoint(-123.64351654,42.16946030),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Lorna Byrne Middle School",'Cave_Junction=' + Cave_Junction.length); Grants_Pass[Grants_Pass.length] = createMarker(new GPoint(-123.36228180,42.36222076),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Madrona Elementary School",'Grants_Pass=' + Grants_Pass.length); Grants_Pass[Grants_Pass.length] = createMarker(new GPoint(-123.37451172,42.50593567),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Manzanita Elementary School",'Grants_Pass=' + Grants_Pass.length); Grants_Pass[Grants_Pass.length] = createMarker(new GPoint(-123.29794312,42.43251038),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Newbridge High School",'Grants_Pass=' + Grants_Pass.length); Grants_Pass[Grants_Pass.length] = createMarker(new GPoint(-123.33231354,42.45765305),"",iconBl); mySelect.options[mySelect.options.length] = new Option("North Middle School",'Grants_Pass=' + Grants_Pass.length); Grants_Pass[Grants_Pass.length] = createMarker(new GPoint(-123.38002777,42.51810074),"",iconGr); mySelect.options[mySelect.options.length] = new Option("North Valley High School",'Grants_Pass=' + Grants_Pass.length); Grants_Pass[Grants_Pass.length] = createMarker(new GPoint(-123.34951019,42.43386459),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Parkside Elementary School",'Grants_Pass=' + Grants_Pass.length); Grants_Pass[Grants_Pass.length] = createMarker(new GPoint(-123.38964844,42.42963791),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Redwood Elementary School",'Grants_Pass=' + Grants_Pass.length); Grants_Pass[Grants_Pass.length] = createMarker(new GPoint(-123.29868317,42.42639542),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Riverside Elementary School",'Grants_Pass=' + Grants_Pass.length); Grants_Pass[Grants_Pass.length] = createMarker(new GPoint(-123.33421326,42.41523743),"",iconBl); mySelect.options[mySelect.options.length] = new Option("South Middle School",'Grants_Pass=' + Grants_Pass.length); Grants_Pass[Grants_Pass.length] = createMarker(new GPoint(-123.40458679,42.51612854),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Southern Oregon Astc",'Grants_Pass=' + Grants_Pass.length); Grants_Pass[Grants_Pass.length] = createMarker(new GPoint(-123.34725189,42.41883087),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Southern Oregon Astc A&e",'Grants_Pass=' + Grants_Pass.length); Williams[Williams.length] = createMarker(new GPoint(-123.28469849,42.20790100),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Williams Elementary School",'Williams=' + Williams.length); Wolf_Creek[Wolf_Creek.length] = createMarker(new GPoint(-123.35399628,42.66759872),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wolf Creek Elementary School",'Wolf_Creek=' + Wolf_Creek.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(Cave_Junction); map.removeOverlays(Grants_Pass); map.removeOverlays(Williams); map.removeOverlays(Wolf_Creek); 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(Grants_Pass);map.removeOverlays(Cave_Junction); map.removeOverlays(Grants_Pass); map.removeOverlays(Williams); map.removeOverlays(Wolf_Creek); map.addOverlays(Cave_Junction); centerByArray(Cave_Junction, false, false); cntMarker += Cave_Junction.length; map.addOverlays(Grants_Pass); centerByArray(Grants_Pass, false, false); cntMarker += Grants_Pass.length; map.addOverlays(Williams); centerByArray(Williams, false, false); cntMarker += Williams.length; map.addOverlays(Wolf_Creek); centerByArray(Wolf_Creek, false, false); cntMarker += Wolf_Creek.length; centerByArray(Grants_Pass,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'); } }