function addMarkers() { mySelect = document.getElementById('selection'); Bandon = [];North_Bend = [];Coos_Bay = [];Coquille = [];Myrtle_Point = [];Powers = [];mySelect.options[mySelect.options.length] = new Option("Bandon schools",'all=Bandon'); mySelect.options[mySelect.options.length] = new Option("Coos Bay schools",'all=Coos_Bay'); mySelect.options[mySelect.options.length] = new Option("Coquille schools",'all=Coquille'); mySelect.options[mySelect.options.length] = new Option("Myrtle Point schools",'all=Myrtle_Point'); mySelect.options[mySelect.options.length] = new Option("North Bend schools",'all=North_Bend'); mySelect.options[mySelect.options.length] = new Option("Powers schools",'all=Powers'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Bandon[Bandon.length] = createMarker(new GPoint(-124.42001343,43.11531067),"
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bandon Senior High School",'Bandon=' + Bandon.length); North_Bend[North_Bend.length] = createMarker(new GPoint(-124.24140930,43.40519714),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bangor Elementary School",'North_Bend=' + North_Bend.length); Coos_Bay[Coos_Bay.length] = createMarker(new GPoint(-124.23040009,43.35039902),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Blossom Gulch Elementary School",'Coos_Bay=' + Coos_Bay.length); Coos_Bay[Coos_Bay.length] = createMarker(new GPoint(-124.23040009,43.35039902),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bunker Hill Elementary School",'Coos_Bay=' + Coos_Bay.length); Coos_Bay[Coos_Bay.length] = createMarker(new GPoint(-124.23040009,43.35039902),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Charleston Elementary School",'Coos_Bay=' + Coos_Bay.length); Coquille[Coquille.length] = createMarker(new GPoint(-124.19351959,43.18601227),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Coquille High School",'Coquille=' + Coquille.length); Coquille[Coquille.length] = createMarker(new GPoint(-124.18933400,43.17560100),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Coquille Valley Intermediate School",'Coquille=' + Coquille.length); Coquille[Coquille.length] = createMarker(new GPoint(-124.18748474,43.18485260),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Coquille Valley Middle School",'Coquille=' + Coquille.length); Coos_Bay[Coos_Bay.length] = createMarker(new GPoint(-124.23040009,43.35039902),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Destinations Public Charter School",'Coos_Bay=' + Coos_Bay.length); Coos_Bay[Coos_Bay.length] = createMarker(new GPoint(-124.23040009,43.35039902),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Eastside Elementary School",'Coos_Bay=' + Coos_Bay.length); Bandon[Bandon.length] = createMarker(new GPoint(-124.41915894,43.11533737),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Harbor Lights Middle School",'Bandon=' + Bandon.length); North_Bend[North_Bend.length] = createMarker(new GPoint(-124.22898865,43.40243530),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hillcrest Elementary School",'North_Bend=' + North_Bend.length); Coquille[Coquille.length] = createMarker(new GPoint(-124.19681549,43.18953705),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'Coquille=' + Coquille.length); North_Bend[North_Bend.length] = createMarker(new GPoint(-124.21047211,43.50252151),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lighthouse School",'North_Bend=' + North_Bend.length); Coquille[Coquille.length] = createMarker(new GPoint(-124.18211365,43.18693924),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Coquille=' + Coquille.length); Coos_Bay[Coos_Bay.length] = createMarker(new GPoint(-124.23040009,43.35039902),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Madison Elementary School",'Coos_Bay=' + Coos_Bay.length); Coos_Bay[Coos_Bay.length] = createMarker(new GPoint(-124.23040009,43.35039902),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Marshfield Senior High School",'Coos_Bay=' + Coos_Bay.length); Coos_Bay[Coos_Bay.length] = createMarker(new GPoint(-124.23040009,43.35039902),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Millicoma Intermediate School",'Coos_Bay=' + Coos_Bay.length); Myrtle_Point[Myrtle_Point.length] = createMarker(new GPoint(-124.13741302,43.06370544),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Myrtle Crest School",'Myrtle_Point=' + Myrtle_Point.length); Myrtle_Point[Myrtle_Point.length] = createMarker(new GPoint(-124.14323425,43.06116104),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Myrtle Point High School",'Myrtle_Point=' + Myrtle_Point.length); North_Bend[North_Bend.length] = createMarker(new GPoint(-124.21047211,43.50252151),"",iconRd); mySelect.options[mySelect.options.length] = new Option("North Bay Elementary School",'North_Bend=' + North_Bend.length); North_Bend[North_Bend.length] = createMarker(new GPoint(-124.23458862,43.39893723),"",iconBl); mySelect.options[mySelect.options.length] = new Option("North Bend Middle School",'North_Bend=' + North_Bend.length); North_Bend[North_Bend.length] = createMarker(new GPoint(-124.23480988,43.40233612),"",iconGr); mySelect.options[mySelect.options.length] = new Option("North Bend Senior High School",'North_Bend=' + North_Bend.length); Bandon[Bandon.length] = createMarker(new GPoint(-124.41618347,43.11381149),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Ocean Crest Elementary School",'Bandon=' + Bandon.length); North_Bend[North_Bend.length] = createMarker(new GPoint(-124.22927856,43.40090179),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Oregon Coast Technology School",'North_Bend=' + North_Bend.length); North_Bend[North_Bend.length] = createMarker(new GPoint(-124.15950012,43.43920135),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pacific Child Care Center",'North_Bend=' + North_Bend.length); Powers[Powers.length] = createMarker(new GPoint(-124.04270172,42.84859848),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Powers Elementary School",'Powers=' + Powers.length); Powers[Powers.length] = createMarker(new GPoint(-124.04270172,42.84859848),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Powers High School",'Powers=' + Powers.length); Coos_Bay[Coos_Bay.length] = createMarker(new GPoint(-124.23696500,43.37790100),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Resource Link Charter School",'Coos_Bay=' + Coos_Bay.length); Coos_Bay[Coos_Bay.length] = createMarker(new GPoint(-124.23040009,43.35039902),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Sunset Middle School",'Coos_Bay=' + Coos_Bay.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(Bandon); map.removeOverlays(Coos_Bay); map.removeOverlays(Coquille); map.removeOverlays(Myrtle_Point); map.removeOverlays(North_Bend); map.removeOverlays(Powers); 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(Bandon);map.removeOverlays(Bandon); map.removeOverlays(Coos_Bay); map.removeOverlays(Coquille); map.removeOverlays(Myrtle_Point); map.removeOverlays(North_Bend); map.removeOverlays(Powers); map.addOverlays(Bandon); centerByArray(Bandon, false, false); cntMarker += Bandon.length; map.addOverlays(Coos_Bay); centerByArray(Coos_Bay, false, false); cntMarker += Coos_Bay.length; map.addOverlays(Coquille); centerByArray(Coquille, false, false); cntMarker += Coquille.length; map.addOverlays(Myrtle_Point); centerByArray(Myrtle_Point, false, false); cntMarker += Myrtle_Point.length; map.addOverlays(North_Bend); centerByArray(North_Bend, false, false); cntMarker += North_Bend.length; map.addOverlays(Powers); centerByArray(Powers, false, false); cntMarker += Powers.length; centerByArray(Bandon,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'); } }