function addMarkers(){ mySelect = document.getElementById('selection'); Tionesta = [];Clarion = [];Turkey_City = [];Mayport = [];Knox = [];New_Bethlehem = [];Fryburg = [];Sligo = [];Lucinda = [];mySelect.options[mySelect.options.length] = new Option("Clarion schools",'all=Clarion'); mySelect.options[mySelect.options.length] = new Option("Fryburg schools",'all=Fryburg'); mySelect.options[mySelect.options.length] = new Option("Knox schools",'all=Knox'); mySelect.options[mySelect.options.length] = new Option("Lucinda schools",'all=Lucinda'); mySelect.options[mySelect.options.length] = new Option("Mayport schools",'all=Mayport'); mySelect.options[mySelect.options.length] = new Option("New Bethlehem schools",'all=New_Bethlehem'); mySelect.options[mySelect.options.length] = new Option("Sligo schools",'all=Sligo'); mySelect.options[mySelect.options.length] = new Option("Tionesta schools",'all=Tionesta'); mySelect.options[mySelect.options.length] = new Option("Turkey City schools",'all=Turkey_City'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Tionesta[Tionesta.length] = createMarker(new GPoint(-79.38781600,41.40627800),"
Alexander Amish School
193 Farm Lane
Tionesta, PA 16353
Co-ed school, 1-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Alexander Amish School",'Tionesta=' + Tionesta.length); Clarion[Clarion.length] = createMarker(new GPoint(-79.39680600,41.19023300),"
Clarion Center School
2 Hospital Drive
Clarion, PA 16214
Co-ed school, 1-11
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Clarion Center School",'Clarion=' + Clarion.length); Turkey_City[Turkey_City.length] = createMarker(new GPoint(-79.61360000,41.18520000),"
Cornerstone Christian Academy
Po Box 24
Turkey City, PA 16058
Co-ed school, 2-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cornerstone Christian Academy",'Turkey_City=' + Turkey_City.length); Mayport[Mayport.length] = createMarker(new GPoint(-79.23890900,41.01585000),"
Deerview School
922 W Market Street
Mayport, PA 16240
Co-ed school, 1-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Deerview School",'Mayport=' + Mayport.length); Clarion[Clarion.length] = createMarker(new GPoint(-79.38102400,41.21305300),"
Immaculate Conception School
729 Main Street
Clarion, PA 16214
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Immaculate Conception School",'Clarion=' + Clarion.length); Knox[Knox.length] = createMarker(new GPoint(-79.55152700,41.22524100),"
Meadow View Amish School
505 Crops Rd
Knox, PA 16232
Co-ed school, 1-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Meadow View Amish School",'Knox=' + Knox.length); New_Bethlehem[New_Bethlehem.length] = createMarker(new GPoint(-79.37781400,41.06273400),"
New Bethlehem Mennonite
805 Frosty Road
New Bethlehem, PA 16242
Co-ed school, 1-9
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("New Bethlehem Mennonite",'New_Bethlehem=' + New_Bethlehem.length); New_Bethlehem[New_Bethlehem.length] = createMarker(new GPoint(-79.35110000,41.01050000),"
New Bethlehem Wesleyan Methodist School
140 Calhoun School Road
New Bethlehem, PA 16242
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("New Bethlehem Wesleyan Methodist School",'New_Bethlehem=' + New_Bethlehem.length); Fryburg[Fryburg.length] = createMarker(new GPoint(-79.40630000,41.38150000),"
St. Michael Elementary School
Po Box 129 18766 Route 208
Fryburg, PA 16326
Co-ed school, PK-7
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Michael Elementary School",'Fryburg=' + Fryburg.length); Sligo[Sligo.length] = createMarker(new GPoint(-79.54346000,41.13946100),"
Shady Nook Amish School
729 Shady Lane
Sligo, PA 16255
Co-ed school, 1-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Shady Nook Amish School",'Sligo=' + Sligo.length); Lucinda[Lucinda.length] = createMarker(new GPoint(-79.35090000,41.32000000),"
St Joseph School
Po Box 9 72 Rectory Lane
Lucinda, PA 16235
Co-ed school, PK-6
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Joseph School",'Lucinda=' + Lucinda.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/////3/' + showArray); map.removeOverlays(Clarion); map.removeOverlays(Fryburg); map.removeOverlays(Knox); map.removeOverlays(Lucinda); map.removeOverlays(Mayport); map.removeOverlays(New_Bethlehem); map.removeOverlays(Sligo); map.removeOverlays(Tionesta); map.removeOverlays(Turkey_City); 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(Tionesta);map.removeOverlays(Clarion); map.removeOverlays(Fryburg); map.removeOverlays(Knox); map.removeOverlays(Lucinda); map.removeOverlays(Mayport); map.removeOverlays(New_Bethlehem); map.removeOverlays(Sligo); map.removeOverlays(Tionesta); map.removeOverlays(Turkey_City); map.addOverlays(Clarion); centerByArray(Clarion, false, false); cntMarker += Clarion.length; map.addOverlays(Fryburg); centerByArray(Fryburg, false, false); cntMarker += Fryburg.length; map.addOverlays(Knox); centerByArray(Knox, false, false); cntMarker += Knox.length; map.addOverlays(Lucinda); centerByArray(Lucinda, false, false); cntMarker += Lucinda.length; map.addOverlays(Mayport); centerByArray(Mayport, false, false); cntMarker += Mayport.length; map.addOverlays(New_Bethlehem); centerByArray(New_Bethlehem, false, false); cntMarker += New_Bethlehem.length; map.addOverlays(Sligo); centerByArray(Sligo, false, false); cntMarker += Sligo.length; map.addOverlays(Tionesta); centerByArray(Tionesta, false, false); cntMarker += Tionesta.length; map.addOverlays(Turkey_City); centerByArray(Turkey_City, false, false); cntMarker += Turkey_City.length; centerByArray(Tionesta,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=3&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; }