function addMarkers(){ mySelect = document.getElementById('selection'); Appomattox = [];Danville = [];Newport_News = [];Lynchburg = [];Wytheville = [];Powhatan = [];Manassas = [];Fredericksburg = [];Dryden = [];Chesapeake = [];Yale = [];mySelect.options[mySelect.options.length] = new Option("Appomattox schools",'all=Appomattox'); mySelect.options[mySelect.options.length] = new Option("Chesapeake schools",'all=Chesapeake'); mySelect.options[mySelect.options.length] = new Option("Danville schools",'all=Danville'); mySelect.options[mySelect.options.length] = new Option("Dryden schools",'all=Dryden'); mySelect.options[mySelect.options.length] = new Option("Fredericksburg schools",'all=Fredericksburg'); mySelect.options[mySelect.options.length] = new Option("Lynchburg schools",'all=Lynchburg'); mySelect.options[mySelect.options.length] = new Option("Manassas schools",'all=Manassas'); mySelect.options[mySelect.options.length] = new Option("Newport News schools",'all=Newport_News'); mySelect.options[mySelect.options.length] = new Option("Powhatan schools",'all=Powhatan'); mySelect.options[mySelect.options.length] = new Option("Wytheville schools",'all=Wytheville'); mySelect.options[mySelect.options.length] = new Option("Yale schools",'all=Yale'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Appomattox[Appomattox.length] = createMarker(new GPoint(-78.83194100,37.36062600),"
Appomattox Sda School
631 Court Street
Appomattox, VA 24522
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Appomattox Sda School",'Appomattox=' + Appomattox.length); Danville[Danville.length] = createMarker(new GPoint(-79.45709600,36.58923600),"
B & P Young Seventh-day Adventist School
212 Ingram Road
Danville, VA 24541
Co-ed school, 1-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("B & P Young Seventh-day Adventist School",'Danville=' + Danville.length); Newport_News[Newport_News.length] = createMarker(new GPoint(-76.43660000,37.01910000),"
Calvary Sda School
Po Box 5109
Newport News, VA 23605
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Calvary Sda School",'Newport_News=' + Newport_News.length); Lynchburg[Lynchburg.length] = createMarker(new GPoint(-79.18580400,37.32132600),"
Desmond T Doss Junior Academy
19 George Street
Lynchburg, VA 24502
Co-ed school, PK-9
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Desmond T Doss Junior Academy",'Lynchburg=' + Lynchburg.length); Wytheville[Wytheville.length] = createMarker(new GPoint(-81.04468100,36.94419900),"
Echo Valley Christian School
265 Echo Valley Road
Wytheville, VA 24382
Co-ed school, 1-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Echo Valley Christian School",'Wytheville=' + Wytheville.length); Powhatan[Powhatan.length] = createMarker(new GPoint(-77.86292500,37.47051400),"
Ephaugh Academy
1072 Timber Trace Rd
Powhatan, VA 23139
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Ephaugh Academy",'Powhatan=' + Powhatan.length); Manassas[Manassas.length] = createMarker(new GPoint(-77.49611700,38.77756000),"
Fairmont Christian Preparatory School
8225 Barrett Drive
Manassas, VA 20109
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Fairmont Christian Preparatory School",'Manassas=' + Manassas.length); Fredericksburg[Fredericksburg.length] = createMarker(new GPoint(-77.58918000,38.29363000),"
Fredericksburg Sda Jr. Academy
6050 Plank Rd
Fredericksburg, VA 22407
Co-ed school, KG-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Fredericksburg Sda Jr. Academy",'Fredericksburg=' + Fredericksburg.length); Dryden[Dryden.length] = createMarker(new GPoint(-82.93220000,36.77890000),"
Powell Valley Christ School
Rr 1 Box 1015
Dryden, VA 24243
Co-ed school, K-7
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Powell Valley Christ School",'Dryden=' + Dryden.length); Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.18547900,36.75789400),"
Tidewater Adventist Academy
1136 Centerville Tpke N
Chesapeake, VA 23320
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Tidewater Adventist Academy",'Chesapeake=' + Chesapeake.length); Yale[Yale.length] = createMarker(new GPoint(-77.29017100,36.85807200),"
Yale Sda School
19183 Courthouse Road
Yale, VA 23897
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Yale Sda School",'Yale=' + Yale.length); map.removeOverlays(Appomattox); map.removeOverlays(Chesapeake); map.removeOverlays(Danville); map.removeOverlays(Dryden); map.removeOverlays(Fredericksburg); map.removeOverlays(Lynchburg); map.removeOverlays(Manassas); map.removeOverlays(Newport_News); map.removeOverlays(Powhatan); map.removeOverlays(Wytheville); map.removeOverlays(Yale); setTimeout(function(){map.addOverlays(Appomattox)},1000); setTimeout(function(){map.addOverlays(Chesapeake)},1000); setTimeout(function(){map.addOverlays(Danville)},1000); setTimeout(function(){map.addOverlays(Dryden)},1000); setTimeout(function(){map.addOverlays(Fredericksburg)},1000); setTimeout(function(){map.addOverlays(Lynchburg)},1000); setTimeout(function(){map.addOverlays(Manassas)},1000); setTimeout(function(){map.addOverlays(Newport_News)},1000); setTimeout(function(){map.addOverlays(Powhatan)},1000); setTimeout(function(){map.addOverlays(Wytheville)},1000); setTimeout(function(){map.addOverlays(Yale)},1000); maxLng = -76.18547900; maxLat = 38.77756000; minLng = -82.93220000; minLat = 36.58923600; reCenterMap(); } // 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//////' + showArray); map.removeOverlays(Appomattox); map.removeOverlays(Chesapeake); map.removeOverlays(Danville); map.removeOverlays(Dryden); map.removeOverlays(Fredericksburg); map.removeOverlays(Lynchburg); map.removeOverlays(Manassas); map.removeOverlays(Newport_News); map.removeOverlays(Powhatan); map.removeOverlays(Wytheville); map.removeOverlays(Yale); 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(Appomattox);map.removeOverlays(Appomattox); map.removeOverlays(Chesapeake); map.removeOverlays(Danville); map.removeOverlays(Dryden); map.removeOverlays(Fredericksburg); map.removeOverlays(Lynchburg); map.removeOverlays(Manassas); map.removeOverlays(Newport_News); map.removeOverlays(Powhatan); map.removeOverlays(Wytheville); map.removeOverlays(Yale); map.addOverlays(Appomattox); centerByArray(Appomattox, false, false); cntMarker += Appomattox.length; map.addOverlays(Chesapeake); centerByArray(Chesapeake, false, false); cntMarker += Chesapeake.length; map.addOverlays(Danville); centerByArray(Danville, false, false); cntMarker += Danville.length; map.addOverlays(Dryden); centerByArray(Dryden, false, false); cntMarker += Dryden.length; map.addOverlays(Fredericksburg); centerByArray(Fredericksburg, false, false); cntMarker += Fredericksburg.length; map.addOverlays(Lynchburg); centerByArray(Lynchburg, false, false); cntMarker += Lynchburg.length; map.addOverlays(Manassas); centerByArray(Manassas, false, false); cntMarker += Manassas.length; map.addOverlays(Newport_News); centerByArray(Newport_News, false, false); cntMarker += Newport_News.length; map.addOverlays(Powhatan); centerByArray(Powhatan, false, false); cntMarker += Powhatan.length; map.addOverlays(Wytheville); centerByArray(Wytheville, false, false); cntMarker += Wytheville.length; map.addOverlays(Yale); centerByArray(Yale, false, false); cntMarker += Yale.length; centerByArray(Appomattox,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///28491,28140,28045,28491,28136,28353,28178,28140,28157,28087,28150,28145,28547,/all'); //window.open('/map.php?type=2&schools=28491,28140,28045,28491,28136,28353,28178,28140,28157,28087,28150,28145,28547,&school_level=&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; }