function addMarkers() { mySelect = document.getElementById('selection'); Blossburg = [];Wellsboro = [];Elkland = [];Westfield = [];Liberty = [];Mansfield = [];Tioga = [];mySelect.options[mySelect.options.length] = new Option("Blossburg schools",'all=Blossburg'); mySelect.options[mySelect.options.length] = new Option("Elkland schools",'all=Elkland'); mySelect.options[mySelect.options.length] = new Option("Liberty schools",'all=Liberty'); mySelect.options[mySelect.options.length] = new Option("Mansfield schools",'all=Mansfield'); mySelect.options[mySelect.options.length] = new Option("Tioga schools",'all=Tioga'); mySelect.options[mySelect.options.length] = new Option("Wellsboro schools",'all=Wellsboro'); mySelect.options[mySelect.options.length] = new Option("Westfield schools",'all=Westfield'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Blossburg[Blossburg.length] = createMarker(new GPoint(-77.06352234,41.67973709),"
Blossburg Elementary School
133 Hannibal St
Blossburg, PA 16912

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Blossburg Elementary School",'Blossburg=' + Blossburg.length); Wellsboro[Wellsboro.length] = createMarker(new GPoint(-77.29798126,41.74209976),"
Charlotte Lappla Elementary School
32 Meade St
Wellsboro, PA 16901

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Charlotte Lappla Elementary School",'Wellsboro=' + Wellsboro.length); Elkland[Elkland.length] = createMarker(new GPoint(-77.30261230,41.99317932),"
Clark Wood Elementary School
112 Ellison Rd
Elkland, PA 16920

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Clark Wood Elementary School",'Elkland=' + Elkland.length); Westfield[Westfield.length] = createMarker(new GPoint(-77.55352783,41.91746140),"
Cowanesque Valley Junior Senior High School
18 State Route 49
Westfield, PA 16950

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cowanesque Valley Junior Senior High School",'Westfield=' + Westfield.length); Wellsboro[Wellsboro.length] = createMarker(new GPoint(-77.29797363,41.74148560),"
Don Gill Elementary School
10 Sherman St
Wellsboro, PA 16901

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Don Gill Elementary School",'Wellsboro=' + Wellsboro.length); Elkland[Elkland.length] = createMarker(new GPoint(-77.30261230,41.99311829),"
Elkland Area High School
110 Ellison Rd
Elkland, PA 16920

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Elkland Area High School",'Elkland=' + Elkland.length); Liberty[Liberty.length] = createMarker(new GPoint(-77.10089874,41.55659866),"
Liberty Elementary School
8622 Route 414
Liberty, PA 16930

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Liberty Elementary School",'Liberty=' + Liberty.length); Liberty[Liberty.length] = createMarker(new GPoint(-77.10610199,41.55789948),"
Liberty Junior Senior High School
Po Box 135
Liberty, PA 16930

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Liberty Junior Senior High School",'Liberty=' + Liberty.length); Mansfield[Mansfield.length] = createMarker(new GPoint(-77.07993317,41.80681610),"
Mansfield Junior Senior High School
73 W Wellsboro St
Mansfield, PA 16933

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Mansfield Junior Senior High School",'Mansfield=' + Mansfield.length); Blossburg[Blossburg.length] = createMarker(new GPoint(-77.06418610,41.67883301),"
North Penn Junior Senior High School
300 Morris St
Blossburg, PA 16912

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("North Penn Junior Senior High School",'Blossburg=' + Blossburg.length); Wellsboro[Wellsboro.length] = createMarker(new GPoint(-77.30335999,41.75048828),"
Rock L Butler Middle School
9 Nichols St
Wellsboro, PA 16901

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Rock L Butler Middle School",'Wellsboro=' + Wellsboro.length); Tioga[Tioga.length] = createMarker(new GPoint(-77.13449860,41.90930176),"
Russell B Walter Elementary School
Rr 2 Box 206
Tioga, PA 16946

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Russell B Walter Elementary School",'Tioga=' + Tioga.length); Mansfield[Mansfield.length] = createMarker(new GPoint(-77.07832336,41.80522156),"
Warren L Miller Elementary School
Dorsett Drive
Mansfield, PA 16933

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Warren L Miller Elementary School",'Mansfield=' + Mansfield.length); Wellsboro[Wellsboro.length] = createMarker(new GPoint(-77.30338287,41.75061035),"
Wellsboro Area High School
225 Nichols St
Wellsboro, PA 16901

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Wellsboro Area High School",'Wellsboro=' + Wellsboro.length); Westfield[Westfield.length] = createMarker(new GPoint(-77.53836060,41.91788101),"
Westfield Area Elementary School
548 West Main St
Westfield, PA 16950

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Westfield Area Elementary School",'Westfield=' + Westfield.length); Tioga[Tioga.length] = createMarker(new GPoint(-77.13196564,41.90835190),"
Williamson Senior High School
Route 15
Tioga, PA 16946

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Williamson Senior High School",'Tioga=' + Tioga.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(Blossburg); map.removeOverlays(Elkland); map.removeOverlays(Liberty); map.removeOverlays(Mansfield); map.removeOverlays(Tioga); map.removeOverlays(Wellsboro); map.removeOverlays(Westfield); 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(Blossburg);map.removeOverlays(Blossburg); map.removeOverlays(Elkland); map.removeOverlays(Liberty); map.removeOverlays(Mansfield); map.removeOverlays(Tioga); map.removeOverlays(Wellsboro); map.removeOverlays(Westfield); map.addOverlays(Blossburg); centerByArray(Blossburg, false, false); cntMarker += Blossburg.length; map.addOverlays(Elkland); centerByArray(Elkland, false, false); cntMarker += Elkland.length; map.addOverlays(Liberty); centerByArray(Liberty, false, false); cntMarker += Liberty.length; map.addOverlays(Mansfield); centerByArray(Mansfield, false, false); cntMarker += Mansfield.length; map.addOverlays(Tioga); centerByArray(Tioga, false, false); cntMarker += Tioga.length; map.addOverlays(Wellsboro); centerByArray(Wellsboro, false, false); cntMarker += Wellsboro.length; map.addOverlays(Westfield); centerByArray(Westfield, false, false); cntMarker += Westfield.length; centerByArray(Blossburg,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'); } }