function addMarkers()
{
mySelect = document.getElementById('selection');
Aldie = [];Sterling = [];Ashburn = [];Leesburg = [];Middleburg = [];Purcellville = [];South_Riding = [];Hamilton = [];Lovettsville = [];Ashburg = [];Potomac_Falls = [];Round_Hill = [];Waterford = [];mySelect.options[mySelect.options.length] = new Option("Aldie schools",'all=Aldie');
mySelect.options[mySelect.options.length] = new Option("Ashburg schools",'all=Ashburg');
mySelect.options[mySelect.options.length] = new Option("Ashburn schools",'all=Ashburn');
mySelect.options[mySelect.options.length] = new Option("Hamilton schools",'all=Hamilton');
mySelect.options[mySelect.options.length] = new Option("Leesburg schools",'all=Leesburg');
mySelect.options[mySelect.options.length] = new Option("Lovettsville schools",'all=Lovettsville');
mySelect.options[mySelect.options.length] = new Option("Middleburg schools",'all=Middleburg');
mySelect.options[mySelect.options.length] = new Option("Potomac Falls schools",'all=Potomac_Falls');
mySelect.options[mySelect.options.length] = new Option("Purcellville schools",'all=Purcellville');
mySelect.options[mySelect.options.length] = new Option("Round Hill schools",'all=Round_Hill');
mySelect.options[mySelect.options.length] = new Option("South Riding schools",'all=South_Riding');
mySelect.options[mySelect.options.length] = new Option("Sterling schools",'all=Sterling');
mySelect.options[mySelect.options.length] = new Option("Waterford schools",'all=Waterford');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Aldie[Aldie.length] = createMarker(new GPoint(-77.64361572,38.97438812),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Aldie Elementary School",'Aldie=' + Aldie.length);
Sterling[Sterling.length] = createMarker(new GPoint(-77.41118622,39.05612183),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Algonkian Elementary School",'Sterling=' + Sterling.length);
Aldie[Aldie.length] = createMarker(new GPoint(-77.56337738,38.94360352),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Arcola Elementary School",'Aldie=' + Aldie.length);
Ashburn[Ashburn.length] = createMarker(new GPoint(-77.47640991,39.05075836),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ashburn Elementary School",'Ashburn=' + Ashburn.length);
Leesburg[Leesburg.length] = createMarker(new GPoint(-77.53388214,39.12321472),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ball's Bluff Elementary School",'Leesburg=' + Leesburg.length);
Middleburg[Middleburg.length] = createMarker(new GPoint(-77.78755188,39.00405502),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Banneker Elementary School",'Middleburg=' + Middleburg.length);
Leesburg[Leesburg.length] = createMarker(new GPoint(-77.51682281,39.09896088),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Belmont Ridge Middle School",'Leesburg=' + Leesburg.length);
Ashburn[Ashburn.length] = createMarker(new GPoint(-77.51185400,39.05779400),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Belmont Station Elementary School",'Ashburn=' + Ashburn.length);
Purcellville[Purcellville.length] = createMarker(new GPoint(-77.70499420,39.12722778),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Blue Ridge Middle School",'Purcellville=' + Purcellville.length);
Ashburn[Ashburn.length] = createMarker(new GPoint(-77.53430900,38.99383100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Briar Woods High School",'Ashburn=' + Ashburn.length);
Ashburn[Ashburn.length] = createMarker(new GPoint(-77.49161530,39.02386093),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Broad Run High School",'Ashburn=' + Ashburn.length);
Leesburg[Leesburg.length] = createMarker(new GPoint(-77.58224487,39.11601257),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("C S Monroe Technology Center",'Leesburg=' + Leesburg.length);
Leesburg[Leesburg.length] = createMarker(new GPoint(-77.57527924,39.10963440),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Catoctin Elementary School",'Leesburg=' + Leesburg.length);
Ashburn[Ashburn.length] = createMarker(new GPoint(-77.49018097,39.03780365),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cedar Lane Elementary School",'Ashburn=' + Ashburn.length);
Leesburg[Leesburg.length] = createMarker(new GPoint(-77.54762268,39.09100342),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cool Spring Elementary School",'Leesburg=' + Leesburg.length);
Sterling[Sterling.length] = createMarker(new GPoint(-77.41216278,39.04341888),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Countryside Elementary School",'Sterling=' + Sterling.length);
Sterling[Sterling.length] = createMarker(new GPoint(-77.41230011,39.04301834),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Dominion High School",'Sterling=' + Sterling.length);
Ashburn[Ashburn.length] = createMarker(new GPoint(-77.47777557,39.03644943),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dominion Trail Elementary School",'Ashburn=' + Ashburn.length);
Leesburg[Leesburg.length] = createMarker(new GPoint(-77.55528259,39.11036682),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Douglass School",'Leesburg=' + Leesburg.length);
Ashburn[Ashburn.length] = createMarker(new GPoint(-77.51875305,39.01641464),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Eagle Ridge Middle School",'Ashburn=' + Ashburn.length);
Purcellville[Purcellville.length] = createMarker(new GPoint(-77.71892548,39.13124847),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Emerick Elementary School",'Purcellville=' + Purcellville.length);
Leesburg[Leesburg.length] = createMarker(new GPoint(-77.57151031,39.08970642),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Evergreen Mill Elementary School",'Leesburg=' + Leesburg.length);
Ashburn[Ashburn.length] = createMarker(new GPoint(-77.47164917,39.03780746),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Farmwell Station Middle School",'Ashburn=' + Ashburn.length);
Sterling[Sterling.length] = createMarker(new GPoint(-105.49540710,44.29695511),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Forest Grove Elementary School",'Sterling=' + Sterling.length);
Leesburg[Leesburg.length] = createMarker(new GPoint(-77.51682281,39.09896088),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Frances Hazel Reid Elementary School",'Leesburg=' + Leesburg.length);
South_Riding[South_Riding.length] = createMarker(new GPoint(-77.53503200,38.91388500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Freedom High School",'South_Riding=' + South_Riding.length);
Sterling[Sterling.length] = createMarker(new GPoint(-77.41754913,39.00128937),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Guilford Elementary School",'Sterling=' + Sterling.length);
Hamilton[Hamilton.length] = createMarker(new GPoint(-77.66192627,39.13321304),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hamilton Elementary School",'Hamilton=' + Hamilton.length);
Hamilton[Hamilton.length] = createMarker(new GPoint(-77.68266296,39.13614273),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Harmony Intermediate",'Hamilton=' + Hamilton.length);
Leesburg[Leesburg.length] = createMarker(new GPoint(-77.52091980,39.09584045),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Harper Park Middle School",'Leesburg=' + Leesburg.length);
Leesburg[Leesburg.length] = createMarker(new GPoint(-77.57134247,39.08879471),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Heritage High School",'Leesburg=' + Leesburg.length);
Purcellville[Purcellville.length] = createMarker(new GPoint(-77.71956635,39.19807816),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hillsboro Elementary School",'Purcellville=' + Purcellville.length);
Ashburn[Ashburn.length] = createMarker(new GPoint(-77.51308441,39.02000046),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hillside Elementary School",'Ashburn=' + Ashburn.length);
Sterling[Sterling.length] = createMarker(new GPoint(-77.38502502,39.04624557),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Horizon Elementary School",'Sterling=' + Sterling.length);
South_Riding[South_Riding.length] = createMarker(new GPoint(-77.52156067,38.91436386),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hutchison Farms Elementary School",'South_Riding=' + South_Riding.length);
Leesburg[Leesburg.length] = createMarker(new GPoint(-77.57115936,39.08968353),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("J. Lupton Simpson Middle School",'Leesburg=' + Leesburg.length);
Leesburg[Leesburg.length] = createMarker(new GPoint(-77.52107239,39.09593201),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("John W. Tolbert, Junior Elementary School",'Leesburg=' + Leesburg.length);
Leesburg[Leesburg.length] = createMarker(new GPoint(-77.54759216,39.12062836),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Leesburg Elementary School",'Leesburg=' + Leesburg.length);
Ashburn[Ashburn.length] = createMarker(new GPoint(-77.52458900,38.98052900),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Legacy Elementary School",'Ashburn=' + Ashburn.length);
Purcellville[Purcellville.length] = createMarker(new GPoint(-77.69692230,39.11827469),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Purcellville=' + Purcellville.length);
South_Riding[South_Riding.length] = createMarker(new GPoint(-77.49866486,38.89773560),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Little River Elementary School",'South_Riding=' + South_Riding.length);
Leesburg[Leesburg.length] = createMarker(new GPoint(-77.54748700,39.07608200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Loudoun Co. Juvenile Detention Home",'Leesburg=' + Leesburg.length);
Leesburg[Leesburg.length] = createMarker(new GPoint(-77.57841492,39.11063385),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Loudoun County High School",'Leesburg=' + Leesburg.length);
Purcellville[Purcellville.length] = createMarker(new GPoint(-77.70209503,39.14137268),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Loudoun Valley High School",'Purcellville=' + Purcellville.length);
Lovettsville[Lovettsville.length] = createMarker(new GPoint(-77.64096069,39.26573181),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lovettsville Elementary School",'Lovettsville=' + Lovettsville.length);
Sterling[Sterling.length] = createMarker(new GPoint(-77.34884644,39.04081345),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lowes Island Elementary School",'Sterling=' + Sterling.length);
Leesburg[Leesburg.length] = createMarker(new GPoint(-77.53511810,39.21283340),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lucketts Elementary School",'Leesburg=' + Leesburg.length);
Sterling[Sterling.length] = createMarker(new GPoint(-77.36985779,39.03518677),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Meadowland Elementary School",'Sterling=' + Sterling.length);
Aldie[Aldie.length] = createMarker(new GPoint(-77.54689100,38.92530500),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mercer Middle School",'Aldie=' + Aldie.length);
Middleburg[Middleburg.length] = createMarker(new GPoint(-77.72260284,39.00389862),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Middleburg Elementary School",'Middleburg=' + Middleburg.length);
Ashburn[Ashburn.length] = createMarker(new GPoint(-77.51871490,39.01649475),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mill Run Elementary School",'Ashburn=' + Ashburn.length);
Purcellville[Purcellville.length] = createMarker(new GPoint(-76.57450104,39.05472183),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mountain View Elementary School",'Purcellville=' + Purcellville.length);
Ashburg[Ashburg.length] = createMarker(new GPoint(-77.47287600,39.03692300),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Newton-lee Elementary School",'Ashburg=' + Ashburg.length);
Sterling[Sterling.length] = createMarker(new GPoint(-77.39901733,39.01347351),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Park View High School",'Sterling=' + Sterling.length);
Aldie[Aldie.length] = createMarker(new GPoint(-10.00000000,10.00000000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pinebrook Elementary School",'Aldie=' + Aldie.length);
Potomac_Falls[Potomac_Falls.length] = createMarker(new GPoint(-77.39070129,39.05011749),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Potomac Falls High School",'Potomac_Falls=' + Potomac_Falls.length);
Sterling[Sterling.length] = createMarker(new GPoint(-77.39541626,39.03874588),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Potowmack Elementary School",'Sterling=' + Sterling.length);
Sterling[Sterling.length] = createMarker(new GPoint(-77.39294434,39.04994202),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("River Bend Middle School",'Sterling=' + Sterling.length);
Sterling[Sterling.length] = createMarker(new GPoint(-77.38535309,39.01452637),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Rolling Ridge Elementary School",'Sterling=' + Sterling.length);
Round_Hill[Round_Hill.length] = createMarker(new GPoint(-77.76442719,39.14555359),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Round Hill Elementary School",'Round_Hill=' + Round_Hill.length);
Ashburn[Ashburn.length] = createMarker(new GPoint(-77.51030731,39.03697968),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sanders Corner Elementary School",'Ashburn=' + Ashburn.length);
Leesburg[Leesburg.length] = createMarker(new GPoint(-77.49897766,39.08386612),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Seldens Landing Elementary School",'Leesburg=' + Leesburg.length);
Sterling[Sterling.length] = createMarker(new GPoint(-77.37189484,39.02945709),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Seneca Ridge Middle School",'Sterling=' + Sterling.length);
Leesburg[Leesburg.length] = createMarker(new GPoint(-91.88776300,45.84026900),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Smart's Mill Middle School",'Leesburg=' + Leesburg.length);
Sterling[Sterling.length] = createMarker(new GPoint(-77.40172577,39.00848007),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sterling Elementary School",'Sterling=' + Sterling.length);
Sterling[Sterling.length] = createMarker(new GPoint(-77.40456390,39.00249481),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Sterling Middle School",'Sterling=' + Sterling.length);
Ashburn[Ashburn.length] = createMarker(new GPoint(-77.51030731,39.04653549),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Stone Bridge High School",'Ashburn=' + Ashburn.length);
Sterling[Sterling.length] = createMarker(new GPoint(-77.38327789,39.03758621),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sugarland Elementary School",'Sterling=' + Sterling.length);
Sterling[Sterling.length] = createMarker(new GPoint(-77.40058899,38.99608231),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sully Elementary School",'Sterling=' + Sterling.length);
Waterford[Waterford.length] = createMarker(new GPoint(-77.60669708,39.18653870),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Waterford Elementary School",'Waterford=' + Waterford.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,10);
/*
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(Aldie);
map.removeOverlays(Ashburg);
map.removeOverlays(Ashburn);
map.removeOverlays(Hamilton);
map.removeOverlays(Leesburg);
map.removeOverlays(Lovettsville);
map.removeOverlays(Middleburg);
map.removeOverlays(Potomac_Falls);
map.removeOverlays(Purcellville);
map.removeOverlays(Round_Hill);
map.removeOverlays(South_Riding);
map.removeOverlays(Sterling);
map.removeOverlays(Waterford);
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(Aldie);map.removeOverlays(Aldie);
map.removeOverlays(Ashburg);
map.removeOverlays(Ashburn);
map.removeOverlays(Hamilton);
map.removeOverlays(Leesburg);
map.removeOverlays(Lovettsville);
map.removeOverlays(Middleburg);
map.removeOverlays(Potomac_Falls);
map.removeOverlays(Purcellville);
map.removeOverlays(Round_Hill);
map.removeOverlays(South_Riding);
map.removeOverlays(Sterling);
map.removeOverlays(Waterford);
map.addOverlays(Aldie);
centerByArray(Aldie, false, false);
cntMarker += Aldie.length;
map.addOverlays(Ashburg);
centerByArray(Ashburg, false, false);
cntMarker += Ashburg.length;
map.addOverlays(Ashburn);
centerByArray(Ashburn, false, false);
cntMarker += Ashburn.length;
map.addOverlays(Hamilton);
centerByArray(Hamilton, false, false);
cntMarker += Hamilton.length;
map.addOverlays(Leesburg);
centerByArray(Leesburg, false, false);
cntMarker += Leesburg.length;
map.addOverlays(Lovettsville);
centerByArray(Lovettsville, false, false);
cntMarker += Lovettsville.length;
map.addOverlays(Middleburg);
centerByArray(Middleburg, false, false);
cntMarker += Middleburg.length;
map.addOverlays(Potomac_Falls);
centerByArray(Potomac_Falls, false, false);
cntMarker += Potomac_Falls.length;
map.addOverlays(Purcellville);
centerByArray(Purcellville, false, false);
cntMarker += Purcellville.length;
map.addOverlays(Round_Hill);
centerByArray(Round_Hill, false, false);
cntMarker += Round_Hill.length;
map.addOverlays(South_Riding);
centerByArray(South_Riding, false, false);
cntMarker += South_Riding.length;
map.addOverlays(Sterling);
centerByArray(Sterling, false, false);
cntMarker += Sterling.length;
map.addOverlays(Waterford);
centerByArray(Waterford, false, false);
cntMarker += Waterford.length;
centerByArray(Aldie,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');
}
}