function addMarkers() { mySelect = document.getElementById('selection'); Everett = [];Bedford = [];Breezewood = [];Martinsburg = [];New_Paris = [];Fishertown = [];Defiance = [];Hyndman = [];Clearville = [];Loysburg = [];Saxton = [];mySelect.options[mySelect.options.length] = new Option("Bedford schools",'all=Bedford'); mySelect.options[mySelect.options.length] = new Option("Breezewood schools",'all=Breezewood'); mySelect.options[mySelect.options.length] = new Option("Clearville schools",'all=Clearville'); mySelect.options[mySelect.options.length] = new Option("Defiance schools",'all=Defiance'); mySelect.options[mySelect.options.length] = new Option("Everett schools",'all=Everett'); mySelect.options[mySelect.options.length] = new Option("Fishertown schools",'all=Fishertown'); mySelect.options[mySelect.options.length] = new Option("Hyndman schools",'all=Hyndman'); mySelect.options[mySelect.options.length] = new Option("Loysburg schools",'all=Loysburg'); mySelect.options[mySelect.options.length] = new Option("Martinsburg schools",'all=Martinsburg'); mySelect.options[mySelect.options.length] = new Option("New Paris schools",'all=New_Paris'); mySelect.options[mySelect.options.length] = new Option("Saxton schools",'all=Saxton'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Everett[Everett.length] = createMarker(new GPoint(-78.43634033,40.02172470),"
Bedford County Technical Cente
195 Pennknoll Rd
Everett, PA 15537

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bedford County Technical Cente",'Everett=' + Everett.length); Bedford[Bedford.length] = createMarker(new GPoint(-78.50376892,40.01900101),"
Bedford Elementary School
3639 Business Route 220
Bedford, PA 15522

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bedford Elementary School",'Bedford=' + Bedford.length); Bedford[Bedford.length] = createMarker(new GPoint(-78.49533844,40.01448441),"
Bedford Middle School
440 E Watson St
Bedford, PA 15522

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Bedford Middle School",'Bedford=' + Bedford.length); Bedford[Bedford.length] = createMarker(new GPoint(-78.49893188,40.01593399),"
Bedford Senior High School
330 E John St
Bedford, PA 15522

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bedford Senior High School",'Bedford=' + Bedford.length); Breezewood[Breezewood.length] = createMarker(new GPoint(-78.24362183,39.99852753),"
Breezewood Elementary School
133 North Main St
Breezewood, PA 15533

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Breezewood Elementary School",'Breezewood=' + Breezewood.length); Martinsburg[Martinsburg.length] = createMarker(new GPoint(-78.32398900,40.31100500),"
Central High School
Rr 1 Box 420
Martinsburg, PA 16662

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Central High School",'Martinsburg=' + Martinsburg.length); Everett[Everett.length] = createMarker(new GPoint(-78.49260712,39.82609177),"
Chaneysville-cove Elementary School
312 Chaneysville Cove Rd
Everett, PA 15537

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Chaneysville-cove Elementary School",'Everett=' + Everett.length); New_Paris[New_Paris.length] = createMarker(new GPoint(-78.58291626,40.14026260),"
Chestnut Ridge Central Elementary School
2534 Quaker Valley Road
New Paris, PA 15554

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Chestnut Ridge Central Elementary School",'New_Paris=' + New_Paris.length); Fishertown[Fishertown.length] = createMarker(new GPoint(-78.58623505,40.12720108),"
Chestnut Ridge Middle School
3281 Valley Road
Fishertown, PA 15539

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Chestnut Ridge Middle School",'Fishertown=' + Fishertown.length); New_Paris[New_Paris.length] = createMarker(new GPoint(-78.58290863,40.14172745),"
Chestnut Ridge Senior High School
2588 Quaker Valley Road
New Paris, PA 15554

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Chestnut Ridge Senior High School",'New_Paris=' + New_Paris.length); Defiance[Defiance.length] = createMarker(new GPoint(-78.23000336,40.16109848),"
Defiance Gr School
Po Box 126
Defiance, PA 16633

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Defiance Gr School",'Defiance=' + Defiance.length); Everett[Everett.length] = createMarker(new GPoint(-78.36037445,40.00636292),"
Everett Area Elementary School
165 E First Ave
Everett, PA 15537

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Everett Area Elementary School",'Everett=' + Everett.length); Everett[Everett.length] = createMarker(new GPoint(-78.36511993,40.01457977),"
Everett Area Junior Senior High School
1 Renaissance Circle
Everett, PA 15537

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Everett Area Junior Senior High School",'Everett=' + Everett.length); Hyndman[Hyndman.length] = createMarker(new GPoint(-78.72769928,39.81240082),"
Hyndman Ms/shs
Po Box 695
Hyndman, PA 15545

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Hyndman Ms/shs",'Hyndman=' + Hyndman.length); Hyndman[Hyndman.length] = createMarker(new GPoint(-78.72769928,39.81240082),"
Hyndman/londonderry Elementary School
Po Box 737
Hyndman, PA 15545

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Hyndman/londonderry Elementary School",'Hyndman=' + Hyndman.length); Clearville[Clearville.length] = createMarker(new GPoint(-78.36903381,39.91690826),"
Mann-monroe Elementary School
268 Rockhill Church Rd
Clearville, PA 15535

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mann-monroe Elementary School",'Clearville=' + Clearville.length); New_Paris[New_Paris.length] = createMarker(new GPoint(-78.64104462,40.12038422),"
New Paris Center Elementary School
4401 Cortland Road
New Paris, PA 15554

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("New Paris Center Elementary School",'New_Paris=' + New_Paris.length); Loysburg[Loysburg.length] = createMarker(new GPoint(-78.37680054,40.16220093),"
Northern Bedford Co Elementary School
217 Nbc Dr
Loysburg, PA 16659

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Northern Bedford Co Elementary School",'Loysburg=' + Loysburg.length); Loysburg[Loysburg.length] = createMarker(new GPoint(-78.37680054,40.16220093),"
Northern Bedford Co Ms/shs
152 Nbc Dr
Loysburg, PA 16659

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Northern Bedford Co Ms/shs",'Loysburg=' + Loysburg.length); Saxton[Saxton.length] = createMarker(new GPoint(-78.24991608,40.21395874),"
Saxton-liberty Gr School
1110 Mifflin St
Saxton, PA 16678

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Saxton-liberty Gr School",'Saxton=' + Saxton.length); Saxton[Saxton.length] = createMarker(new GPoint(-78.23609161,40.22169113),"
Tussey Mountain Junior Senior High School
199 Front Street
Saxton, PA 16678

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Tussey Mountain Junior Senior High School",'Saxton=' + Saxton.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(Bedford); map.removeOverlays(Breezewood); map.removeOverlays(Clearville); map.removeOverlays(Defiance); map.removeOverlays(Everett); map.removeOverlays(Fishertown); map.removeOverlays(Hyndman); map.removeOverlays(Loysburg); map.removeOverlays(Martinsburg); map.removeOverlays(New_Paris); map.removeOverlays(Saxton); 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(Everett);map.removeOverlays(Bedford); map.removeOverlays(Breezewood); map.removeOverlays(Clearville); map.removeOverlays(Defiance); map.removeOverlays(Everett); map.removeOverlays(Fishertown); map.removeOverlays(Hyndman); map.removeOverlays(Loysburg); map.removeOverlays(Martinsburg); map.removeOverlays(New_Paris); map.removeOverlays(Saxton); map.addOverlays(Bedford); centerByArray(Bedford, false, false); cntMarker += Bedford.length; map.addOverlays(Breezewood); centerByArray(Breezewood, false, false); cntMarker += Breezewood.length; map.addOverlays(Clearville); centerByArray(Clearville, false, false); cntMarker += Clearville.length; map.addOverlays(Defiance); centerByArray(Defiance, false, false); cntMarker += Defiance.length; map.addOverlays(Everett); centerByArray(Everett, false, false); cntMarker += Everett.length; map.addOverlays(Fishertown); centerByArray(Fishertown, false, false); cntMarker += Fishertown.length; map.addOverlays(Hyndman); centerByArray(Hyndman, false, false); cntMarker += Hyndman.length; map.addOverlays(Loysburg); centerByArray(Loysburg, false, false); cntMarker += Loysburg.length; map.addOverlays(Martinsburg); centerByArray(Martinsburg, false, false); cntMarker += Martinsburg.length; map.addOverlays(New_Paris); centerByArray(New_Paris, false, false); cntMarker += New_Paris.length; map.addOverlays(Saxton); centerByArray(Saxton, false, false); cntMarker += Saxton.length; centerByArray(Everett,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'); } }