function addMarkers(){ mySelect = document.getElementById('selection'); Towanda = [];Canton = [];Sayre = [];Athens = [];Ulster = [];Lerayville = [];Stevensville = [];Leraysville = [];mySelect.options[mySelect.options.length] = new Option("Athens schools",'all=Athens'); mySelect.options[mySelect.options.length] = new Option("Canton schools",'all=Canton'); mySelect.options[mySelect.options.length] = new Option("Leraysville schools",'all=Leraysville'); mySelect.options[mySelect.options.length] = new Option("Lerayville schools",'all=Lerayville'); mySelect.options[mySelect.options.length] = new Option("Sayre schools",'all=Sayre'); mySelect.options[mySelect.options.length] = new Option("Stevensville schools",'all=Stevensville'); mySelect.options[mySelect.options.length] = new Option("Towanda schools",'all=Towanda'); mySelect.options[mySelect.options.length] = new Option("Ulster schools",'all=Ulster'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Towanda[Towanda.length] = createMarker(new GPoint(-76.47700000,41.75330000),"
Barclay Friends School
Rr 1 Box 167b
Towanda, PA 18848
Co-ed school, PK-1
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Barclay Friends School",'Towanda=' + Towanda.length); Canton[Canton.length] = createMarker(new GPoint(-76.84715400,41.65400500),"
Canton Country School
Rr 1 Box 5240
Canton, PA 17724
Co-ed school, 1-9
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Canton Country School",'Canton=' + Canton.length); Sayre[Sayre.length] = createMarker(new GPoint(-76.53063200,41.98548500),"
Epiphany School
627 Stevenson Street
Sayre, PA 18840
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Epiphany School",'Sayre=' + Sayre.length); Athens[Athens.length] = createMarker(new GPoint(-76.52409800,41.96336100),"
His Majesty Christian Academy
207 Pennsylvania Avenue
Athens, PA 18810
Co-ed school, K-10
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("His Majesty Christian Academy",'Athens=' + Athens.length); Ulster[Ulster.length] = createMarker(new GPoint(-76.47050000,41.83590000),"
North Rome Christian School
Rr 1 Box 190a
Ulster, PA 18850
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("North Rome Christian School",'Ulster=' + Ulster.length); Canton[Canton.length] = createMarker(new GPoint(-76.85212500,41.65186300),"
Son-shine Christian School
63-65 Sullivan Street
Canton, PA 17724
Co-ed school, PK-4
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Son-shine Christian School",'Canton=' + Canton.length); Towanda[Towanda.length] = createMarker(new GPoint(-76.44588300,41.76915300),"
St Agnes School
102 3rd Street
Towanda, PA 18848
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Agnes School",'Towanda=' + Towanda.length); Ulster[Ulster.length] = createMarker(new GPoint(-76.48090000,41.84620000),"
Union Valley Christian School
Rr 1 Box 556
Ulster, PA 18850
Co-ed school, 1-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Union Valley Christian School",'Ulster=' + Ulster.length); Lerayville[Lerayville.length] = createMarker(new GPoint(-76.17430000,41.84310000),"
Valley View Amish School
Amish Rd Rd 2 Box 61
Lerayville, PA 18829
Co-ed school, 1-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Valley View Amish School",'Lerayville=' + Lerayville.length); Stevensville[Stevensville.length] = createMarker(new GPoint(-76.17440000,41.77190000),"
Valley View Amish School
Rr 1 Box 49
Stevensville, PA 18845
Co-ed school, 1-9
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Valley View Amish School",'Stevensville=' + Stevensville.length); Leraysville[Leraysville.length] = createMarker(new GPoint(-79.57272100,42.07521700),"
Valley View Amish School
Amish Rd Rd 2 Box 61
Leraysville, PA 18829
Co-ed school, 1-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Valley View Amish School",'Leraysville=' + Leraysville.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,11); /* 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/////1/' + showArray); map.removeOverlays(Athens); map.removeOverlays(Canton); map.removeOverlays(Leraysville); map.removeOverlays(Lerayville); map.removeOverlays(Sayre); map.removeOverlays(Stevensville); map.removeOverlays(Towanda); map.removeOverlays(Ulster); 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(Towanda);map.removeOverlays(Athens); map.removeOverlays(Canton); map.removeOverlays(Leraysville); map.removeOverlays(Lerayville); map.removeOverlays(Sayre); map.removeOverlays(Stevensville); map.removeOverlays(Towanda); map.removeOverlays(Ulster); map.addOverlays(Athens); centerByArray(Athens, false, false); cntMarker += Athens.length; map.addOverlays(Canton); centerByArray(Canton, false, false); cntMarker += Canton.length; map.addOverlays(Leraysville); centerByArray(Leraysville, false, false); cntMarker += Leraysville.length; map.addOverlays(Lerayville); centerByArray(Lerayville, false, false); cntMarker += Lerayville.length; map.addOverlays(Sayre); centerByArray(Sayre, false, false); cntMarker += Sayre.length; map.addOverlays(Stevensville); centerByArray(Stevensville, false, false); cntMarker += Stevensville.length; map.addOverlays(Towanda); centerByArray(Towanda, false, false); cntMarker += Towanda.length; map.addOverlays(Ulster); centerByArray(Ulster, false, false); cntMarker += Ulster.length; centerByArray(Towanda,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'); //window.open('/map.php?type=1&schools=&school_level=1&radius=&zipcode=&school_type_search=&school_type_code='); } } function createMarker(point, label, icon) { var marker = new GMarker(point, icon); var html = label; GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); return marker; }