function addMarkers() { mySelect = document.getElementById('selection'); Port_Townsend = [];Brinnon = [];Port_Hadlock = [];Chimacum = [];Forks = [];Quilcene = [];mySelect.options[mySelect.options.length] = new Option("Brinnon schools",'all=Brinnon'); mySelect.options[mySelect.options.length] = new Option("Chimacum schools",'all=Chimacum'); mySelect.options[mySelect.options.length] = new Option("Forks schools",'all=Forks'); mySelect.options[mySelect.options.length] = new Option("Port Hadlock schools",'all=Port_Hadlock'); mySelect.options[mySelect.options.length] = new Option("Port Townsend schools",'all=Port_Townsend'); mySelect.options[mySelect.options.length] = new Option("Quilcene schools",'all=Quilcene'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Port_Townsend[Port_Townsend.length] = createMarker(new GPoint(-122.77800751,48.12811279),"
Blue Heron Middle School
3939 San Juan Av
Port Townsend, WA 98368

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Blue Heron Middle School",'Port_Townsend=' + Port_Townsend.length); Brinnon[Brinnon.length] = createMarker(new GPoint(-122.90294647,47.69696808),"
Brinnon Elementary School
46 Schoolhouse Rd
Brinnon, WA 98320

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Brinnon Elementary School",'Brinnon=' + Brinnon.length); Port_Hadlock[Port_Hadlock.length] = createMarker(new GPoint(-122.76879883,48.03264999),"
Chimacum Creek Primary School
313 Ness Corner Rd
Port Hadlock, WA 98339

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Chimacum Creek Primary School",'Port_Hadlock=' + Port_Hadlock.length); Chimacum[Chimacum.length] = createMarker(new GPoint(-122.77839661,48.01346207),"
Chimacum Elementary School
Po Box 278
Chimacum, WA 98325

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Chimacum Elementary School",'Chimacum=' + Chimacum.length); Chimacum[Chimacum.length] = createMarker(new GPoint(-122.77839661,48.01346207),"
Chimacum High School
Po Box 278
Chimacum, WA 98325

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Chimacum High School",'Chimacum=' + Chimacum.length); Chimacum[Chimacum.length] = createMarker(new GPoint(-122.77839661,48.01346207),"
Chimacum Middle School
Po Box 278
Chimacum, WA 98325

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Chimacum Middle School",'Chimacum=' + Chimacum.length); Port_Townsend[Port_Townsend.length] = createMarker(new GPoint(-122.79166412,48.11121750),"
Grant Street Elementary School
1637 Grant St
Port Townsend, WA 98368

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Grant Street Elementary School",'Port_Townsend=' + Port_Townsend.length); Port_Townsend[Port_Townsend.length] = createMarker(new GPoint(-122.79166412,48.11121750),"
I.c.e. Program
1637 Grant Street
Port Townsend, WA 98368

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("I.c.e. Program",'Port_Townsend=' + Port_Townsend.length); Port_Townsend[Port_Townsend.length] = createMarker(new GPoint(-122.77223969,48.11526489),"
Mountain View Elementary School
1919 Blaine Street
Port Townsend, WA 98368

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mountain View Elementary School",'Port_Townsend=' + Port_Townsend.length); Chimacum[Chimacum.length] = createMarker(new GPoint(-122.78800201,47.98889923),"
P1 Program Elementary School
Po Box 278
Chimacum, WA 98325

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("P1 Program Elementary School",'Chimacum=' + Chimacum.length); Port_Townsend[Port_Townsend.length] = createMarker(new GPoint(-122.76821899,48.11771393),"
Port Townsend High School
1500 Van Ness St
Port Townsend, WA 98368

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Port Townsend High School",'Port_Townsend=' + Port_Townsend.length); Port_Townsend[Port_Townsend.length] = createMarker(new GPoint(-122.76909100,48.11974000),"
Port Townsend Special Education
450 Fir Street
Port Townsend, WA 98368

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Port Townsend Special Education",'Port_Townsend=' + Port_Townsend.length); Forks[Forks.length] = createMarker(new GPoint(-124.35617828,47.89152145),"
Queets-clearwater Elementary School
146000 Hwy 101
Forks, WA 98331

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Queets-clearwater Elementary School",'Forks=' + Forks.length); Quilcene[Quilcene.length] = createMarker(new GPoint(-122.87451172,47.82257080),"
Quilcene High And Elementary School
Po Box 40
Quilcene, WA 98376

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Quilcene High And Elementary School",'Quilcene=' + Quilcene.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(Brinnon); map.removeOverlays(Chimacum); map.removeOverlays(Forks); map.removeOverlays(Port_Hadlock); map.removeOverlays(Port_Townsend); map.removeOverlays(Quilcene); 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(Port_Townsend);map.removeOverlays(Brinnon); map.removeOverlays(Chimacum); map.removeOverlays(Forks); map.removeOverlays(Port_Hadlock); map.removeOverlays(Port_Townsend); map.removeOverlays(Quilcene); map.addOverlays(Brinnon); centerByArray(Brinnon, false, false); cntMarker += Brinnon.length; map.addOverlays(Chimacum); centerByArray(Chimacum, false, false); cntMarker += Chimacum.length; map.addOverlays(Forks); centerByArray(Forks, false, false); cntMarker += Forks.length; map.addOverlays(Port_Hadlock); centerByArray(Port_Hadlock, false, false); cntMarker += Port_Hadlock.length; map.addOverlays(Port_Townsend); centerByArray(Port_Townsend, false, false); cntMarker += Port_Townsend.length; map.addOverlays(Quilcene); centerByArray(Quilcene, false, false); cntMarker += Quilcene.length; centerByArray(Port_Townsend,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'); } }