function addMarkers() { mySelect = document.getElementById('selection'); Milroy = [];Reedsville = [];Lewistown = [];Yeagertown = [];Mount_Union = [];Mc_Veytown = [];Mcveytown = [];Belleville = [];mySelect.options[mySelect.options.length] = new Option("Belleville schools",'all=Belleville'); mySelect.options[mySelect.options.length] = new Option("Lewistown schools",'all=Lewistown'); mySelect.options[mySelect.options.length] = new Option("Mc Veytown schools",'all=Mc_Veytown'); mySelect.options[mySelect.options.length] = new Option("Mcveytown schools",'all=Mcveytown'); mySelect.options[mySelect.options.length] = new Option("Milroy schools",'all=Milroy'); mySelect.options[mySelect.options.length] = new Option("Mount Union schools",'all=Mount_Union'); mySelect.options[mySelect.options.length] = new Option("Reedsville schools",'all=Reedsville'); mySelect.options[mySelect.options.length] = new Option("Yeagertown schools",'all=Yeagertown'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Milroy[Milroy.length] = createMarker(new GPoint(-77.53420258,40.73199844),"
Armagh Township Elementary School
283 Broad St
Milroy, PA 17063

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Armagh Township Elementary School",'Milroy=' + Milroy.length); Reedsville[Reedsville.length] = createMarker(new GPoint(-77.59358215,40.68707275),"
Brown Township Elementary School
96 Kish Rd
Reedsville, PA 17084

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Brown Township Elementary School",'Reedsville=' + Reedsville.length); Lewistown[Lewistown.length] = createMarker(new GPoint(-77.58660800,40.59618500),"
Buchanan Elementary School
100 Franklin Avenue
Lewistown, PA 17044

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Buchanan Elementary School",'Lewistown=' + Lewistown.length); Yeagertown[Yeagertown.length] = createMarker(new GPoint(-77.58161926,40.63695145),"
Derry Elementary School
200 Greenwood Avenue
Yeagertown, PA 17099

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Derry Elementary School",'Yeagertown=' + Yeagertown.length); Lewistown[Lewistown.length] = createMarker(new GPoint(-77.49867249,40.63147354),"
East Derry Elementary School
2316 Back Maitland Rd
Lewistown, PA 17044

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("East Derry Elementary School",'Lewistown=' + Lewistown.length); Lewistown[Lewistown.length] = createMarker(new GPoint(-77.57002258,40.62364960),"
Highland Park Area Elementary School
490 6th St
Lewistown, PA 17044

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Highland Park Area Elementary School",'Lewistown=' + Lewistown.length); Reedsville[Reedsville.length] = createMarker(new GPoint(-77.59400940,40.68765259),"
Indian Valley Middle School
125 Kish Rd
Reedsville, PA 17084

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Indian Valley Middle School",'Reedsville=' + Reedsville.length); Lewistown[Lewistown.length] = createMarker(new GPoint(-77.56659698,40.62297821),"
Indian Valley Senior High School
700 Cedar St
Lewistown, PA 17044

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Indian Valley Senior High School",'Lewistown=' + Lewistown.length); Lewistown[Lewistown.length] = createMarker(new GPoint(-77.56404114,40.59387970),"
Lewistown Area Senior High School
2 Manor Drive
Lewistown, PA 17044

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Lewistown Area Senior High School",'Lewistown=' + Lewistown.length); Lewistown[Lewistown.length] = createMarker(new GPoint(-77.58800900,40.71983700),"
Lewistown Elementary School
1 Manor Drive
Lewistown, PA 17044

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lewistown Elementary School",'Lewistown=' + Lewistown.length); Lewistown[Lewistown.length] = createMarker(new GPoint(-77.56690979,40.59477997),"
Lewistown Middle School
212 Green Ave
Lewistown, PA 17044

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Lewistown Middle School",'Lewistown=' + Lewistown.length); Lewistown[Lewistown.length] = createMarker(new GPoint(-77.55369568,40.60570526),"
Mifflin-juniata Ctc
700 Pitt St
Lewistown, PA 17044

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Mifflin-juniata Ctc",'Lewistown=' + Lewistown.length); Mount_Union[Mount_Union.length] = createMarker(new GPoint(-77.86455536,40.37960052),"
Mount Union-kistler Elementary School
154 School Street
Mount Union, PA 17066

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mount Union-kistler Elementary School",'Mount_Union=' + Mount_Union.length); Lewistown[Lewistown.length] = createMarker(new GPoint(-77.56478119,40.59095764),"
Seventh Ward Elementary School
25 East Susquehanna Avenue
Lewistown, PA 17044

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Seventh Ward Elementary School",'Lewistown=' + Lewistown.length); Mc_Veytown[Mc_Veytown.length] = createMarker(new GPoint(-77.67007446,40.54594040),"
Strodes Mills Elementary School
185 Chestnut Ridge Rd
Mc Veytown, PA 17051

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Strodes Mills Elementary School",'Mc_Veytown=' + Mc_Veytown.length); Mc_Veytown[Mc_Veytown.length] = createMarker(new GPoint(-77.66959381,40.54593658),"
Strodes Mills Middle School
205 Chestnut Ridge Rd
Mc Veytown, PA 17051

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Strodes Mills Middle School",'Mc_Veytown=' + Mc_Veytown.length); Mcveytown[Mcveytown.length] = createMarker(new GPoint(-77.84829712,40.39242172),"
Tuscarora Blended Learning Charter School
2527 Us Highway 522 South
Mcveytown, PA 17051

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Tuscarora Blended Learning Charter School",'Mcveytown=' + Mcveytown.length); Belleville[Belleville.length] = createMarker(new GPoint(-77.72461700,40.60859299),"
Union Township Elementary School
95 North Penn St Po Box 978
Belleville, PA 17004

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Union Township Elementary School",'Belleville=' + Belleville.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(Belleville); map.removeOverlays(Lewistown); map.removeOverlays(Mc_Veytown); map.removeOverlays(Mcveytown); map.removeOverlays(Milroy); map.removeOverlays(Mount_Union); map.removeOverlays(Reedsville); map.removeOverlays(Yeagertown); 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(Milroy);map.removeOverlays(Belleville); map.removeOverlays(Lewistown); map.removeOverlays(Mc_Veytown); map.removeOverlays(Mcveytown); map.removeOverlays(Milroy); map.removeOverlays(Mount_Union); map.removeOverlays(Reedsville); map.removeOverlays(Yeagertown); map.addOverlays(Belleville); centerByArray(Belleville, false, false); cntMarker += Belleville.length; map.addOverlays(Lewistown); centerByArray(Lewistown, false, false); cntMarker += Lewistown.length; map.addOverlays(Mc_Veytown); centerByArray(Mc_Veytown, false, false); cntMarker += Mc_Veytown.length; map.addOverlays(Mcveytown); centerByArray(Mcveytown, false, false); cntMarker += Mcveytown.length; map.addOverlays(Milroy); centerByArray(Milroy, false, false); cntMarker += Milroy.length; map.addOverlays(Mount_Union); centerByArray(Mount_Union, false, false); cntMarker += Mount_Union.length; map.addOverlays(Reedsville); centerByArray(Reedsville, false, false); cntMarker += Reedsville.length; map.addOverlays(Yeagertown); centerByArray(Yeagertown, false, false); cntMarker += Yeagertown.length; centerByArray(Milroy,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'); } }