function addMarkers(){ mySelect = document.getElementById('selection'); Bridgewater = [];Oakton = [];Marshall = [];Bedford = [];Virginia_Beach = [];Reston = [];Fairfax = [];mySelect.options[mySelect.options.length] = new Option("Bedford schools",'all=Bedford'); mySelect.options[mySelect.options.length] = new Option("Bridgewater schools",'all=Bridgewater'); mySelect.options[mySelect.options.length] = new Option("Fairfax schools",'all=Fairfax'); mySelect.options[mySelect.options.length] = new Option("Marshall schools",'all=Marshall'); mySelect.options[mySelect.options.length] = new Option("Oakton schools",'all=Oakton'); mySelect.options[mySelect.options.length] = new Option("Reston schools",'all=Reston'); mySelect.options[mySelect.options.length] = new Option("Virginia Beach schools",'all=Virginia_Beach'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Bridgewater[Bridgewater.length] = createMarker(new GPoint(-79.00540000,38.38930000),"
Blue Ridge Christian School
Po Box 207
Bridgewater, VA 22812
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Blue Ridge Christian School",'Bridgewater=' + Bridgewater.length); Oakton[Oakton.length] = createMarker(new GPoint(-77.32156200,38.88652200),"
Dominion Christian School
Po Box 3068 10922 Vale Road
Oakton, VA 22124
Co-ed school, K-9
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Dominion Christian School",'Oakton=' + Oakton.length); Marshall[Marshall.length] = createMarker(new GPoint(-77.90216800,38.77072300),"
Fresta Valley Christian School
6428 Wilson Rd
Marshall, VA 20115
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Fresta Valley Christian School",'Marshall=' + Marshall.length); Bedford[Bedford.length] = createMarker(new GPoint(-79.49858100,37.37161700),"
New Covenant Schools Of Bedford
1987 Big Island Highway
Bedford, VA 24523
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("New Covenant Schools Of Bedford",'Bedford=' + Bedford.length); Virginia_Beach[Virginia_Beach.length] = createMarker(new GPoint(-76.00197900,36.85291100),"
Norfolk Christian School-beach
1265 Laskin Rd
Virginia Beach, VA 23451
Co-ed school, PK-5
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Norfolk Christian School-beach",'Virginia_Beach=' + Virginia_Beach.length); Reston[Reston.length] = createMarker(new GPoint(-77.34276100,38.95213200),"
Oak Hill Christian School
11480 Sunset Hills Road
Reston, VA 20190
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Oak Hill Christian School",'Reston=' + Reston.length); Fairfax[Fairfax.length] = createMarker(new GPoint(-77.33597500,38.83302000),"
Trinity Christian School
11204 Braddock Road
Fairfax, VA 22030
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Trinity Christian School",'Fairfax=' + Fairfax.length); map.removeOverlays(Bedford); map.removeOverlays(Bridgewater); map.removeOverlays(Fairfax); map.removeOverlays(Marshall); map.removeOverlays(Oakton); map.removeOverlays(Reston); map.removeOverlays(Virginia_Beach); setTimeout(function(){map.addOverlays(Bedford)},1000); setTimeout(function(){map.addOverlays(Bridgewater)},1000); setTimeout(function(){map.addOverlays(Fairfax)},1000); setTimeout(function(){map.addOverlays(Marshall)},1000); setTimeout(function(){map.addOverlays(Oakton)},1000); setTimeout(function(){map.addOverlays(Reston)},1000); setTimeout(function(){map.addOverlays(Virginia_Beach)},1000); maxLng = -76.00197900; maxLat = 38.95213200; minLng = -79.49858100; minLat = 36.85291100; 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(Bedford); map.removeOverlays(Bridgewater); map.removeOverlays(Fairfax); map.removeOverlays(Marshall); map.removeOverlays(Oakton); map.removeOverlays(Reston); map.removeOverlays(Virginia_Beach); 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(Bridgewater);map.removeOverlays(Bedford); map.removeOverlays(Bridgewater); map.removeOverlays(Fairfax); map.removeOverlays(Marshall); map.removeOverlays(Oakton); map.removeOverlays(Reston); map.removeOverlays(Virginia_Beach); map.addOverlays(Bedford); centerByArray(Bedford, false, false); cntMarker += Bedford.length; map.addOverlays(Bridgewater); centerByArray(Bridgewater, false, false); cntMarker += Bridgewater.length; map.addOverlays(Fairfax); centerByArray(Fairfax, false, false); cntMarker += Fairfax.length; map.addOverlays(Marshall); centerByArray(Marshall, false, false); cntMarker += Marshall.length; map.addOverlays(Oakton); centerByArray(Oakton, false, false); cntMarker += Oakton.length; map.addOverlays(Reston); centerByArray(Reston, false, false); cntMarker += Reston.length; map.addOverlays(Virginia_Beach); centerByArray(Virginia_Beach, false, false); cntMarker += Virginia_Beach.length; centerByArray(Bridgewater,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///28496,28180,30483,33852,28068,28496,28180,28142,30483,28319,/all'); //window.open('/map.php?type=2&schools=28496,28180,30483,33852,28068,28496,28180,28142,30483,28319,&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; }