function addMarkers(){
mySelect = document.getElementById('selection');
Springfield = [];Centreville = [];Alexandria = [];Chantilly = [];Fairfax_Station = [];Vienna = [];Herndon = [];Oakton = [];Baileys_Crossroads = [];Fairfax = [];Mclean = [];Reston = [];Annandale = [];Falls_Church = [];mySelect.options[mySelect.options.length] = new Option("Alexandria schools",'all=Alexandria');
mySelect.options[mySelect.options.length] = new Option("Annandale schools",'all=Annandale');
mySelect.options[mySelect.options.length] = new Option("Baileys Crossroads schools",'all=Baileys_Crossroads');
mySelect.options[mySelect.options.length] = new Option("Centreville schools",'all=Centreville');
mySelect.options[mySelect.options.length] = new Option("Chantilly schools",'all=Chantilly');
mySelect.options[mySelect.options.length] = new Option("Fairfax schools",'all=Fairfax');
mySelect.options[mySelect.options.length] = new Option("Fairfax Station schools",'all=Fairfax_Station');
mySelect.options[mySelect.options.length] = new Option("Falls Church schools",'all=Falls_Church');
mySelect.options[mySelect.options.length] = new Option("Herndon schools",'all=Herndon');
mySelect.options[mySelect.options.length] = new Option("Mclean schools",'all=Mclean');
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("Springfield schools",'all=Springfield');
mySelect.options[mySelect.options.length] = new Option("Vienna schools",'all=Vienna');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Springfield[Springfield.length] = createMarker(new GPoint(-77.23874800,38.78442900),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Accotink Academy",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-77.23527400,38.78189700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Accotink Alternative",'Springfield=' + Springfield.length);
Centreville[Centreville.length] = createMarker(new GPoint(-77.48120400,38.82936400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ad Fontes Academy",'Centreville=' + Centreville.length);
Springfield[Springfield.length] = createMarker(new GPoint(-77.16729900,38.80138400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chesapeake Academy",'Springfield=' + Springfield.length);
Alexandria[Alexandria.length] = createMarker(new GPoint(-77.12770900,38.78385700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christian Center School",'Alexandria=' + Alexandria.length);
Chantilly[Chantilly.length] = createMarker(new GPoint(-77.44068700,38.88259000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Different Drum Inc.",'Chantilly=' + Chantilly.length);
Springfield[Springfield.length] = createMarker(new GPoint(-77.21999500,38.80843300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Dominion School",'Springfield=' + Springfield.length);
Alexandria[Alexandria.length] = createMarker(new GPoint(-77.12047000,38.72802100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Engleside Christian School",'Alexandria=' + Alexandria.length);
Fairfax_Station[Fairfax_Station.length] = createMarker(new GPoint(-77.30104200,38.77506000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fairfax Baptist Temple Academy",'Fairfax_Station=' + Fairfax_Station.length);
Vienna[Vienna.length] = createMarker(new GPoint(-77.31180900,38.95158600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fairfax Christian School",'Vienna=' + Vienna.length);
Herndon[Herndon.length] = createMarker(new GPoint(-77.37907000,38.96936600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fairfax Collegiate Summer Program",'Herndon=' + Herndon.length);
Oakton[Oakton.length] = createMarker(new GPoint(-77.31870000,38.87083700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Flint Hill School",'Oakton=' + Oakton.length);
Chantilly[Chantilly.length] = createMarker(new GPoint(-77.43494900,38.89403100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("High Road School Of Northern Virginia",'Chantilly=' + Chantilly.length);
Alexandria[Alexandria.length] = createMarker(new GPoint(-77.10248300,38.73178000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Islamic Saudi Academy",'Alexandria=' + Alexandria.length);
Baileys_Crossroads[Baileys_Crossroads.length] = createMarker(new GPoint(-77.12310500,38.85111400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Khadijah Academy",'Baileys_Crossroads=' + Baileys_Crossroads.length);
Alexandria[Alexandria.length] = createMarker(new GPoint(-77.14776600,38.82833900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Leary School Of Virginia",'Alexandria=' + Alexandria.length);
Fairfax[Fairfax.length] = createMarker(new GPoint(-77.35700900,38.83043000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Little Flock Christian School",'Fairfax=' + Fairfax.length);
Mclean[Mclean.length] = createMarker(new GPoint(-77.23215100,38.96433500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("The Madeira School",'Mclean=' + Mclean.length);
Reston[Reston.length] = createMarker(new GPoint(-77.34276100,38.95213200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Oak Hill Christian School",'Reston=' + Reston.length);
Fairfax[Fairfax.length] = createMarker(new GPoint(-77.33404200,38.85986500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Oak Valley Center",'Fairfax=' + Fairfax.length);
Mclean[Mclean.length] = createMarker(new GPoint(-77.19168400,38.95731800),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Oakcrest School",'Mclean=' + Mclean.length);
Reston[Reston.length] = createMarker(new GPoint(-77.34276100,38.95213200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Oasis School",'Reston=' + Reston.length);
Annandale[Annandale.length] = createMarker(new GPoint(-77.18671000,38.81203700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Phillips School-Annandale",'Annandale=' + Annandale.length);
Mclean[Mclean.length] = createMarker(new GPoint(-77.15303900,38.93870000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Potomac School",'Mclean=' + Mclean.length);
Herndon[Herndon.length] = createMarker(new GPoint(-77.37658900,38.98917400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Temple Baptist School",'Herndon=' + Herndon.length);
Fairfax[Fairfax.length] = createMarker(new GPoint(-77.33597500,38.83302000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Christian School",'Fairfax=' + Fairfax.length);
Falls_Church[Falls_Church.length] = createMarker(new GPoint(-77.20549900,38.87469100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity School At Meadow View",'Falls_Church=' + Falls_Church.length);
Fairfax[Fairfax.length] = createMarker(new GPoint(-77.24938200,38.86552900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Way Of Faith Christian Academy",'Fairfax=' + Fairfax.length);
Springfield[Springfield.length] = createMarker(new GPoint(-77.18494500,38.80802600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Word Of Life Christian Academy",'Springfield=' + Springfield.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/////2/' + showArray);
map.removeOverlays(Alexandria);
map.removeOverlays(Annandale);
map.removeOverlays(Baileys_Crossroads);
map.removeOverlays(Centreville);
map.removeOverlays(Chantilly);
map.removeOverlays(Fairfax);
map.removeOverlays(Fairfax_Station);
map.removeOverlays(Falls_Church);
map.removeOverlays(Herndon);
map.removeOverlays(Mclean);
map.removeOverlays(Oakton);
map.removeOverlays(Reston);
map.removeOverlays(Springfield);
map.removeOverlays(Vienna);
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(Springfield);map.removeOverlays(Alexandria);
map.removeOverlays(Annandale);
map.removeOverlays(Baileys_Crossroads);
map.removeOverlays(Centreville);
map.removeOverlays(Chantilly);
map.removeOverlays(Fairfax);
map.removeOverlays(Fairfax_Station);
map.removeOverlays(Falls_Church);
map.removeOverlays(Herndon);
map.removeOverlays(Mclean);
map.removeOverlays(Oakton);
map.removeOverlays(Reston);
map.removeOverlays(Springfield);
map.removeOverlays(Vienna);
map.addOverlays(Alexandria);
centerByArray(Alexandria, false, false);
cntMarker += Alexandria.length;
map.addOverlays(Annandale);
centerByArray(Annandale, false, false);
cntMarker += Annandale.length;
map.addOverlays(Baileys_Crossroads);
centerByArray(Baileys_Crossroads, false, false);
cntMarker += Baileys_Crossroads.length;
map.addOverlays(Centreville);
centerByArray(Centreville, false, false);
cntMarker += Centreville.length;
map.addOverlays(Chantilly);
centerByArray(Chantilly, false, false);
cntMarker += Chantilly.length;
map.addOverlays(Fairfax);
centerByArray(Fairfax, false, false);
cntMarker += Fairfax.length;
map.addOverlays(Fairfax_Station);
centerByArray(Fairfax_Station, false, false);
cntMarker += Fairfax_Station.length;
map.addOverlays(Falls_Church);
centerByArray(Falls_Church, false, false);
cntMarker += Falls_Church.length;
map.addOverlays(Herndon);
centerByArray(Herndon, false, false);
cntMarker += Herndon.length;
map.addOverlays(Mclean);
centerByArray(Mclean, false, false);
cntMarker += Mclean.length;
map.addOverlays(Oakton);
centerByArray(Oakton, false, false);
cntMarker += Oakton.length;
map.addOverlays(Reston);
centerByArray(Reston, false, false);
cntMarker += Reston.length;
map.addOverlays(Springfield);
centerByArray(Springfield, false, false);
cntMarker += Springfield.length;
map.addOverlays(Vienna);
centerByArray(Vienna, false, false);
cntMarker += Vienna.length;
centerByArray(Springfield,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=2&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;
}