function addMarkers() { mySelect = document.getElementById('selection'); Glen_Campbell = [];Indiana = [];Blairsville = [];Saltsburg = [];Homer_City = [];Home = [];Marion_Center = [];Clymer = [];Commodore = [];Armagh = [];mySelect.options[mySelect.options.length] = new Option("Armagh schools",'all=Armagh'); mySelect.options[mySelect.options.length] = new Option("Blairsville schools",'all=Blairsville'); mySelect.options[mySelect.options.length] = new Option("Clymer schools",'all=Clymer'); mySelect.options[mySelect.options.length] = new Option("Commodore schools",'all=Commodore'); mySelect.options[mySelect.options.length] = new Option("Glen Campbell schools",'all=Glen_Campbell'); mySelect.options[mySelect.options.length] = new Option("Home schools",'all=Home'); mySelect.options[mySelect.options.length] = new Option("Homer City schools",'all=Homer_City'); mySelect.options[mySelect.options.length] = new Option("Indiana schools",'all=Indiana'); mySelect.options[mySelect.options.length] = new Option("Marion Center schools",'all=Marion_Center'); mySelect.options[mySelect.options.length] = new Option("Saltsburg schools",'all=Saltsburg'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Glen_Campbell[Glen_Campbell.length] = createMarker(new GPoint(-78.87287903,40.83829880),"
Banks-canoe Elementary School
3676 Glen Campbell Rd
Glen Campbell, PA 15742

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Banks-canoe Elementary School",'Glen_Campbell=' + Glen_Campbell.length); Indiana[Indiana.length] = createMarker(new GPoint(-79.19367218,40.61965561),"
Ben Franklin Elementary School
95 Ben Franklin Rd
Indiana, PA 15701

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Ben Franklin Elementary School",'Indiana=' + Indiana.length); Blairsville[Blairsville.length] = createMarker(new GPoint(-79.21892548,40.44855118),"
Blairsville Elementary School
106 School Lane
Blairsville, PA 15717

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Blairsville Elementary School",'Blairsville=' + Blairsville.length); Blairsville[Blairsville.length] = createMarker(new GPoint(-79.21891022,40.44853973),"
Blairsville Middle School
104 School Lane
Blairsville, PA 15717

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Blairsville Middle School",'Blairsville=' + Blairsville.length); Blairsville[Blairsville.length] = createMarker(new GPoint(-79.21887970,40.44851303),"
Blairsville Senior High School
100 School Lane
Blairsville, PA 15717

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Blairsville Senior High School",'Blairsville=' + Blairsville.length); Indiana[Indiana.length] = createMarker(new GPoint(-79.12238312,40.61863327),"
East Pike Elementary School
501 E Pike
Indiana, PA 15701

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("East Pike Elementary School",'Indiana=' + Indiana.length); Indiana[Indiana.length] = createMarker(new GPoint(-79.16992187,40.62046432),"
Eisenhower Elementary School
1460 School St
Indiana, PA 15701

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Eisenhower Elementary School",'Indiana=' + Indiana.length); Saltsburg[Saltsburg.length] = createMarker(new GPoint(-79.43430328,40.48839951),"
Elders Ridge Elementary School
Rr 1 Box 128
Saltsburg, PA 15681

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Elders Ridge Elementary School",'Saltsburg=' + Saltsburg.length); Homer_City[Homer_City.length] = createMarker(new GPoint(-79.15989685,40.53276825),"
Homer-center Elementary School
45 Wildcat Ln
Homer City, PA 15748

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Homer-center Elementary School",'Homer_City=' + Homer_City.length); Homer_City[Homer_City.length] = createMarker(new GPoint(-79.15987396,40.53240204),"
Homer-center Junior Senior High School
70 Wildcat Ln
Homer City, PA 15748

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Homer-center Junior Senior High School",'Homer_City=' + Homer_City.length); Indiana[Indiana.length] = createMarker(new GPoint(-79.14811707,40.62042999),"
Horace Mann Elementary School
205 S 5th St
Indiana, PA 15701

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Horace Mann Elementary School",'Indiana=' + Indiana.length); Indiana[Indiana.length] = createMarker(new GPoint(-79.14801788,40.62662888),"
Indiana Area Junior High School
245 N 5th St
Indiana, PA 15701

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Indiana Area Junior High School",'Indiana=' + Indiana.length); Indiana[Indiana.length] = createMarker(new GPoint(-79.14731598,40.63094330),"
Indiana Area Senior High School
450 N 5th St
Indiana, PA 15701

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Indiana Area Senior High School",'Indiana=' + Indiana.length); Indiana[Indiana.length] = createMarker(new GPoint(-79.12191772,40.64201355),"
Indiana County Technology Cent
441 Hamill Rd
Indiana, PA 15701

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Indiana County Technology Cent",'Indiana=' + Indiana.length); Home[Home.length] = createMarker(new GPoint(-79.10037994,40.70279694),"
Marion Center Area Elementary School
2535 Route 119 Hwy N
Home, PA 15747

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Marion Center Area Elementary School",'Home=' + Home.length); Marion_Center[Marion_Center.length] = createMarker(new GPoint(-79.03050232,40.77159882),"
Marion Center Area High School
Po Box 209
Marion Center, PA 15759

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Marion Center Area High School",'Marion_Center=' + Marion_Center.length); Marion_Center[Marion_Center.length] = createMarker(new GPoint(-79.03050232,40.77159882),"
Marion Center Area Middle School
Po Box 199
Marion Center, PA 15759

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Marion Center Area Middle School",'Marion_Center=' + Marion_Center.length); Clymer[Clymer.length] = createMarker(new GPoint(-78.94219208,40.63863754),"
Penns Manor Area Elementary School
6003 Route 553 Hwy
Clymer, PA 15728

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Penns Manor Area Elementary School",'Clymer=' + Clymer.length); Clymer[Clymer.length] = createMarker(new GPoint(-78.94219208,40.63863754),"
Penns Manor Area Junior Senior High School
6003 Route 553 Highway
Clymer, PA 15728

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Penns Manor Area Junior Senior High School",'Clymer=' + Clymer.length); Commodore[Commodore.length] = createMarker(new GPoint(-78.94257355,40.71305847),"
Purchase Line Junior Senior High School
Po Box 374
Commodore, PA 15729

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Purchase Line Junior Senior High School",'Commodore=' + Commodore.length); Commodore[Commodore.length] = createMarker(new GPoint(-78.94257355,40.71305847),"
Purchase Line South Elementary School
Po Box 374
Commodore, PA 15729

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Purchase Line South Elementary School",'Commodore=' + Commodore.length); Saltsburg[Saltsburg.length] = createMarker(new GPoint(-79.44647980,40.49942780),"
Saltsburg Elementary School
250 3rd St
Saltsburg, PA 15681

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Saltsburg Elementary School",'Saltsburg=' + Saltsburg.length); Saltsburg[Saltsburg.length] = createMarker(new GPoint(-79.44908142,40.49064255),"
Saltsburg Middle School High School
84 Trojan Lane
Saltsburg, PA 15681

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Saltsburg Middle School High School",'Saltsburg=' + Saltsburg.length); Armagh[Armagh.length] = createMarker(new GPoint(-79.03040314,40.45230103),"
United Elementary School
10775 Route 56 East
Armagh, PA 15920

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("United Elementary School",'Armagh=' + Armagh.length); Armagh[Armagh.length] = createMarker(new GPoint(-79.03040314,40.45230103),"
United Junior Senior High School
Po Box 168
Armagh, PA 15920

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("United Junior Senior High School",'Armagh=' + Armagh.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(Armagh); map.removeOverlays(Blairsville); map.removeOverlays(Clymer); map.removeOverlays(Commodore); map.removeOverlays(Glen_Campbell); map.removeOverlays(Home); map.removeOverlays(Homer_City); map.removeOverlays(Indiana); map.removeOverlays(Marion_Center); map.removeOverlays(Saltsburg); 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(Glen_Campbell);map.removeOverlays(Armagh); map.removeOverlays(Blairsville); map.removeOverlays(Clymer); map.removeOverlays(Commodore); map.removeOverlays(Glen_Campbell); map.removeOverlays(Home); map.removeOverlays(Homer_City); map.removeOverlays(Indiana); map.removeOverlays(Marion_Center); map.removeOverlays(Saltsburg); map.addOverlays(Armagh); centerByArray(Armagh, false, false); cntMarker += Armagh.length; map.addOverlays(Blairsville); centerByArray(Blairsville, false, false); cntMarker += Blairsville.length; map.addOverlays(Clymer); centerByArray(Clymer, false, false); cntMarker += Clymer.length; map.addOverlays(Commodore); centerByArray(Commodore, false, false); cntMarker += Commodore.length; map.addOverlays(Glen_Campbell); centerByArray(Glen_Campbell, false, false); cntMarker += Glen_Campbell.length; map.addOverlays(Home); centerByArray(Home, false, false); cntMarker += Home.length; map.addOverlays(Homer_City); centerByArray(Homer_City, false, false); cntMarker += Homer_City.length; map.addOverlays(Indiana); centerByArray(Indiana, false, false); cntMarker += Indiana.length; map.addOverlays(Marion_Center); centerByArray(Marion_Center, false, false); cntMarker += Marion_Center.length; map.addOverlays(Saltsburg); centerByArray(Saltsburg, false, false); cntMarker += Saltsburg.length; centerByArray(Glen_Campbell,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'); } }