function addMarkers() { mySelect = document.getElementById('selection'); Peach_Creek = [];Martinsburg = [];Clarksburg = [];Parkersburg = [];Dunbar = [];Romney = [];mySelect.options[mySelect.options.length] = new Option("Clarksburg special education schools",'all=Clarksburg'); mySelect.options[mySelect.options.length] = new Option("Dunbar special education schools",'all=Dunbar'); mySelect.options[mySelect.options.length] = new Option("Martinsburg special education schools",'all=Martinsburg'); mySelect.options[mySelect.options.length] = new Option("Parkersburg special education schools",'all=Parkersburg'); mySelect.options[mySelect.options.length] = new Option("Peach Creek special education schools",'all=Peach_Creek'); mySelect.options[mySelect.options.length] = new Option("Romney special education schools",'all=Romney'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Peach_Creek[Peach_Creek.length] = createMarker(new GPoint(-81.98500061,37.87440109),"
Crooked Creek School
Po Box 9
Peach Creek, WV 25639

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Crooked Creek School",'Peach_Creek=' + Peach_Creek.length); Martinsburg[Martinsburg.length] = createMarker(new GPoint(-77.99289703,39.48320007),"
Eastern Panhandle Training Center
Rr 6 Box 271
Martinsburg, WV 25401

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Eastern Panhandle Training Center",'Martinsburg=' + Martinsburg.length); Clarksburg[Clarksburg.length] = createMarker(new GPoint(-80.34546661,39.27777481),"
Genesis Youth Center
535 Horner Ave
Clarksburg, WV 26301

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Genesis Youth Center",'Clarksburg=' + Clarksburg.length); Clarksburg[Clarksburg.length] = createMarker(new GPoint(-80.32947540,39.25503922),"
Harrison County Magnet Center
One Eagle Way
Clarksburg, WV 26301

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Harrison County Magnet Center",'Clarksburg=' + Clarksburg.length); Martinsburg[Martinsburg.length] = createMarker(new GPoint(-77.98841858,39.42235565),"
Pikeside Learning Center
2140 Winchester Pike
Martinsburg, WV 25401

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Pikeside Learning Center",'Martinsburg=' + Martinsburg.length); Clarksburg[Clarksburg.length] = createMarker(new GPoint(-80.36640167,39.26060104),"
Pressley Ridge School
Rr 5 Box 697
Clarksburg, WV 26301

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Pressley Ridge School",'Clarksburg=' + Clarksburg.length); Martinsburg[Martinsburg.length] = createMarker(new GPoint(-77.96855164,39.45965576),"
Ramer Center
515 W Martin St
Martinsburg, WV 25401

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Ramer Center",'Martinsburg=' + Martinsburg.length); Parkersburg[Parkersburg.length] = createMarker(new GPoint(-81.53165436,39.24464417),"
Rayon-trek Center
615 Broadway Avenue
Parkersburg, WV 26101

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Rayon-trek Center",'Parkersburg=' + Parkersburg.length); Dunbar[Dunbar.length] = createMarker(new GPoint(-81.75811768,38.37212372),"
Shawnee Community Center
142 Marshall Ave
Dunbar, WV 25064

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Shawnee Community Center",'Dunbar=' + Dunbar.length); Romney[Romney.length] = createMarker(new GPoint(-78.75261688,39.34054565),"
Wv Elementary School For Deaf
301 E Main St
Romney, WV 26757

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Wv Elementary School For Deaf",'Romney=' + Romney.length); Romney[Romney.length] = createMarker(new GPoint(-78.75707900,39.34213000),"
Wv School For Blind
301 E Main St
Romney, WV 26757

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Wv School For Blind",'Romney=' + Romney.length); Romney[Romney.length] = createMarker(new GPoint(-78.75707900,39.34213000),"
Wv Secondary School For Deaf
301 E Main St
Romney, WV 26757

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Wv Secondary School For Deaf",'Romney=' + Romney.length); maxLng = -77.96855164; maxLat = 39.48320007; minLng = -81.98500061; minLat = 37.87440109; reCenterMap(); map.removeOverlays(Clarksburg); map.removeOverlays(Dunbar); map.removeOverlays(Martinsburg); map.removeOverlays(Parkersburg); map.removeOverlays(Peach_Creek); map.removeOverlays(Romney); setTimeout(function(){map.addOverlays(Clarksburg)},1000); setTimeout(function(){map.addOverlays(Dunbar)},1000); setTimeout(function(){map.addOverlays(Martinsburg)},1000); setTimeout(function(){map.addOverlays(Parkersburg)},1000); setTimeout(function(){map.addOverlays(Peach_Creek)},1000); setTimeout(function(){map.addOverlays(Romney)},1000); } // 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(Clarksburg); map.removeOverlays(Dunbar); map.removeOverlays(Martinsburg); map.removeOverlays(Parkersburg); map.removeOverlays(Peach_Creek); map.removeOverlays(Romney); 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(Peach_Creek);map.removeOverlays(Clarksburg); map.removeOverlays(Dunbar); map.removeOverlays(Martinsburg); map.removeOverlays(Parkersburg); map.removeOverlays(Peach_Creek); map.removeOverlays(Romney); map.addOverlays(Clarksburg); centerByArray(Clarksburg, false, false); cntMarker += Clarksburg.length; map.addOverlays(Dunbar); centerByArray(Dunbar, false, false); cntMarker += Dunbar.length; map.addOverlays(Martinsburg); centerByArray(Martinsburg, false, false); cntMarker += Martinsburg.length; map.addOverlays(Parkersburg); centerByArray(Parkersburg, false, false); cntMarker += Parkersburg.length; map.addOverlays(Peach_Creek); centerByArray(Peach_Creek, false, false); cntMarker += Peach_Creek.length; map.addOverlays(Romney); centerByArray(Romney, false, false); cntMarker += Romney.length; centerByArray(Peach_Creek,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'); } }