function addMarkers(){
mySelect = document.getElementById('selection');
Accokeek = [];Bowie = [];Forestville = [];Capitol_Heights = [];Upper_Marlboro = [];Hyattsville = [];Bladensburg = [];Rockville = [];Temple_Hills = [];Suitland = [];Clinton = [];Landover = [];Lanham_Seabrook = [];Oxon_Hill = [];Brandywine = [];Fort_Washington = [];Landover_Hills = [];Camp_Springs = [];Laurel = [];Mitchellville = [];mySelect.options[mySelect.options.length] = new Option("Accokeek schools",'all=Accokeek');
mySelect.options[mySelect.options.length] = new Option("Bladensburg schools",'all=Bladensburg');
mySelect.options[mySelect.options.length] = new Option("Bowie schools",'all=Bowie');
mySelect.options[mySelect.options.length] = new Option("Brandywine schools",'all=Brandywine');
mySelect.options[mySelect.options.length] = new Option("Camp Springs schools",'all=Camp_Springs');
mySelect.options[mySelect.options.length] = new Option("Capitol Heights schools",'all=Capitol_Heights');
mySelect.options[mySelect.options.length] = new Option("Clinton schools",'all=Clinton');
mySelect.options[mySelect.options.length] = new Option("Forestville schools",'all=Forestville');
mySelect.options[mySelect.options.length] = new Option("Fort Washington schools",'all=Fort_Washington');
mySelect.options[mySelect.options.length] = new Option("Hyattsville schools",'all=Hyattsville');
mySelect.options[mySelect.options.length] = new Option("Landover schools",'all=Landover');
mySelect.options[mySelect.options.length] = new Option("Landover Hills schools",'all=Landover_Hills');
mySelect.options[mySelect.options.length] = new Option("Lanham Seabrook schools",'all=Lanham_Seabrook');
mySelect.options[mySelect.options.length] = new Option("Laurel schools",'all=Laurel');
mySelect.options[mySelect.options.length] = new Option("Mitchellville schools",'all=Mitchellville');
mySelect.options[mySelect.options.length] = new Option("Oxon Hill schools",'all=Oxon_Hill');
mySelect.options[mySelect.options.length] = new Option("Rockville schools",'all=Rockville');
mySelect.options[mySelect.options.length] = new Option("Suitland schools",'all=Suitland');
mySelect.options[mySelect.options.length] = new Option("Temple Hills schools",'all=Temple_Hills');
mySelect.options[mySelect.options.length] = new Option("Upper Marlboro schools",'all=Upper_Marlboro');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Accokeek[Accokeek.length] = createMarker(new GPoint(-77.01663700,38.67295200),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Beddow High School, The",'Accokeek=' + Accokeek.length);
Bowie[Bowie.length] = createMarker(new GPoint(-76.74046700,38.96097700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Belair Baptist Christian Academy",'Bowie=' + Bowie.length);
Forestville[Forestville.length] = createMarker(new GPoint(-76.88962300,38.85136900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bishop Mcnamara High School",'Forestville=' + Forestville.length);
Capitol_Heights[Capitol_Heights.length] = createMarker(new GPoint(-76.90370000,38.88590000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Children Of Light Christian Ch",'Capitol_Heights=' + Capitol_Heights.length);
Upper_Marlboro[Upper_Marlboro.length] = createMarker(new GPoint(-76.83226800,38.79725300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Clinton Christian School",'Upper_Marlboro=' + Upper_Marlboro.length);
Bowie[Bowie.length] = createMarker(new GPoint(-76.72781700,38.98262100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cornerstone Christian Academy",'Bowie=' + Bowie.length);
Hyattsville[Hyattsville.length] = createMarker(new GPoint(-76.94172000,38.95806300),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Dematha Catholic High School",'Hyattsville=' + Hyattsville.length);
Bladensburg[Bladensburg.length] = createMarker(new GPoint(-76.91391300,38.94722700),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Elizabeth Seton High School",'Bladensburg=' + Bladensburg.length);
Upper_Marlboro[Upper_Marlboro.length] = createMarker(new GPoint(-76.69351300,38.89149600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fairhaven School",'Upper_Marlboro=' + Upper_Marlboro.length);
Capitol_Heights[Capitol_Heights.length] = createMarker(new GPoint(-76.85781800,38.88195200),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Florence Bertell Academy Of Prince Georges Cnty",'Capitol_Heights=' + Capitol_Heights.length);
Rockville[Rockville.length] = createMarker(new GPoint(-77.11983900,39.04834400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Foundation Schools",'Rockville=' + Rockville.length);
Temple_Hills[Temple_Hills.length] = createMarker(new GPoint(-76.94968300,38.83096500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("From The Heart Christian School",'Temple_Hills=' + Temple_Hills.length);
Suitland[Suitland.length] = createMarker(new GPoint(-76.92736100,38.85021700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("God's Church International Higher Learning",'Suitland=' + Suitland.length);
Temple_Hills[Temple_Hills.length] = createMarker(new GPoint(-76.93726600,38.82293500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("God's Church Intl Higher Learn",'Temple_Hills=' + Temple_Hills.length);
Clinton[Clinton.length] = createMarker(new GPoint(-76.89475900,38.75657600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grace Brethren Christian School",'Clinton=' + Clinton.length);
Bowie[Bowie.length] = createMarker(new GPoint(-76.71183600,38.95741800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("High Road Academy Of Prince George's County",'Bowie=' + Bowie.length);
Capitol_Heights[Capitol_Heights.length] = createMarker(new GPoint(-76.85587500,38.88329000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("High Road School Of Prince George's County",'Capitol_Heights=' + Capitol_Heights.length);
Landover[Landover.length] = createMarker(new GPoint(-76.88934200,38.91037300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Highland Park Christian Academy",'Landover=' + Landover.length);
Clinton[Clinton.length] = createMarker(new GPoint(-76.89900000,38.75750000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Independent Baptist Academy",'Clinton=' + Clinton.length);
Landover[Landover.length] = createMarker(new GPoint(-76.85662700,38.90647900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jericho Christian Academy",'Landover=' + Landover.length);
Lanham_Seabrook[Lanham_Seabrook.length] = createMarker(new GPoint(-76.86204200,38.97896000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lanham Christian School",'Lanham_Seabrook=' + Lanham_Seabrook.length);
Oxon_Hill[Oxon_Hill.length] = createMarker(new GPoint(-77.00379800,38.79239700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Leary School Prince Georges Co",'Oxon_Hill=' + Oxon_Hill.length);
Brandywine[Brandywine.length] = createMarker(new GPoint(-76.89209100,38.71987500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Maryland Gospel Assembly School",'Brandywine=' + Brandywine.length);
Fort_Washington[Fort_Washington.length] = createMarker(new GPoint(-76.97809500,38.79815600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("National Christian Academy",'Fort_Washington=' + Fort_Washington.length);
Landover_Hills[Landover_Hills.length] = createMarker(new GPoint(-76.89498600,38.94429600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Hope Academy",'Landover_Hills=' + Landover_Hills.length);
Hyattsville[Hyattsville.length] = createMarker(new GPoint(-76.93440000,38.94230000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pathways School-hyattsville Re",'Hyattsville=' + Hyattsville.length);
Temple_Hills[Temple_Hills.length] = createMarker(new GPoint(-76.91318200,38.80197900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Progressive Christian Academy",'Temple_Hills=' + Temple_Hills.length);
Camp_Springs[Camp_Springs.length] = createMarker(new GPoint(-76.91348300,38.80209200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Progressive Christian Academy",'Camp_Springs=' + Camp_Springs.length);
Upper_Marlboro[Upper_Marlboro.length] = createMarker(new GPoint(-76.76258000,38.87517700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Queen Anne School",'Upper_Marlboro=' + Upper_Marlboro.length);
Upper_Marlboro[Upper_Marlboro.length] = createMarker(new GPoint(-76.78876800,38.87425400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Riverdale Baptist School",'Upper_Marlboro=' + Upper_Marlboro.length);
Laurel[Laurel.length] = createMarker(new GPoint(-76.85625000,39.10893200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Vincent Pallotti High School",'Laurel=' + Laurel.length);
Hyattsville[Hyattsville.length] = createMarker(new GPoint(-76.97796900,38.94689500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("St Anns High School",'Hyattsville=' + Hyattsville.length);
Mitchellville[Mitchellville.length] = createMarker(new GPoint(-76.79948600,38.94034600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Washington New Church School",'Mitchellville=' + Mitchellville.length);
Hyattsville[Hyattsville.length] = createMarker(new GPoint(-76.96426900,38.96341100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Washington United Christian Academy",'Hyattsville=' + Hyattsville.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(Accokeek);
map.removeOverlays(Bladensburg);
map.removeOverlays(Bowie);
map.removeOverlays(Brandywine);
map.removeOverlays(Camp_Springs);
map.removeOverlays(Capitol_Heights);
map.removeOverlays(Clinton);
map.removeOverlays(Forestville);
map.removeOverlays(Fort_Washington);
map.removeOverlays(Hyattsville);
map.removeOverlays(Landover);
map.removeOverlays(Landover_Hills);
map.removeOverlays(Lanham_Seabrook);
map.removeOverlays(Laurel);
map.removeOverlays(Mitchellville);
map.removeOverlays(Oxon_Hill);
map.removeOverlays(Rockville);
map.removeOverlays(Suitland);
map.removeOverlays(Temple_Hills);
map.removeOverlays(Upper_Marlboro);
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(Accokeek);map.removeOverlays(Accokeek);
map.removeOverlays(Bladensburg);
map.removeOverlays(Bowie);
map.removeOverlays(Brandywine);
map.removeOverlays(Camp_Springs);
map.removeOverlays(Capitol_Heights);
map.removeOverlays(Clinton);
map.removeOverlays(Forestville);
map.removeOverlays(Fort_Washington);
map.removeOverlays(Hyattsville);
map.removeOverlays(Landover);
map.removeOverlays(Landover_Hills);
map.removeOverlays(Lanham_Seabrook);
map.removeOverlays(Laurel);
map.removeOverlays(Mitchellville);
map.removeOverlays(Oxon_Hill);
map.removeOverlays(Rockville);
map.removeOverlays(Suitland);
map.removeOverlays(Temple_Hills);
map.removeOverlays(Upper_Marlboro);
map.addOverlays(Accokeek);
centerByArray(Accokeek, false, false);
cntMarker += Accokeek.length;
map.addOverlays(Bladensburg);
centerByArray(Bladensburg, false, false);
cntMarker += Bladensburg.length;
map.addOverlays(Bowie);
centerByArray(Bowie, false, false);
cntMarker += Bowie.length;
map.addOverlays(Brandywine);
centerByArray(Brandywine, false, false);
cntMarker += Brandywine.length;
map.addOverlays(Camp_Springs);
centerByArray(Camp_Springs, false, false);
cntMarker += Camp_Springs.length;
map.addOverlays(Capitol_Heights);
centerByArray(Capitol_Heights, false, false);
cntMarker += Capitol_Heights.length;
map.addOverlays(Clinton);
centerByArray(Clinton, false, false);
cntMarker += Clinton.length;
map.addOverlays(Forestville);
centerByArray(Forestville, false, false);
cntMarker += Forestville.length;
map.addOverlays(Fort_Washington);
centerByArray(Fort_Washington, false, false);
cntMarker += Fort_Washington.length;
map.addOverlays(Hyattsville);
centerByArray(Hyattsville, false, false);
cntMarker += Hyattsville.length;
map.addOverlays(Landover);
centerByArray(Landover, false, false);
cntMarker += Landover.length;
map.addOverlays(Landover_Hills);
centerByArray(Landover_Hills, false, false);
cntMarker += Landover_Hills.length;
map.addOverlays(Lanham_Seabrook);
centerByArray(Lanham_Seabrook, false, false);
cntMarker += Lanham_Seabrook.length;
map.addOverlays(Laurel);
centerByArray(Laurel, false, false);
cntMarker += Laurel.length;
map.addOverlays(Mitchellville);
centerByArray(Mitchellville, false, false);
cntMarker += Mitchellville.length;
map.addOverlays(Oxon_Hill);
centerByArray(Oxon_Hill, false, false);
cntMarker += Oxon_Hill.length;
map.addOverlays(Rockville);
centerByArray(Rockville, false, false);
cntMarker += Rockville.length;
map.addOverlays(Suitland);
centerByArray(Suitland, false, false);
cntMarker += Suitland.length;
map.addOverlays(Temple_Hills);
centerByArray(Temple_Hills, false, false);
cntMarker += Temple_Hills.length;
map.addOverlays(Upper_Marlboro);
centerByArray(Upper_Marlboro, false, false);
cntMarker += Upper_Marlboro.length;
centerByArray(Accokeek,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;
}