function addMarkers()
{
mySelect = document.getElementById('selection');
Frederick = [];Brunswick = [];Adamstown = [];Thurmont = [];New_Market = [];Emmitsburg = [];Walkersville = [];Monrovia = [];Hillcrest = [];Libertytown = [];Middletown = [];Myersville = [];Keymar = [];Ijamsville = [];Sabillasville = [];Mt_Airy = [];Jefferson = [];mySelect.options[mySelect.options.length] = new Option("Adamstown schools",'all=Adamstown');
mySelect.options[mySelect.options.length] = new Option("Brunswick schools",'all=Brunswick');
mySelect.options[mySelect.options.length] = new Option("Emmitsburg schools",'all=Emmitsburg');
mySelect.options[mySelect.options.length] = new Option("Frederick schools",'all=Frederick');
mySelect.options[mySelect.options.length] = new Option("Hillcrest schools",'all=Hillcrest');
mySelect.options[mySelect.options.length] = new Option("Ijamsville schools",'all=Ijamsville');
mySelect.options[mySelect.options.length] = new Option("Jefferson schools",'all=Jefferson');
mySelect.options[mySelect.options.length] = new Option("Keymar schools",'all=Keymar');
mySelect.options[mySelect.options.length] = new Option("Libertytown schools",'all=Libertytown');
mySelect.options[mySelect.options.length] = new Option("Middletown schools",'all=Middletown');
mySelect.options[mySelect.options.length] = new Option("Monrovia schools",'all=Monrovia');
mySelect.options[mySelect.options.length] = new Option("Mt Airy schools",'all=Mt_Airy');
mySelect.options[mySelect.options.length] = new Option("Myersville schools",'all=Myersville');
mySelect.options[mySelect.options.length] = new Option("New Market schools",'all=New_Market');
mySelect.options[mySelect.options.length] = new Option("Sabillasville schools",'all=Sabillasville');
mySelect.options[mySelect.options.length] = new Option("Thurmont schools",'all=Thurmont');
mySelect.options[mySelect.options.length] = new Option("Walkersville schools",'all=Walkersville');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Frederick[Frederick.length] = createMarker(new GPoint(-77.42973328,39.37783813),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ballenger Creek Elementary School",'Frederick=' + Frederick.length);
Frederick[Frederick.length] = createMarker(new GPoint(-77.44321442,39.38301086),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Ballenger Creek Middle School",'Frederick=' + Frederick.length);
Brunswick[Brunswick.length] = createMarker(new GPoint(-77.63430023,39.31801224),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Brunswick Elementary School",'Brunswick=' + Brunswick.length);
Brunswick[Brunswick.length] = createMarker(new GPoint(-77.61074829,39.31625748),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Brunswick High School",'Brunswick=' + Brunswick.length);
Brunswick[Brunswick.length] = createMarker(new GPoint(-77.61074829,39.31625748),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Brunswick Middle School",'Brunswick=' + Brunswick.length);
Adamstown[Adamstown.length] = createMarker(new GPoint(-77.47062683,39.31265640),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Carroll Manor Elementary School",'Adamstown=' + Adamstown.length);
Thurmont[Thurmont.length] = createMarker(new GPoint(-77.41068268,39.63788223),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Catoctin High School",'Thurmont=' + Thurmont.length);
Frederick[Frederick.length] = createMarker(new GPoint(-77.33410700,39.33358500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Centerville Elementary School",'Frederick=' + Frederick.length);
Frederick[Frederick.length] = createMarker(new GPoint(-77.42512600,39.39304200),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Crestwood Middle School",'Frederick=' + Frederick.length);
New_Market[New_Market.length] = createMarker(new GPoint(-77.29999542,39.40055084),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Deer Crossing Elementary School",'New_Market=' + New_Market.length);
Emmitsburg[Emmitsburg.length] = createMarker(new GPoint(-77.32825470,39.70128632),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Emmitsburg Elementary School",'Emmitsburg=' + Emmitsburg.length);
Frederick[Frederick.length] = createMarker(new GPoint(-77.41319275,39.45068741),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Frederick County Career & Technology Center",'Frederick=' + Frederick.length);
Walkersville[Walkersville.length] = createMarker(new GPoint(-77.34755707,39.48323059),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Frederick County Evening High School",'Walkersville=' + Walkersville.length);
Frederick[Frederick.length] = createMarker(new GPoint(-77.42572784,39.41726685),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Frederick High School",'Frederick=' + Frederick.length);
Walkersville[Walkersville.length] = createMarker(new GPoint(-77.35199738,39.49954987),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Glade Elementary School",'Walkersville=' + Walkersville.length);
Frederick[Frederick.length] = createMarker(new GPoint(-77.40487671,39.43273926),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gov. Thomas Johnson High School",'Frederick=' + Frederick.length);
Frederick[Frederick.length] = createMarker(new GPoint(-77.39967346,39.43870544),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Gov. Thomas Johnson Middle School",'Frederick=' + Frederick.length);
Monrovia[Monrovia.length] = createMarker(new GPoint(-77.26227570,39.34454727),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Green Valley Elementary School",'Monrovia=' + Monrovia.length);
Frederick[Frederick.length] = createMarker(new GPoint(-77.41301727,39.43625641),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Heather Ridge High School",'Frederick=' + Frederick.length);
Frederick[Frederick.length] = createMarker(new GPoint(-77.41301727,39.43625641),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Heather Ridge Middle School",'Frederick=' + Frederick.length);
Hillcrest[Hillcrest.length] = createMarker(new GPoint(-77.45285034,39.41078186),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hillcrest Elementary School",'Hillcrest=' + Hillcrest.length);
Monrovia[Monrovia.length] = createMarker(new GPoint(-77.23516846,39.32716370),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kemptown Elementary School",'Monrovia=' + Monrovia.length);
Thurmont[Thurmont.length] = createMarker(new GPoint(-77.41559601,39.53761673),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lewistown Elementary School",'Thurmont=' + Thurmont.length);
Libertytown[Libertytown.length] = createMarker(new GPoint(-77.25475311,39.48220062),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Liberty Elementary School",'Libertytown=' + Libertytown.length);
Frederick[Frederick.length] = createMarker(new GPoint(-77.24376678,39.43250275),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Linganore High School",'Frederick=' + Frederick.length);
Middletown[Middletown.length] = createMarker(new GPoint(-77.53799438,39.44302750),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Middletown Elementary School",'Middletown=' + Middletown.length);
Middletown[Middletown.length] = createMarker(new GPoint(-77.53638458,39.44179916),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Middletown High School",'Middletown=' + Middletown.length);
Middletown[Middletown.length] = createMarker(new GPoint(-77.53656769,39.44147110),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Middletown Middle School",'Middletown=' + Middletown.length);
Frederick[Frederick.length] = createMarker(new GPoint(-77.41042328,39.45694351),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Monocacy Elementary School",'Frederick=' + Frederick.length);
Frederick[Frederick.length] = createMarker(new GPoint(-77.41454315,39.45526886),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Monocacy Middle School",'Frederick=' + Frederick.length);
Frederick[Frederick.length] = createMarker(new GPoint(-77.38664246,39.44884872),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Monocacy Valley Montessori School",'Frederick=' + Frederick.length);
Myersville[Myersville.length] = createMarker(new GPoint(-77.56620026,39.50970078),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Myersville Elementary School",'Myersville=' + Myersville.length);
New_Market[New_Market.length] = createMarker(new GPoint(-77.28549957,39.40530014),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("New Market Elementary School",'New_Market=' + New_Market.length);
New_Market[New_Market.length] = createMarker(new GPoint(-77.28549957,39.40530014),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("New Market Middle School",'New_Market=' + New_Market.length);
Keymar[Keymar.length] = createMarker(new GPoint(-77.71311188,39.64149475),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("New Midway/woodsboro Elementary School",'Keymar=' + Keymar.length);
Frederick[Frederick.length] = createMarker(new GPoint(-77.41008759,39.42676544),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("North Frederick Elementary School",'Frederick=' + Frederick.length);
Ijamsville[Ijamsville.length] = createMarker(new GPoint(-77.32577515,39.39353561),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Oakdale Elementary School",'Ijamsville=' + Ijamsville.length);
Ijamsville[Ijamsville.length] = createMarker(new GPoint(-77.28549957,39.40530014),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Oakdale Middle School",'Ijamsville=' + Ijamsville.length);
Frederick[Frederick.length] = createMarker(new GPoint(-77.44117737,39.39249802),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Orchard Grove Elementary School",'Frederick=' + Frederick.length);
Frederick[Frederick.length] = createMarker(new GPoint(-77.41842651,39.41496658),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Parkway Elementary School",'Frederick=' + Frederick.length);
Frederick[Frederick.length] = createMarker(new GPoint(-77.45979309,39.42501068),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rock Creek School",'Frederick=' + Frederick.length);
Sabillasville[Sabillasville.length] = createMarker(new GPoint(-77.45477295,39.67759705),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sabillasville Elementary School",'Sabillasville=' + Sabillasville.length);
Frederick[Frederick.length] = createMarker(new GPoint(-77.41616821,39.40877533),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South Frederick Elementary School",'Frederick=' + Frederick.length);
Frederick[Frederick.length] = createMarker(new GPoint(-77.35218048,39.40039063),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Spring Ridge Elementary School",'Frederick=' + Frederick.length);
Thurmont[Thurmont.length] = createMarker(new GPoint(-77.39813232,39.61745453),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Thurmont Elementary School",'Thurmont=' + Thurmont.length);
Thurmont[Thurmont.length] = createMarker(new GPoint(-77.40448761,39.62139130),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Thurmont Middle School",'Thurmont=' + Thurmont.length);
Thurmont[Thurmont.length] = createMarker(new GPoint(-77.38831329,39.61463547),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Thurmont Primary",'Thurmont=' + Thurmont.length);
Frederick[Frederick.length] = createMarker(new GPoint(-77.44329400,39.37089900),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Tuscarora Elementary School",'Frederick=' + Frederick.length);
Frederick[Frederick.length] = createMarker(new GPoint(-76.83809662,38.97650146),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tuscarora High School",'Frederick=' + Frederick.length);
Mt_Airy[Mt_Airy.length] = createMarker(new GPoint(-77.17405701,39.37118912),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Twin Ridge Elementary School",'Mt_Airy=' + Mt_Airy.length);
Frederick[Frederick.length] = createMarker(new GPoint(-77.35765839,39.32861328),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Urbana Elementary School",'Frederick=' + Frederick.length);
Ijamsville[Ijamsville.length] = createMarker(new GPoint(-77.32436600,39.36162100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Urbana High School",'Ijamsville=' + Ijamsville.length);
Jefferson[Jefferson.length] = createMarker(new GPoint(-77.54837799,39.36021042),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Valley Elementary School",'Jefferson=' + Jefferson.length);
Walkersville[Walkersville.length] = createMarker(new GPoint(-77.34645081,39.48373795),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Walkersville Elementary School",'Walkersville=' + Walkersville.length);
Walkersville[Walkersville.length] = createMarker(new GPoint(-77.35768127,39.47620773),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Walkersville High School",'Walkersville=' + Walkersville.length);
Walkersville[Walkersville.length] = createMarker(new GPoint(-77.35536194,39.47837067),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Walkersville Middle School",'Walkersville=' + Walkersville.length);
Frederick[Frederick.length] = createMarker(new GPoint(-77.45981598,39.42507935),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Waverley Elementary School",'Frederick=' + Frederick.length);
Frederick[Frederick.length] = createMarker(new GPoint(-77.43735504,39.41598892),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("West Frederick Middle School",'Frederick=' + Frederick.length);
Frederick[Frederick.length] = createMarker(new GPoint(-77.44624329,39.45489120),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Whittier Elementary School",'Frederick=' + Frederick.length);
Ijamsville[Ijamsville.length] = createMarker(new GPoint(-77.27815247,39.32204056),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Windsor Knolls Middle School",'Ijamsville=' + Ijamsville.length);
Myersville[Myersville.length] = createMarker(new GPoint(-77.55112457,39.57336807),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wolfsville Elementary School",'Myersville=' + Myersville.length);
Frederick[Frederick.length] = createMarker(new GPoint(-77.45449829,39.47337341),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Yellow Springs Elementary School",'Frederick=' + Frederick.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(Adamstown);
map.removeOverlays(Brunswick);
map.removeOverlays(Emmitsburg);
map.removeOverlays(Frederick);
map.removeOverlays(Hillcrest);
map.removeOverlays(Ijamsville);
map.removeOverlays(Jefferson);
map.removeOverlays(Keymar);
map.removeOverlays(Libertytown);
map.removeOverlays(Middletown);
map.removeOverlays(Monrovia);
map.removeOverlays(Mt_Airy);
map.removeOverlays(Myersville);
map.removeOverlays(New_Market);
map.removeOverlays(Sabillasville);
map.removeOverlays(Thurmont);
map.removeOverlays(Walkersville);
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(Frederick);map.removeOverlays(Adamstown);
map.removeOverlays(Brunswick);
map.removeOverlays(Emmitsburg);
map.removeOverlays(Frederick);
map.removeOverlays(Hillcrest);
map.removeOverlays(Ijamsville);
map.removeOverlays(Jefferson);
map.removeOverlays(Keymar);
map.removeOverlays(Libertytown);
map.removeOverlays(Middletown);
map.removeOverlays(Monrovia);
map.removeOverlays(Mt_Airy);
map.removeOverlays(Myersville);
map.removeOverlays(New_Market);
map.removeOverlays(Sabillasville);
map.removeOverlays(Thurmont);
map.removeOverlays(Walkersville);
map.addOverlays(Adamstown);
centerByArray(Adamstown, false, false);
cntMarker += Adamstown.length;
map.addOverlays(Brunswick);
centerByArray(Brunswick, false, false);
cntMarker += Brunswick.length;
map.addOverlays(Emmitsburg);
centerByArray(Emmitsburg, false, false);
cntMarker += Emmitsburg.length;
map.addOverlays(Frederick);
centerByArray(Frederick, false, false);
cntMarker += Frederick.length;
map.addOverlays(Hillcrest);
centerByArray(Hillcrest, false, false);
cntMarker += Hillcrest.length;
map.addOverlays(Ijamsville);
centerByArray(Ijamsville, false, false);
cntMarker += Ijamsville.length;
map.addOverlays(Jefferson);
centerByArray(Jefferson, false, false);
cntMarker += Jefferson.length;
map.addOverlays(Keymar);
centerByArray(Keymar, false, false);
cntMarker += Keymar.length;
map.addOverlays(Libertytown);
centerByArray(Libertytown, false, false);
cntMarker += Libertytown.length;
map.addOverlays(Middletown);
centerByArray(Middletown, false, false);
cntMarker += Middletown.length;
map.addOverlays(Monrovia);
centerByArray(Monrovia, false, false);
cntMarker += Monrovia.length;
map.addOverlays(Mt_Airy);
centerByArray(Mt_Airy, false, false);
cntMarker += Mt_Airy.length;
map.addOverlays(Myersville);
centerByArray(Myersville, false, false);
cntMarker += Myersville.length;
map.addOverlays(New_Market);
centerByArray(New_Market, false, false);
cntMarker += New_Market.length;
map.addOverlays(Sabillasville);
centerByArray(Sabillasville, false, false);
cntMarker += Sabillasville.length;
map.addOverlays(Thurmont);
centerByArray(Thurmont, false, false);
cntMarker += Thurmont.length;
map.addOverlays(Walkersville);
centerByArray(Walkersville, false, false);
cntMarker += Walkersville.length;
centerByArray(Frederick,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');
}
}