function addMarkers() { mySelect = document.getElementById('selection'); Bradford = [];Kane = [];Mt_Jewett = [];Eldred = [];Duke_Center = [];Port_Allegany = [];Smethport = [];mySelect.options[mySelect.options.length] = new Option("Bradford schools",'all=Bradford'); mySelect.options[mySelect.options.length] = new Option("Duke Center schools",'all=Duke_Center'); mySelect.options[mySelect.options.length] = new Option("Eldred schools",'all=Eldred'); mySelect.options[mySelect.options.length] = new Option("Kane schools",'all=Kane'); mySelect.options[mySelect.options.length] = new Option("Mt Jewett schools",'all=Mt_Jewett'); mySelect.options[mySelect.options.length] = new Option("Port Allegany schools",'all=Port_Allegany'); mySelect.options[mySelect.options.length] = new Option("Smethport schools",'all=Smethport'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Bradford[Bradford.length] = createMarker(new GPoint(-78.65865326,41.95874405),"
Bradford Area High School
81 Interstate Pkwy
Bradford, PA 16701

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bradford Area High School",'Bradford=' + Bradford.length); Kane[Kane.length] = createMarker(new GPoint(-78.81258392,41.65787888),"
Chestnut Street Elementary School
226 Chestnut St
Kane, PA 16735

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Chestnut Street Elementary School",'Kane=' + Kane.length); Bradford[Bradford.length] = createMarker(new GPoint(-78.61957550,41.96725845),"
Floyd C Fretz Middle School
140 Lorana Ave
Bradford, PA 16701

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Floyd C Fretz Middle School",'Bradford=' + Bradford.length); Bradford[Bradford.length] = createMarker(new GPoint(-78.63092804,41.97365952),"
George Blaisdell Elementary School
265 Constitution Ave
Bradford, PA 16701

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("George Blaisdell Elementary School",'Bradford=' + Bradford.length); Kane[Kane.length] = createMarker(new GPoint(-78.80301666,41.65566254),"
Kane Area High School
300 Hemlock Ave
Kane, PA 16735

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Kane Area High School",'Kane=' + Kane.length); Kane[Kane.length] = createMarker(new GPoint(-78.81338501,41.65566254),"
Kane Area Middle School
400 W Hemlock Ave
Kane, PA 16735

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Kane Area Middle School",'Kane=' + Kane.length); Mt_Jewett[Mt_Jewett.length] = createMarker(new GPoint(-78.63999939,41.72489929),"
Mt Jewett Elementary School
Po Box 7267
Mt Jewett, PA 16740

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mt Jewett Elementary School",'Mt_Jewett=' + Mt_Jewett.length); Eldred[Eldred.length] = createMarker(new GPoint(-78.38294983,41.95536804),"
Otto-eldred Elementary School
Po Box 309
Eldred, PA 16731

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Otto-eldred Elementary School",'Eldred=' + Eldred.length); Duke_Center[Duke_Center.length] = createMarker(new GPoint(-78.44069672,41.93349838),"
Otto-eldred Junior Senior High School
143 Sweitzer Dr
Duke Center, PA 16729

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Otto-eldred Junior Senior High School",'Duke_Center=' + Duke_Center.length); Port_Allegany[Port_Allegany.length] = createMarker(new GPoint(-78.26689148,41.81473541),"
Port Allegany Elementary School
85 Clyde Lynch Dr
Port Allegany, PA 16743

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Port Allegany Elementary School",'Port_Allegany=' + Port_Allegany.length); Port_Allegany[Port_Allegany.length] = createMarker(new GPoint(-78.27238464,41.81659317),"
Port Allegany Junior Senior High School
20 Oak St
Port Allegany, PA 16743

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Port Allegany Junior Senior High School",'Port_Allegany=' + Port_Allegany.length); Bradford[Bradford.length] = createMarker(new GPoint(-78.65496063,41.95973587),"
School Street Elementary School
76 School St
Bradford, PA 16701

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("School Street Elementary School",'Bradford=' + Bradford.length); Port_Allegany[Port_Allegany.length] = createMarker(new GPoint(-78.26736450,41.81896591),"
Seneca Highlands Avts
219 Edison Bates Dr
Port Allegany, PA 16743

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Seneca Highlands Avts",'Port_Allegany=' + Port_Allegany.length); Smethport[Smethport.length] = createMarker(new GPoint(-78.44175720,41.80479050),"
Smethport Area Elementary School
414 S Mechanic St
Smethport, PA 16749

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Smethport Area Elementary School",'Smethport=' + Smethport.length); Smethport[Smethport.length] = createMarker(new GPoint(-78.44175720,41.80479813),"
Smethport Area Junior Senior High School
412 S Mechanic St
Smethport, PA 16749

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Smethport Area Junior Senior High School",'Smethport=' + Smethport.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(Bradford); map.removeOverlays(Duke_Center); map.removeOverlays(Eldred); map.removeOverlays(Kane); map.removeOverlays(Mt_Jewett); map.removeOverlays(Port_Allegany); map.removeOverlays(Smethport); 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(Bradford);map.removeOverlays(Bradford); map.removeOverlays(Duke_Center); map.removeOverlays(Eldred); map.removeOverlays(Kane); map.removeOverlays(Mt_Jewett); map.removeOverlays(Port_Allegany); map.removeOverlays(Smethport); map.addOverlays(Bradford); centerByArray(Bradford, false, false); cntMarker += Bradford.length; map.addOverlays(Duke_Center); centerByArray(Duke_Center, false, false); cntMarker += Duke_Center.length; map.addOverlays(Eldred); centerByArray(Eldred, false, false); cntMarker += Eldred.length; map.addOverlays(Kane); centerByArray(Kane, false, false); cntMarker += Kane.length; map.addOverlays(Mt_Jewett); centerByArray(Mt_Jewett, false, false); cntMarker += Mt_Jewett.length; map.addOverlays(Port_Allegany); centerByArray(Port_Allegany, false, false); cntMarker += Port_Allegany.length; map.addOverlays(Smethport); centerByArray(Smethport, false, false); cntMarker += Smethport.length; centerByArray(Bradford,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'); } }