function addMarkers()
{
mySelect = document.getElementById('selection');
Waldorf = [];Pomfret = [];Newburg = [];La_Plata = [];Marbury = [];Indian_Head = [];Nanjemoy = [];Bryantown = [];mySelect.options[mySelect.options.length] = new Option("Bryantown schools",'all=Bryantown');
mySelect.options[mySelect.options.length] = new Option("Indian Head schools",'all=Indian_Head');
mySelect.options[mySelect.options.length] = new Option("La Plata schools",'all=La_Plata');
mySelect.options[mySelect.options.length] = new Option("Marbury schools",'all=Marbury');
mySelect.options[mySelect.options.length] = new Option("Nanjemoy schools",'all=Nanjemoy');
mySelect.options[mySelect.options.length] = new Option("Newburg schools",'all=Newburg');
mySelect.options[mySelect.options.length] = new Option("Pomfret schools",'all=Pomfret');
mySelect.options[mySelect.options.length] = new Option("Waldorf schools",'all=Waldorf');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Waldorf[Waldorf.length] = createMarker(new GPoint(-76.92220306,38.60356903),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Arthur Middleton Elementary School",'Waldorf=' + Waldorf.length);
Waldorf[Waldorf.length] = createMarker(new GPoint(-76.89719391,38.60265350),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Benjamin Stoddert Middle School",'Waldorf=' + Waldorf.length);
Waldorf[Waldorf.length] = createMarker(new GPoint(-76.95807648,38.64913559),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Berry Elementary School",'Waldorf=' + Waldorf.length);
Waldorf[Waldorf.length] = createMarker(new GPoint(-76.93923950,38.62514877),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("C. Paul Barnhart Elementary School",'Waldorf=' + Waldorf.length);
Pomfret[Pomfret.length] = createMarker(new GPoint(-77.03115082,38.56949997),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Charles County Career & Technology Center",'Pomfret=' + Pomfret.length);
Waldorf[Waldorf.length] = createMarker(new GPoint(-76.92824554,38.63520432),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Daniel Of Saint Thomas Jenifer Elementary School",'Waldorf=' + Waldorf.length);
Waldorf[Waldorf.length] = createMarker(new GPoint(-76.91860199,38.59661865),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dr. Gustavus Brown Elementary School",'Waldorf=' + Waldorf.length);
Pomfret[Pomfret.length] = createMarker(new GPoint(-77.03172302,38.56760025),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dr. James Craik Elementary School",'Pomfret=' + Pomfret.length);
Waldorf[Waldorf.length] = createMarker(new GPoint(-76.90771484,38.60688019),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dr. Samuel A. Mudd Elementary School",'Waldorf=' + Waldorf.length);
Newburg[Newburg.length] = createMarker(new GPoint(-76.94110107,38.35956192),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dr. Thomas L. Higdon Elementary School",'Newburg=' + Newburg.length);
Waldorf[Waldorf.length] = createMarker(new GPoint(-76.90410614,38.59337616),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Eva Turner Elementary School",'Waldorf=' + Waldorf.length);
La_Plata[La_Plata.length] = createMarker(new GPoint(-76.94826508,38.54790115),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("F. B. Gwynn Educational Center",'La_Plata=' + La_Plata.length);
Marbury[Marbury.length] = createMarker(new GPoint(-77.15196228,38.56220245),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Gale-bailey Elementary School",'Marbury=' + Marbury.length);
Indian_Head[Indian_Head.length] = createMarker(new GPoint(-77.13437653,38.60216522),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("General Smallwood Middle School",'Indian_Head=' + Indian_Head.length);
Indian_Head[Indian_Head.length] = createMarker(new GPoint(-77.13368988,38.58027649),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Henry E. Lackey High School",'Indian_Head=' + Indian_Head.length);
Indian_Head[Indian_Head.length] = createMarker(new GPoint(-77.16468811,38.59983444),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Indian Head Elementary School",'Indian_Head=' + Indian_Head.length);
Indian_Head[Indian_Head.length] = createMarker(new GPoint(-77.07386780,38.61360931),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("J. C. Parks Elementary School",'Indian_Head=' + Indian_Head.length);
Waldorf[Waldorf.length] = createMarker(new GPoint(-76.89126587,38.62026978),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("J. P. Ryon Elementary School",'Waldorf=' + Waldorf.length);
Waldorf[Waldorf.length] = createMarker(new GPoint(-76.88764191,38.62279129),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("John Hanson Middle School",'Waldorf=' + Waldorf.length);
La_Plata[La_Plata.length] = createMarker(new GPoint(-76.94906616,38.54151535),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("La Plata High School",'La_Plata=' + La_Plata.length);
Waldorf[Waldorf.length] = createMarker(new GPoint(-76.79665375,38.61638260),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Malcolm Elementary School",'Waldorf=' + Waldorf.length);
La_Plata[La_Plata.length] = createMarker(new GPoint(-76.94906616,38.54151535),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mary Matula Elementary School",'La_Plata=' + La_Plata.length);
Waldorf[Waldorf.length] = createMarker(new GPoint(-76.95822906,38.64917755),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mattawoman Middle School",'Waldorf=' + Waldorf.length);
Indian_Head[Indian_Head.length] = createMarker(new GPoint(-77.07376862,38.61317444),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Matthew Henson Middle School",'Indian_Head=' + Indian_Head.length);
Pomfret[Pomfret.length] = createMarker(new GPoint(-77.03166199,38.56790924),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Maurice J. Mcdonough High School",'Pomfret=' + Pomfret.length);
La_Plata[La_Plata.length] = createMarker(new GPoint(-76.97989655,38.52709961),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Milton M. Somers Middle School",'La_Plata=' + La_Plata.length);
Nanjemoy[Nanjemoy.length] = createMarker(new GPoint(-77.17699432,38.45908356),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mt Hope/nanjemoy Elementary School",'Nanjemoy=' + Nanjemoy.length);
Waldorf[Waldorf.length] = createMarker(new GPoint(-76.97405900,38.64281600),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("North Point High School",'Waldorf=' + Waldorf.length);
Newburg[Newburg.length] = createMarker(new GPoint(-76.94365692,38.36180496),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Piccowaxen Middle School",'Newburg=' + Newburg.length);
La_Plata[La_Plata.length] = createMarker(new GPoint(-76.94906616,38.54151535),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Radio Station Road Academy School",'La_Plata=' + La_Plata.length);
Bryantown[Bryantown.length] = createMarker(new GPoint(-76.84104156,38.54229736),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("T. C. Martin Elementary School",'Bryantown=' + Bryantown.length);
Waldorf[Waldorf.length] = createMarker(new GPoint(-76.88824463,38.61677933),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Thomas Stone High School",'Waldorf=' + Waldorf.length);
La_Plata[La_Plata.length] = createMarker(new GPoint(-76.96777344,38.52592468),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Walter J. Mitchell Elementary School",'La_Plata=' + La_Plata.length);
Waldorf[Waldorf.length] = createMarker(new GPoint(-76.96922302,38.61929703),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Westlake High School",'Waldorf=' + Waldorf.length);
Waldorf[Waldorf.length] = createMarker(new GPoint(-76.93480682,38.61882019),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("William B. Wade Elementary School",'Waldorf=' + Waldorf.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(Bryantown);
map.removeOverlays(Indian_Head);
map.removeOverlays(La_Plata);
map.removeOverlays(Marbury);
map.removeOverlays(Nanjemoy);
map.removeOverlays(Newburg);
map.removeOverlays(Pomfret);
map.removeOverlays(Waldorf);
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(Waldorf);map.removeOverlays(Bryantown);
map.removeOverlays(Indian_Head);
map.removeOverlays(La_Plata);
map.removeOverlays(Marbury);
map.removeOverlays(Nanjemoy);
map.removeOverlays(Newburg);
map.removeOverlays(Pomfret);
map.removeOverlays(Waldorf);
map.addOverlays(Bryantown);
centerByArray(Bryantown, false, false);
cntMarker += Bryantown.length;
map.addOverlays(Indian_Head);
centerByArray(Indian_Head, false, false);
cntMarker += Indian_Head.length;
map.addOverlays(La_Plata);
centerByArray(La_Plata, false, false);
cntMarker += La_Plata.length;
map.addOverlays(Marbury);
centerByArray(Marbury, false, false);
cntMarker += Marbury.length;
map.addOverlays(Nanjemoy);
centerByArray(Nanjemoy, false, false);
cntMarker += Nanjemoy.length;
map.addOverlays(Newburg);
centerByArray(Newburg, false, false);
cntMarker += Newburg.length;
map.addOverlays(Pomfret);
centerByArray(Pomfret, false, false);
cntMarker += Pomfret.length;
map.addOverlays(Waldorf);
centerByArray(Waldorf, false, false);
cntMarker += Waldorf.length;
centerByArray(Waldorf,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');
}
}