function addMarkers() { mySelect = document.getElementById('selection'); Punxsutawney = [];Big_Run = [];Brockway = [];Brookville = [];Reynoldsville = [];Anita = [];mySelect.options[mySelect.options.length] = new Option("Anita schools",'all=Anita'); mySelect.options[mySelect.options.length] = new Option("Big Run schools",'all=Big_Run'); mySelect.options[mySelect.options.length] = new Option("Brockway schools",'all=Brockway'); mySelect.options[mySelect.options.length] = new Option("Brookville schools",'all=Brookville'); mySelect.options[mySelect.options.length] = new Option("Punxsutawney schools",'all=Punxsutawney'); mySelect.options[mySelect.options.length] = new Option("Reynoldsville schools",'all=Reynoldsville'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Punxsutawney[Punxsutawney.length] = createMarker(new GPoint(-78.97380066,40.94760132),"
Bell Township Elementary School
662 Airport Rd
Punxsutawney, PA 15767

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bell Township Elementary School",'Punxsutawney=' + Punxsutawney.length); Big_Run[Big_Run.length] = createMarker(new GPoint(-78.87030029,40.96873856),"
Big Run Elementary School
E Main Street
Big Run, PA 15715

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Big Run Elementary School",'Big_Run=' + Big_Run.length); Brockway[Brockway.length] = createMarker(new GPoint(-78.80532074,41.25196457),"
Brockway Area Elementary School
40 North St
Brockway, PA 15824

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Brockway Area Elementary School",'Brockway=' + Brockway.length); Brockway[Brockway.length] = createMarker(new GPoint(-78.80235291,41.25054169),"
Brockway Area Junior Senior High School
100 Alexander St
Brockway, PA 15824

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Brockway Area Junior Senior High School",'Brockway=' + Brockway.length); Brookville[Brookville.length] = createMarker(new GPoint(-79.08570099,41.16721725),"
Brookville Junior Senior High School
96 Jenks St
Brookville, PA 15825

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Brookville Junior Senior High School",'Brookville=' + Brookville.length); Reynoldsville[Reynoldsville.length] = createMarker(new GPoint(-78.88443756,41.09015274),"
C G Johnson Elementary School
923 Jackson St
Reynoldsville, PA 15851

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("C G Johnson Elementary School",'Reynoldsville=' + Reynoldsville.length); Brookville[Brookville.length] = createMarker(new GPoint(-79.06189728,41.15530014),"
Hickory Grove Elementary School
Po Box 479
Brookville, PA 15825

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Hickory Grove Elementary School",'Brookville=' + Brookville.length); Reynoldsville[Reynoldsville.length] = createMarker(new GPoint(-78.89644623,41.10692596),"
Jefferson County-dubois Avts High School
576 Vo Tech Rd
Reynoldsville, PA 15851

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Jefferson County-dubois Avts High School",'Reynoldsville=' + Reynoldsville.length); Punxsutawney[Punxsutawney.length] = createMarker(new GPoint(-78.96848297,40.94932175),"
Jenks Hill Elementary School
Jenks Avenue
Punxsutawney, PA 15767

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Jenks Hill Elementary School",'Punxsutawney=' + Punxsutawney.length); Punxsutawney[Punxsutawney.length] = createMarker(new GPoint(-78.98485565,40.92338562),"
Longview Elementary School
19466 Route 119 Highway N
Punxsutawney, PA 15767

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Longview Elementary School",'Punxsutawney=' + Punxsutawney.length); Punxsutawney[Punxsutawney.length] = createMarker(new GPoint(-78.97097778,40.94277954),"
Mapleview Elementary School
9329 Route 536
Punxsutawney, PA 15767

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mapleview Elementary School",'Punxsutawney=' + Punxsutawney.length); Punxsutawney[Punxsutawney.length] = createMarker(new GPoint(-78.96717072,40.94436264),"
Mary A Wilson Elementary School
407 E Mahoning Street
Punxsutawney, PA 15767

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mary A Wilson Elementary School",'Punxsutawney=' + Punxsutawney.length); Brookville[Brookville.length] = createMarker(new GPoint(-79.06189728,41.15530014),"
Northside Elementary School
Po Box 479
Brookville, PA 15825

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Northside Elementary School",'Brookville=' + Brookville.length); Anita[Anita.length] = createMarker(new GPoint(-78.96150208,41.00379944),"
Parkview Elementary School
Po Box 285
Anita, PA 15711

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Parkview Elementary School",'Anita=' + Anita.length); Brookville[Brookville.length] = createMarker(new GPoint(-79.06189728,41.15530014),"
Pinecreek Elementary School
Po Box 479
Brookville, PA 15825

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Pinecreek Elementary School",'Brookville=' + Brookville.length); Punxsutawney[Punxsutawney.length] = createMarker(new GPoint(-78.97751617,40.94939804),"
Punxsutawney Area High School
450 N Findley Street
Punxsutawney, PA 15767

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Punxsutawney Area High School",'Punxsutawney=' + Punxsutawney.length); Punxsutawney[Punxsutawney.length] = createMarker(new GPoint(-78.97834015,40.94981766),"
Punxsutawney Area Middle School
465 Beyer Ave
Punxsutawney, PA 15767

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Punxsutawney Area Middle School",'Punxsutawney=' + Punxsutawney.length); Reynoldsville[Reynoldsville.length] = createMarker(new GPoint(-78.94110107,41.08890152),"
Sykesville Elementary School
1100 Sykesville School Rd
Reynoldsville, PA 15851

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Sykesville Elementary School",'Reynoldsville=' + Reynoldsville.length); Punxsutawney[Punxsutawney.length] = createMarker(new GPoint(-78.99040222,40.94746017),"
West End Elementary School
300 Center St
Punxsutawney, PA 15767

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("West End Elementary School",'Punxsutawney=' + Punxsutawney.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(Anita); map.removeOverlays(Big_Run); map.removeOverlays(Brockway); map.removeOverlays(Brookville); map.removeOverlays(Punxsutawney); map.removeOverlays(Reynoldsville); 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(Punxsutawney);map.removeOverlays(Anita); map.removeOverlays(Big_Run); map.removeOverlays(Brockway); map.removeOverlays(Brookville); map.removeOverlays(Punxsutawney); map.removeOverlays(Reynoldsville); map.addOverlays(Anita); centerByArray(Anita, false, false); cntMarker += Anita.length; map.addOverlays(Big_Run); centerByArray(Big_Run, false, false); cntMarker += Big_Run.length; map.addOverlays(Brockway); centerByArray(Brockway, false, false); cntMarker += Brockway.length; map.addOverlays(Brookville); centerByArray(Brookville, false, false); cntMarker += Brookville.length; map.addOverlays(Punxsutawney); centerByArray(Punxsutawney, false, false); cntMarker += Punxsutawney.length; map.addOverlays(Reynoldsville); centerByArray(Reynoldsville, false, false); cntMarker += Reynoldsville.length; centerByArray(Punxsutawney,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'); } }