function addMarkers() { mySelect = document.getElementById('selection'); Renovo = [];Mill_Hall = [];Lock_Haven = [];Loganton = [];mySelect.options[mySelect.options.length] = new Option("Lock Haven schools",'all=Lock_Haven'); mySelect.options[mySelect.options.length] = new Option("Loganton schools",'all=Loganton'); mySelect.options[mySelect.options.length] = new Option("Mill Hall schools",'all=Mill_Hall'); mySelect.options[mySelect.options.length] = new Option("Renovo schools",'all=Renovo'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Renovo[Renovo.length] = createMarker(new GPoint(-77.70838928,41.33723831),"
Bucktail Area Jr. Sr. High School
1300 Bucktail Ave
Renovo, PA 17764

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bucktail Area Jr. Sr. High School",'Renovo=' + Renovo.length); Renovo[Renovo.length] = createMarker(new GPoint(-77.70828000,41.33618600),"
Bucktail Area MiddleSchool
1300 Bucktail Avenue
Renovo, PA 17764

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Bucktail Area MiddleSchool",'Renovo=' + Renovo.length); Mill_Hall[Mill_Hall.length] = createMarker(new GPoint(-77.49690247,41.11009979),"
Central Mountain High School
64 Keystone Central Dr
Mill Hall, PA 17751

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Central Mountain High School",'Mill_Hall=' + Mill_Hall.length); Mill_Hall[Mill_Hall.length] = createMarker(new GPoint(-77.49461365,41.10923767),"
Central Mountain Middle School
200 Ben Avenue
Mill Hall, PA 17751

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Central Mountain Middle School",'Mill_Hall=' + Mill_Hall.length); Lock_Haven[Lock_Haven.length] = createMarker(new GPoint(-77.44721222,41.13623810),"
Central Mountain Middle School (east)
Lock Haven Campus 301 W Church
Lock Haven, PA 17745

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Central Mountain Middle School (east)",'Lock_Haven=' + Lock_Haven.length); Mill_Hall[Mill_Hall.length] = createMarker(new GPoint(-77.48461151,41.10728073),"
Central Mountain Middle School (west)
Ben Campus 200 Ben Avenue
Mill Hall, PA 17745

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Central Mountain Middle School (west)",'Mill_Hall=' + Mill_Hall.length); Lock_Haven[Lock_Haven.length] = createMarker(new GPoint(-77.45374298,41.13074112),"
Dickey Elementary School
South Fairview Street
Lock Haven, PA 17745

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Dickey Elementary School",'Lock_Haven=' + Lock_Haven.length); Mill_Hall[Mill_Hall.length] = createMarker(new GPoint(-77.49690247,41.11009979),"
Keystone Central Avts
64 Keystone Central Dr
Mill Hall, PA 17751

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Keystone Central Avts",'Mill_Hall=' + Mill_Hall.length); Mill_Hall[Mill_Hall.length] = createMarker(new GPoint(-77.42346954,41.09387970),"
Lamar Township Elementary School
34 East End Mountain Road
Mill Hall, PA 17751

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lamar Township Elementary School",'Mill_Hall=' + Mill_Hall.length); Lock_Haven[Lock_Haven.length] = createMarker(new GPoint(-77.45787048,41.13565826),"
Mcghee Elementary School
101 West 4th Street
Lock Haven, PA 17745

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mcghee Elementary School",'Lock_Haven=' + Lock_Haven.length); Mill_Hall[Mill_Hall.length] = createMarker(new GPoint(-77.49177551,41.10746384),"
Mill Hall Elementary School
210 Kyler Ave
Mill Hall, PA 17751

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mill Hall Elementary School",'Mill_Hall=' + Mill_Hall.length); Renovo[Renovo.length] = createMarker(new GPoint(-77.70812225,41.33705139),"
Renovo Elementary School
1301 Bucktail Ave
Renovo, PA 17764

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Renovo Elementary School",'Renovo=' + Renovo.length); Lock_Haven[Lock_Haven.length] = createMarker(new GPoint(-77.44116974,41.13574219),"
Robb Elementary School
400 East Church Street
Lock Haven, PA 17745

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Robb Elementary School",'Lock_Haven=' + Lock_Haven.length); Loganton[Loganton.length] = createMarker(new GPoint(-77.30229950,41.03480148),"
Sugar Valley Elementary School
98 East South Street
Loganton, PA 17747

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Sugar Valley Elementary School",'Loganton=' + Loganton.length); Loganton[Loganton.length] = createMarker(new GPoint(-77.28600311,41.04299927),"
Sugar Valley Rural Charter School
Po Box 104
Loganton, PA 17747

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Sugar Valley Rural Charter School",'Loganton=' + Loganton.length); Lock_Haven[Lock_Haven.length] = createMarker(new GPoint(-77.53646088,41.22829819),"
Woodward Elementary School
35 King Street
Lock Haven, PA 17745

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Woodward Elementary School",'Lock_Haven=' + Lock_Haven.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(Lock_Haven); map.removeOverlays(Loganton); map.removeOverlays(Mill_Hall); map.removeOverlays(Renovo); 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(Renovo);map.removeOverlays(Lock_Haven); map.removeOverlays(Loganton); map.removeOverlays(Mill_Hall); map.removeOverlays(Renovo); map.addOverlays(Lock_Haven); centerByArray(Lock_Haven, false, false); cntMarker += Lock_Haven.length; map.addOverlays(Loganton); centerByArray(Loganton, false, false); cntMarker += Loganton.length; map.addOverlays(Mill_Hall); centerByArray(Mill_Hall, false, false); cntMarker += Mill_Hall.length; map.addOverlays(Renovo); centerByArray(Renovo, false, false); cntMarker += Renovo.length; centerByArray(Renovo,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'); } }