function addMarkers(){
mySelect = document.getElementById('selection');
Woodbridge = [];Manassas = [];Triangle = [];Bristow = [];Dumfries = [];Dale_City = [];Catharpin = [];Gainesville = [];Lake_Ridge = [];mySelect.options[mySelect.options.length] = new Option("Bristow schools",'all=Bristow');
mySelect.options[mySelect.options.length] = new Option("Catharpin schools",'all=Catharpin');
mySelect.options[mySelect.options.length] = new Option("Dale City schools",'all=Dale_City');
mySelect.options[mySelect.options.length] = new Option("Dumfries schools",'all=Dumfries');
mySelect.options[mySelect.options.length] = new Option("Gainesville schools",'all=Gainesville');
mySelect.options[mySelect.options.length] = new Option("Lake Ridge schools",'all=Lake_Ridge');
mySelect.options[mySelect.options.length] = new Option("Manassas schools",'all=Manassas');
mySelect.options[mySelect.options.length] = new Option("Triangle schools",'all=Triangle');
mySelect.options[mySelect.options.length] = new Option("Woodbridge schools",'all=Woodbridge');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Woodbridge[Woodbridge.length] = createMarker(new GPoint(-77.30305600,38.65736800),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Academy Day Care",'Woodbridge=' + Woodbridge.length);
Manassas[Manassas.length] = createMarker(new GPoint(-77.48424200,38.75422900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("All Saints Catholic School",'Manassas=' + Manassas.length);
Woodbridge[Woodbridge.length] = createMarker(new GPoint(-77.32364000,38.66192900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethel Christian School",'Woodbridge=' + Woodbridge.length);
Triangle[Triangle.length] = createMarker(new GPoint(-77.18350000,38.77460000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calvary Christian School",'Triangle=' + Triangle.length);
Woodbridge[Woodbridge.length] = createMarker(new GPoint(-77.25865000,38.66263000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cardinal Montessori School",'Woodbridge=' + Woodbridge.length);
Manassas[Manassas.length] = createMarker(new GPoint(-77.52371400,38.73853400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chesterbrook Academy - Manassas",'Manassas=' + Manassas.length);
Woodbridge[Woodbridge.length] = createMarker(new GPoint(-77.27927200,38.67511300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Children's World Learning Center",'Woodbridge=' + Woodbridge.length);
Manassas[Manassas.length] = createMarker(new GPoint(-77.51061800,38.78896400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Children's World Learning Centers",'Manassas=' + Manassas.length);
Bristow[Bristow.length] = createMarker(new GPoint(-77.55995500,38.73939400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Childrens World Braemar #090",'Bristow=' + Bristow.length);
Woodbridge[Woodbridge.length] = createMarker(new GPoint(-77.30178300,38.64764300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christ Chapel Academy",'Woodbridge=' + Woodbridge.length);
Dumfries[Dumfries.length] = createMarker(new GPoint(-77.34699600,38.62528800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Clairmont School And Child Care Center",'Dumfries=' + Dumfries.length);
Woodbridge[Woodbridge.length] = createMarker(new GPoint(-77.30762300,38.65567300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cloverdale School",'Woodbridge=' + Woodbridge.length);
Dale_City[Dale_City.length] = createMarker(new GPoint(-77.35956700,38.64848300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Dale City Christian Church Cdc & Academy",'Dale_City=' + Dale_City.length);
Woodbridge[Woodbridge.length] = createMarker(new GPoint(-77.25569700,38.66132600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Edelen's Montessori Learning Center",'Woodbridge=' + Woodbridge.length);
Manassas[Manassas.length] = createMarker(new GPoint(-77.45014000,38.78268200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Emmanuel Christian School",'Manassas=' + Manassas.length);
Dale_City[Dale_City.length] = createMarker(new GPoint(-77.30567100,38.62918200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Evangel Christian School",'Dale_City=' + Dale_City.length);
Manassas[Manassas.length] = createMarker(new GPoint(-77.49611700,38.77756000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fairmont Christian Preparatory School",'Manassas=' + Manassas.length);
Catharpin[Catharpin.length] = createMarker(new GPoint(-77.57179500,38.85433700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("First Steps Preschool",'Catharpin=' + Catharpin.length);
Manassas[Manassas.length] = createMarker(new GPoint(-77.50974900,38.80072900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Good Shepherd Academy",'Manassas=' + Manassas.length);
Manassas[Manassas.length] = createMarker(new GPoint(-77.48438100,38.77982800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Greater Mt Calvary Christian Preschool & Academy",'Manassas=' + Manassas.length);
Woodbridge[Woodbridge.length] = createMarker(new GPoint(-77.37836100,38.63584200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Heritage Christian School",'Woodbridge=' + Woodbridge.length);
Dale_City[Dale_City.length] = createMarker(new GPoint(-77.32016000,38.64560400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Family Catholic School",'Dale_City=' + Dale_City.length);
Dale_City[Dale_City.length] = createMarker(new GPoint(-77.33408300,38.66682600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jewels And Jems",'Dale_City=' + Dale_City.length);
Dumfries[Dumfries.length] = createMarker(new GPoint(-77.31073900,38.58167400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("La Petite Academy - Dumfries",'Dumfries=' + Dumfries.length);
Woodbridge[Woodbridge.length] = createMarker(new GPoint(-77.30381500,38.65224600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("La Petite Academy-smoketown Rd",'Woodbridge=' + Woodbridge.length);
Bristow[Bristow.length] = createMarker(new GPoint(-77.56664800,38.74997700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Linton Hall School",'Bristow=' + Bristow.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-77.59861800,38.77601400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Minnieland At Bridlewood",'Gainesville=' + Gainesville.length);
Woodbridge[Woodbridge.length] = createMarker(new GPoint(-77.26262200,38.67269600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Minnieland At Yarbrough/lake R",'Woodbridge=' + Woodbridge.length);
Woodbridge[Woodbridge.length] = createMarker(new GPoint(-77.32709600,38.65000600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Minnieland Of Dale City",'Woodbridge=' + Woodbridge.length);
Woodbridge[Woodbridge.length] = createMarker(new GPoint(-77.30131200,38.64472600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Morning Star Child Development Center",'Woodbridge=' + Woodbridge.length);
Manassas[Manassas.length] = createMarker(new GPoint(-77.46565200,38.78982200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Noahs Ark Christian Preschool",'Manassas=' + Manassas.length);
Dumfries[Dumfries.length] = createMarker(new GPoint(-77.33004100,38.56129500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Open Door Apostolic Christian Academy",'Dumfries=' + Dumfries.length);
Woodbridge[Woodbridge.length] = createMarker(new GPoint(-77.25886200,38.66098800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Peter Pan Day School",'Woodbridge=' + Woodbridge.length);
Lake_Ridge[Lake_Ridge.length] = createMarker(new GPoint(-77.31453600,38.68686700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Prince William Academy",'Lake_Ridge=' + Lake_Ridge.length);
Dumfries[Dumfries.length] = createMarker(new GPoint(-77.33017600,38.56392000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Richard Milburn High School",'Dumfries=' + Dumfries.length);
Woodbridge[Woodbridge.length] = createMarker(new GPoint(-77.26672300,38.62840300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Riverview Baptist Day School",'Woodbridge=' + Woodbridge.length);
Woodbridge[Woodbridge.length] = createMarker(new GPoint(-77.25747100,38.65319600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Thomas Aquinas Regional School",'Woodbridge=' + Woodbridge.length);
Triangle[Triangle.length] = createMarker(new GPoint(-77.32951000,38.54401600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Francis Of Assisi School",'Triangle=' + Triangle.length);
Woodbridge[Woodbridge.length] = createMarker(new GPoint(-77.26531900,38.64972400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St John Neumann School",'Woodbridge=' + Woodbridge.length);
Triangle[Triangle.length] = createMarker(new GPoint(-77.34380000,38.55360000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Star Bethlehem Christian Academy",'Triangle=' + Triangle.length);
Manassas[Manassas.length] = createMarker(new GPoint(-77.49630700,38.77702800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tabernacle Baptist Academy",'Manassas=' + Manassas.length);
Woodbridge[Woodbridge.length] = createMarker(new GPoint(-77.26204200,38.66231300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Temple Preschool",'Woodbridge=' + Woodbridge.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-77.61573900,38.81076600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wonderland Child Care Center",'Gainesville=' + Gainesville.length);
Bristow[Bristow.length] = createMarker(new GPoint(-77.54808000,38.73847900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Youth For Tomorrow",'Bristow=' + Bristow.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/////3/' + showArray);
map.removeOverlays(Bristow);
map.removeOverlays(Catharpin);
map.removeOverlays(Dale_City);
map.removeOverlays(Dumfries);
map.removeOverlays(Gainesville);
map.removeOverlays(Lake_Ridge);
map.removeOverlays(Manassas);
map.removeOverlays(Triangle);
map.removeOverlays(Woodbridge);
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(Woodbridge);map.removeOverlays(Bristow);
map.removeOverlays(Catharpin);
map.removeOverlays(Dale_City);
map.removeOverlays(Dumfries);
map.removeOverlays(Gainesville);
map.removeOverlays(Lake_Ridge);
map.removeOverlays(Manassas);
map.removeOverlays(Triangle);
map.removeOverlays(Woodbridge);
map.addOverlays(Bristow);
centerByArray(Bristow, false, false);
cntMarker += Bristow.length;
map.addOverlays(Catharpin);
centerByArray(Catharpin, false, false);
cntMarker += Catharpin.length;
map.addOverlays(Dale_City);
centerByArray(Dale_City, false, false);
cntMarker += Dale_City.length;
map.addOverlays(Dumfries);
centerByArray(Dumfries, false, false);
cntMarker += Dumfries.length;
map.addOverlays(Gainesville);
centerByArray(Gainesville, false, false);
cntMarker += Gainesville.length;
map.addOverlays(Lake_Ridge);
centerByArray(Lake_Ridge, false, false);
cntMarker += Lake_Ridge.length;
map.addOverlays(Manassas);
centerByArray(Manassas, false, false);
cntMarker += Manassas.length;
map.addOverlays(Triangle);
centerByArray(Triangle, false, false);
cntMarker += Triangle.length;
map.addOverlays(Woodbridge);
centerByArray(Woodbridge, false, false);
cntMarker += Woodbridge.length;
centerByArray(Woodbridge,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=3&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;
}