function addMarkers() { mySelect = document.getElementById('selection'); Adrian = [];Ontario = [];Harper = [];Jordan_Valley = [];Juntura = [];Nyssa = [];Vale = [];Arock = [];mySelect.options[mySelect.options.length] = new Option("Adrian schools",'all=Adrian'); mySelect.options[mySelect.options.length] = new Option("Arock schools",'all=Arock'); mySelect.options[mySelect.options.length] = new Option("Harper schools",'all=Harper'); mySelect.options[mySelect.options.length] = new Option("Jordan Valley schools",'all=Jordan_Valley'); mySelect.options[mySelect.options.length] = new Option("Juntura schools",'all=Juntura'); mySelect.options[mySelect.options.length] = new Option("Nyssa schools",'all=Nyssa'); mySelect.options[mySelect.options.length] = new Option("Ontario schools",'all=Ontario'); mySelect.options[mySelect.options.length] = new Option("Vale schools",'all=Vale'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Adrian[Adrian.length] = createMarker(new GPoint(-117.11129761,43.60599899),"
Adrian Elementary School
Po Box 108
Adrian, OR 97901

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Adrian Elementary School",'Adrian=' + Adrian.length); Adrian[Adrian.length] = createMarker(new GPoint(-117.11129761,43.60599899),"
Adrian High School
Po Box 108
Adrian, OR 97901

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Adrian High School",'Adrian=' + Adrian.length); Ontario[Ontario.length] = createMarker(new GPoint(-116.98423767,44.02863693),"
Aiken Elementary School
1297 W Idaho Ave
Ontario, OR 97914

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Aiken Elementary School",'Ontario=' + Ontario.length); Ontario[Ontario.length] = createMarker(new GPoint(-116.98291016,44.01756287),"
Alameda Elementary School
1252 Alameda Dr
Ontario, OR 97914

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Alameda Elementary School",'Ontario=' + Ontario.length); Ontario[Ontario.length] = createMarker(new GPoint(-116.98688507,44.23633575),"
Annex Elementary School
402 Annex Rd
Ontario, OR 97914

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Annex Elementary School",'Ontario=' + Ontario.length); Ontario[Ontario.length] = createMarker(new GPoint(-117.01290894,43.98856354),"
Cairo Elementary School
531 Hwy 2026
Ontario, OR 97914

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Cairo Elementary School",'Ontario=' + Ontario.length); Ontario[Ontario.length] = createMarker(new GPoint(-116.96466064,44.03821945),"
Four Rivers Community School
2232 Sw 4th Ave
Ontario, OR 97914

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Four Rivers Community School",'Ontario=' + Ontario.length); Harper[Harper.length] = createMarker(new GPoint(-117.60946655,43.86249924),"
Harper School
2987 Harperwestfall Rd
Harper, OR 97906

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Harper School",'Harper=' + Harper.length); Jordan_Valley[Jordan_Valley.length] = createMarker(new GPoint(-118.07552338,42.98717880),"
Jordan Valley Elementary School
Po Box 99
Jordan Valley, OR 97910

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Jordan Valley Elementary School",'Jordan_Valley=' + Jordan_Valley.length); Jordan_Valley[Jordan_Valley.length] = createMarker(new GPoint(-118.07552338,42.98717880),"
Jordan Valley High School
Po Box 99
Jordan Valley, OR 97910

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Jordan Valley High School",'Jordan_Valley=' + Jordan_Valley.length); Juntura[Juntura.length] = createMarker(new GPoint(-118.00980377,43.86479950),"
Juntura Elementary School
Po Box 248
Juntura, OR 97911

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Juntura Elementary School",'Juntura=' + Juntura.length); Ontario[Ontario.length] = createMarker(new GPoint(-116.97150421,44.03364944),"
May Roberts Elementary School
590 Nw 8th St
Ontario, OR 97914

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("May Roberts Elementary School",'Ontario=' + Ontario.length); Nyssa[Nyssa.length] = createMarker(new GPoint(-117.00177765,43.87756348),"
Nyssa Elementary School
809 Bower Ave
Nyssa, OR 97913

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Nyssa Elementary School",'Nyssa=' + Nyssa.length); Nyssa[Nyssa.length] = createMarker(new GPoint(-117.00347137,43.87482071),"
Nyssa High School
824 Adrian Blvd
Nyssa, OR 97913

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Nyssa High School",'Nyssa=' + Nyssa.length); Nyssa[Nyssa.length] = createMarker(new GPoint(-117.00658417,43.87656784),"
Nyssa Middle School
101 S 11th St
Nyssa, OR 97913

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Nyssa Middle School",'Nyssa=' + Nyssa.length); Ontario[Ontario.length] = createMarker(new GPoint(-116.97853851,44.02863693),"
Ontario High School
1115 W Idaho Ave
Ontario, OR 97914

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Ontario High School",'Ontario=' + Ontario.length); Ontario[Ontario.length] = createMarker(new GPoint(-116.97021484,44.02611542),"
Ontario Middle School
573 Sw 2nd Ave
Ontario, OR 97914

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Ontario Middle School",'Ontario=' + Ontario.length); Ontario[Ontario.length] = createMarker(new GPoint(-116.93441010,44.11919785),"
Pioneer Elementary School
4744 Pioneer Rd
Ontario, OR 97914

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Pioneer Elementary School",'Ontario=' + Ontario.length); Jordan_Valley[Jordan_Valley.length] = createMarker(new GPoint(-117.54199982,42.62250137),"
Rockville Elementary School
Po Box 99
Jordan Valley, OR 97910

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Rockville Elementary School",'Jordan_Valley=' + Jordan_Valley.length); Vale[Vale.length] = createMarker(new GPoint(-117.23690796,43.98265076),"
Vale Elementary School
403 E St W
Vale, OR 97918

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Vale Elementary School",'Vale=' + Vale.length); Vale[Vale.length] = createMarker(new GPoint(-117.25189209,43.97888565),"
Vale High School
505 Viking Dr
Vale, OR 97918

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Vale High School",'Vale=' + Vale.length); Vale[Vale.length] = createMarker(new GPoint(-117.23690796,43.98265076),"
Vale Middle School
403 E St W
Vale, OR 97918

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Vale Middle School",'Vale=' + Vale.length); Arock[Arock.length] = createMarker(new GPoint(-117.52600098,42.91469955),"
W W Jones Elementary School
Po Box 131
Arock, OR 97902

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("W W Jones Elementary School",'Arock=' + Arock.length); Vale[Vale.length] = createMarker(new GPoint(-117.36528778,44.11284256),"
Willowcreek Elementary School
2300 9th Ave W
Vale, OR 97918

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Willowcreek Elementary School",'Vale=' + Vale.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(Adrian); map.removeOverlays(Arock); map.removeOverlays(Harper); map.removeOverlays(Jordan_Valley); map.removeOverlays(Juntura); map.removeOverlays(Nyssa); map.removeOverlays(Ontario); map.removeOverlays(Vale); 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(Adrian);map.removeOverlays(Adrian); map.removeOverlays(Arock); map.removeOverlays(Harper); map.removeOverlays(Jordan_Valley); map.removeOverlays(Juntura); map.removeOverlays(Nyssa); map.removeOverlays(Ontario); map.removeOverlays(Vale); map.addOverlays(Adrian); centerByArray(Adrian, false, false); cntMarker += Adrian.length; map.addOverlays(Arock); centerByArray(Arock, false, false); cntMarker += Arock.length; map.addOverlays(Harper); centerByArray(Harper, false, false); cntMarker += Harper.length; map.addOverlays(Jordan_Valley); centerByArray(Jordan_Valley, false, false); cntMarker += Jordan_Valley.length; map.addOverlays(Juntura); centerByArray(Juntura, false, false); cntMarker += Juntura.length; map.addOverlays(Nyssa); centerByArray(Nyssa, false, false); cntMarker += Nyssa.length; map.addOverlays(Ontario); centerByArray(Ontario, false, false); cntMarker += Ontario.length; map.addOverlays(Vale); centerByArray(Vale, false, false); cntMarker += Vale.length; centerByArray(Adrian,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'); } }