function addMarkers() { mySelect = document.getElementById('selection'); Damascus = [];Hamlin = [];Hawley = [];Honesdale = [];Lake_Ariel = [];Lakewood = [];Newfoundland = [];Waymart = [];mySelect.options[mySelect.options.length] = new Option("Damascus schools",'all=Damascus'); mySelect.options[mySelect.options.length] = new Option("Hamlin schools",'all=Hamlin'); mySelect.options[mySelect.options.length] = new Option("Hawley schools",'all=Hawley'); mySelect.options[mySelect.options.length] = new Option("Honesdale schools",'all=Honesdale'); mySelect.options[mySelect.options.length] = new Option("Lake Ariel schools",'all=Lake_Ariel'); mySelect.options[mySelect.options.length] = new Option("Lakewood schools",'all=Lakewood'); mySelect.options[mySelect.options.length] = new Option("Newfoundland schools",'all=Newfoundland'); mySelect.options[mySelect.options.length] = new Option("Waymart schools",'all=Waymart'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Damascus[Damascus.length] = createMarker(new GPoint(-75.06864166,41.70330811),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Damascus Area School",'Damascus=' + Damascus.length); Hamlin[Hamlin.length] = createMarker(new GPoint(-75.33999634,41.39250183),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hamlin El Center",'Hamlin=' + Hamlin.length); Hawley[Hawley.length] = createMarker(new GPoint(-75.19011688,41.47922134),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hawley Kindergarten Center",'Hawley=' + Hawley.length); Honesdale[Honesdale.length] = createMarker(new GPoint(-75.26081848,41.56140518),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Honesdale High School",'Honesdale=' + Honesdale.length); Lake_Ariel[Lake_Ariel.length] = createMarker(new GPoint(-75.38368225,41.45418930),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lake Ariel Elementary School",'Lake_Ariel=' + Lake_Ariel.length); Honesdale[Honesdale.length] = createMarker(new GPoint(-75.26958466,41.55724335),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lakeside Elementary School",'Honesdale=' + Honesdale.length); Lakewood[Lakewood.length] = createMarker(new GPoint(-75.39739990,41.82419968),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Preston School",'Lakewood=' + Lakewood.length); Honesdale[Honesdale.length] = createMarker(new GPoint(-75.26530457,41.57435608),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Stourbridge Elementary School",'Honesdale=' + Honesdale.length); Hawley[Hawley.length] = createMarker(new GPoint(-75.05400085,41.33269882),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Wallenpaupack Area High School",'Hawley=' + Hawley.length); Hawley[Hawley.length] = createMarker(new GPoint(-75.05400085,41.33269882),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Wallenpaupack Area Middle School",'Hawley=' + Hawley.length); Hawley[Hawley.length] = createMarker(new GPoint(-75.05400085,41.33269882),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wallenpaupack North Elementary School",'Hawley=' + Hawley.length); Hawley[Hawley.length] = createMarker(new GPoint(-75.05400085,41.33269882),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wallenpaupack Pri School",'Hawley=' + Hawley.length); Newfoundland[Newfoundland.length] = createMarker(new GPoint(-75.35130310,41.27330017),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wallenpaupack South Elementary School",'Newfoundland=' + Newfoundland.length); Honesdale[Honesdale.length] = createMarker(new GPoint(-75.25594330,41.55862808),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Wayne Highlands Middle School",'Honesdale=' + Honesdale.length); Lake_Ariel[Lake_Ariel.length] = createMarker(new GPoint(-75.41840363,41.44309998),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Western Wayne High School",'Lake_Ariel=' + Lake_Ariel.length); Lake_Ariel[Lake_Ariel.length] = createMarker(new GPoint(-75.41840363,41.44309998),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Western Wayne Middle School",'Lake_Ariel=' + Lake_Ariel.length); Waymart[Waymart.length] = createMarker(new GPoint(-75.40881348,41.57524872),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wilson Elementary School",'Waymart=' + Waymart.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(Damascus); map.removeOverlays(Hamlin); map.removeOverlays(Hawley); map.removeOverlays(Honesdale); map.removeOverlays(Lake_Ariel); map.removeOverlays(Lakewood); map.removeOverlays(Newfoundland); map.removeOverlays(Waymart); 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(Damascus);map.removeOverlays(Damascus); map.removeOverlays(Hamlin); map.removeOverlays(Hawley); map.removeOverlays(Honesdale); map.removeOverlays(Lake_Ariel); map.removeOverlays(Lakewood); map.removeOverlays(Newfoundland); map.removeOverlays(Waymart); map.addOverlays(Damascus); centerByArray(Damascus, false, false); cntMarker += Damascus.length; map.addOverlays(Hamlin); centerByArray(Hamlin, false, false); cntMarker += Hamlin.length; map.addOverlays(Hawley); centerByArray(Hawley, false, false); cntMarker += Hawley.length; map.addOverlays(Honesdale); centerByArray(Honesdale, false, false); cntMarker += Honesdale.length; map.addOverlays(Lake_Ariel); centerByArray(Lake_Ariel, false, false); cntMarker += Lake_Ariel.length; map.addOverlays(Lakewood); centerByArray(Lakewood, false, false); cntMarker += Lakewood.length; map.addOverlays(Newfoundland); centerByArray(Newfoundland, false, false); cntMarker += Newfoundland.length; map.addOverlays(Waymart); centerByArray(Waymart, false, false); cntMarker += Waymart.length; centerByArray(Damascus,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'); } }