function addMarkers(){
mySelect = document.getElementById('selection');
Herndon = [];Dulles = [];Ashburn = [];Manassas = [];Sterling = [];Leesburg = [];Middleburg = [];Purcellville = [];mySelect.options[mySelect.options.length] = new Option("Ashburn schools",'all=Ashburn');
mySelect.options[mySelect.options.length] = new Option("Dulles schools",'all=Dulles');
mySelect.options[mySelect.options.length] = new Option("Herndon schools",'all=Herndon');
mySelect.options[mySelect.options.length] = new Option("Leesburg schools",'all=Leesburg');
mySelect.options[mySelect.options.length] = new Option("Manassas schools",'all=Manassas');
mySelect.options[mySelect.options.length] = new Option("Middleburg schools",'all=Middleburg');
mySelect.options[mySelect.options.length] = new Option("Purcellville schools",'all=Purcellville');
mySelect.options[mySelect.options.length] = new Option("Sterling schools",'all=Sterling');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Herndon[Herndon.length] = createMarker(new GPoint(-77.57011500,39.11580200),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("A Kid's Place",'Herndon=' + Herndon.length);
Dulles[Dulles.length] = createMarker(new GPoint(-77.45101300,39.00106700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Aol Child Dev Center",'Dulles=' + Dulles.length);
Ashburn[Ashburn.length] = createMarker(new GPoint(-77.47513500,39.03893200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ashburn Village Country Day School",'Ashburn=' + Ashburn.length);
Ashburn[Ashburn.length] = createMarker(new GPoint(-77.51801200,39.01721000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Boyd School",'Ashburn=' + Ashburn.length);
Manassas[Manassas.length] = createMarker(new GPoint(-77.49695600,38.80532100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Boyd School - Manassas",'Manassas=' + Manassas.length);
Sterling[Sterling.length] = createMarker(new GPoint(-77.40677100,39.02735900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chesterbrook Academy - Sterling",'Sterling=' + Sterling.length);
Ashburn[Ashburn.length] = createMarker(new GPoint(-77.45692500,39.01900600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christian Faith & Fellowship School",'Ashburn=' + Ashburn.length);
Sterling[Sterling.length] = createMarker(new GPoint(-77.40388500,39.02711400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Creme De La Creme",'Sterling=' + Sterling.length);
Leesburg[Leesburg.length] = createMarker(new GPoint(-77.58132200,39.10746700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Dominion Academy",'Leesburg=' + Leesburg.length);
Sterling[Sterling.length] = createMarker(new GPoint(-77.39908700,39.02173700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Christian School",'Sterling=' + Sterling.length);
Ashburn[Ashburn.length] = createMarker(new GPoint(-77.48091800,39.02343000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Golden Pond School",'Ashburn=' + Ashburn.length);
Leesburg[Leesburg.length] = createMarker(new GPoint(-77.58314600,39.11639900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Graydon Manor",'Leesburg=' + Leesburg.length);
Middleburg[Middleburg.length] = createMarker(new GPoint(-77.72260000,39.00390000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Hill School",'Middleburg=' + Middleburg.length);
Leesburg[Leesburg.length] = createMarker(new GPoint(-77.58184500,39.03127200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Leesburg Christian School",'Leesburg=' + Leesburg.length);
Leesburg[Leesburg.length] = createMarker(new GPoint(-77.57333700,39.04599000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Loudoun Country Day School",'Leesburg=' + Leesburg.length);
Ashburn[Ashburn.length] = createMarker(new GPoint(-77.51410400,39.05466400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Academy At Belmont Greene",'Ashburn=' + Ashburn.length);
Sterling[Sterling.length] = createMarker(new GPoint(-77.42880000,39.00610000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Childrens House Of Loudoun",'Sterling=' + Sterling.length);
Leesburg[Leesburg.length] = createMarker(new GPoint(-77.53973100,39.10965400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School Of Leesburg",'Leesburg=' + Leesburg.length);
Sterling[Sterling.length] = createMarker(new GPoint(-77.40911200,39.00839900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Munger Academy",'Sterling=' + Sterling.length);
Leesburg[Leesburg.length] = createMarker(new GPoint(-77.55592300,39.12208600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Paxton Child Development Cnter",'Leesburg=' + Leesburg.length);
Purcellville[Purcellville.length] = createMarker(new GPoint(-77.70547200,39.13788800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Purcellville Children's Academy",'Purcellville=' + Purcellville.length);
Ashburn[Ashburn.length] = createMarker(new GPoint(-77.50082300,39.02423900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Theresa School",'Ashburn=' + Ashburn.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/////1/' + showArray);
map.removeOverlays(Ashburn);
map.removeOverlays(Dulles);
map.removeOverlays(Herndon);
map.removeOverlays(Leesburg);
map.removeOverlays(Manassas);
map.removeOverlays(Middleburg);
map.removeOverlays(Purcellville);
map.removeOverlays(Sterling);
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(Herndon);map.removeOverlays(Ashburn);
map.removeOverlays(Dulles);
map.removeOverlays(Herndon);
map.removeOverlays(Leesburg);
map.removeOverlays(Manassas);
map.removeOverlays(Middleburg);
map.removeOverlays(Purcellville);
map.removeOverlays(Sterling);
map.addOverlays(Ashburn);
centerByArray(Ashburn, false, false);
cntMarker += Ashburn.length;
map.addOverlays(Dulles);
centerByArray(Dulles, false, false);
cntMarker += Dulles.length;
map.addOverlays(Herndon);
centerByArray(Herndon, false, false);
cntMarker += Herndon.length;
map.addOverlays(Leesburg);
centerByArray(Leesburg, false, false);
cntMarker += Leesburg.length;
map.addOverlays(Manassas);
centerByArray(Manassas, false, false);
cntMarker += Manassas.length;
map.addOverlays(Middleburg);
centerByArray(Middleburg, false, false);
cntMarker += Middleburg.length;
map.addOverlays(Purcellville);
centerByArray(Purcellville, false, false);
cntMarker += Purcellville.length;
map.addOverlays(Sterling);
centerByArray(Sterling, false, false);
cntMarker += Sterling.length;
centerByArray(Herndon,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=1&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;
}