function addMarkers()
{
mySelect = document.getElementById('selection');
Westminster = [];Sykesville = [];Eldersburg = [];Union_Bridge = [];Hampstead = [];Manchester = [];Mount_Airy = [];New_Windsor = [];Taneytown = [];Mt_Airy = [];Finksburg = [];mySelect.options[mySelect.options.length] = new Option("Eldersburg schools",'all=Eldersburg');
mySelect.options[mySelect.options.length] = new Option("Finksburg schools",'all=Finksburg');
mySelect.options[mySelect.options.length] = new Option("Hampstead schools",'all=Hampstead');
mySelect.options[mySelect.options.length] = new Option("Manchester schools",'all=Manchester');
mySelect.options[mySelect.options.length] = new Option("Mount Airy schools",'all=Mount_Airy');
mySelect.options[mySelect.options.length] = new Option("Mt Airy schools",'all=Mt_Airy');
mySelect.options[mySelect.options.length] = new Option("New Windsor schools",'all=New_Windsor');
mySelect.options[mySelect.options.length] = new Option("Sykesville schools",'all=Sykesville');
mySelect.options[mySelect.options.length] = new Option("Taneytown schools",'all=Taneytown');
mySelect.options[mySelect.options.length] = new Option("Union Bridge schools",'all=Union_Bridge');
mySelect.options[mySelect.options.length] = new Option("Westminster schools",'all=Westminster');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Westminster[Westminster.length] = createMarker(new GPoint(-76.99387360,39.54079056),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Carroll County Career & Technology Center",'Westminster=' + Westminster.length);
Westminster[Westminster.length] = createMarker(new GPoint(-76.98601532,39.57227325),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Carroll County Evening High School",'Westminster=' + Westminster.length);
Westminster[Westminster.length] = createMarker(new GPoint(-76.98601532,39.57227325),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Carroll County Home & Hospital School",'Westminster=' + Westminster.length);
Westminster[Westminster.length] = createMarker(new GPoint(-76.99221802,39.55764771),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Carroll Springs School",'Westminster=' + Westminster.length);
Sykesville[Sykesville.length] = createMarker(new GPoint(-76.93203735,39.39425659),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Carrolltowne Elementary School",'Sykesville=' + Sykesville.length);
Eldersburg[Eldersburg.length] = createMarker(new GPoint(-76.98271179,39.42262268),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Century High School",'Eldersburg=' + Eldersburg.length);
Westminster[Westminster.length] = createMarker(new GPoint(-77.03498077,39.67545700),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Charles Carroll Elementary School",'Westminster=' + Westminster.length);
Westminster[Westminster.length] = createMarker(new GPoint(-76.97978973,39.57531357),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cranberry Station Elementary School",'Westminster=' + Westminster.length);
Sykesville[Sykesville.length] = createMarker(new GPoint(-76.96054840,39.40816116),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Eldersburg Elementary School",'Sykesville=' + Sykesville.length);
Union_Bridge[Union_Bridge.length] = createMarker(new GPoint(-77.17522430,39.57644653),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Elmer A. Wolfe Elementary School",'Union_Bridge=' + Union_Bridge.length);
Union_Bridge[Union_Bridge.length] = createMarker(new GPoint(-77.13181305,39.59359741),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Francis Scott Key Senior High School",'Union_Bridge=' + Union_Bridge.length);
Sykesville[Sykesville.length] = createMarker(new GPoint(-76.95055389,39.31485748),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Freedom District Elementary School",'Sykesville=' + Sykesville.length);
Westminster[Westminster.length] = createMarker(new GPoint(-77.00595856,39.54104233),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Friendship Valley Elementary School",'Westminster=' + Westminster.length);
Westminster[Westminster.length] = createMarker(new GPoint(-76.99600983,39.57518768),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gateway School",'Westminster=' + Westminster.length);
Hampstead[Hampstead.length] = createMarker(new GPoint(-76.86280823,39.60306931),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hampstead Elementary School",'Hampstead=' + Hampstead.length);
Sykesville[Sykesville.length] = createMarker(new GPoint(-76.95529938,39.41484070),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Liberty High School",'Sykesville=' + Sykesville.length);
Sykesville[Sykesville.length] = createMarker(new GPoint(-76.98186493,39.42256546),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Linton Springs Elementary School",'Sykesville=' + Sykesville.length);
Manchester[Manchester.length] = createMarker(new GPoint(-76.88407135,39.66170502),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Manchester Elementary School",'Manchester=' + Manchester.length);
Sykesville[Sykesville.length] = createMarker(new GPoint(-76.95055389,39.31485748),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mechanicsville Elementary School",'Sykesville=' + Sykesville.length);
Mount_Airy[Mount_Airy.length] = createMarker(new GPoint(-77.15033722,39.37986755),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mount Airy Elementary School",'Mount_Airy=' + Mount_Airy.length);
New_Windsor[New_Windsor.length] = createMarker(new GPoint(-77.11191559,39.55007935),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("New Windsor Middle School",'New_Windsor=' + New_Windsor.length);
Hampstead[Hampstead.length] = createMarker(new GPoint(-76.86128998,39.60866547),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Carroll High School",'Hampstead=' + Hampstead.length);
Hampstead[Hampstead.length] = createMarker(new GPoint(-76.86961365,39.64087296),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("North Carroll Middle School",'Hampstead=' + Hampstead.length);
Taneytown[Taneytown.length] = createMarker(new GPoint(-77.16871643,39.65212631),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Northwest Middle School",'Taneytown=' + Taneytown.length);
Sykesville[Sykesville.length] = createMarker(new GPoint(-76.93217468,39.39942551),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Oklahoma Road Middle School",'Sykesville=' + Sykesville.length);
Mt_Airy[Mt_Airy.length] = createMarker(new GPoint(-77.15479900,39.37647000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Parr's Ridge Elementary School",'Mt_Airy=' + Mt_Airy.length);
Sykesville[Sykesville.length] = createMarker(new GPoint(-76.96546936,39.40611649),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Piney Ridge Elementary School",'Sykesville=' + Sykesville.length);
Westminster[Westminster.length] = createMarker(new GPoint(-76.98591900,39.57341400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Post Secondary Program",'Westminster=' + Westminster.length);
Westminster[Westminster.length] = createMarker(new GPoint(-76.99255900,39.57448500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pride School",'Westminster=' + Westminster.length);
Westminster[Westminster.length] = createMarker(new GPoint(-76.99462128,39.53378677),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Robert Moton Elementary School",'Westminster=' + Westminster.length);
Westminster[Westminster.length] = createMarker(new GPoint(-77.10593414,39.63109589),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Runnymede Elementary School",'Westminster=' + Westminster.length);
Finksburg[Finksburg.length] = createMarker(new GPoint(-76.92402649,39.52406311),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sandymount Elementary School",'Finksburg=' + Finksburg.length);
Hampstead[Hampstead.length] = createMarker(new GPoint(-76.85796356,39.60207748),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Shiloh Middle School",'Hampstead=' + Hampstead.length);
Sykesville[Sykesville.length] = createMarker(new GPoint(-77.04566956,39.44329071),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Carroll Senior High School",'Sykesville=' + Sykesville.length);
Hampstead[Hampstead.length] = createMarker(new GPoint(-76.83910370,39.59287262),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Spring Garden Elementary School",'Hampstead=' + Hampstead.length);
Sykesville[Sykesville.length] = createMarker(new GPoint(-76.96749878,39.37279129),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Sykesville Middle School",'Sykesville=' + Sykesville.length);
Taneytown[Taneytown.length] = createMarker(new GPoint(-77.16871643,39.65212631),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Taneytown Elementary School",'Taneytown=' + Taneytown.length);
Westminster[Westminster.length] = createMarker(new GPoint(-76.99185181,39.57494736),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Westminster East Middle School",'Westminster=' + Westminster.length);
Westminster[Westminster.length] = createMarker(new GPoint(-77.02466583,39.58052826),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Westminster Elementary School",'Westminster=' + Westminster.length);
Westminster[Westminster.length] = createMarker(new GPoint(-76.99389648,39.54223251),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Westminster Senior High School",'Westminster=' + Westminster.length);
Westminster[Westminster.length] = createMarker(new GPoint(-76.99212646,39.58301163),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Westminster West Middle School",'Westminster=' + Westminster.length);
Westminster[Westminster.length] = createMarker(new GPoint(-76.99183655,39.58286285),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("William Winchester Elementary School",'Westminster=' + Westminster.length);
Westminster[Westminster.length] = createMarker(new GPoint(-77.05499268,39.45439529),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Winfield Elementary School",'Westminster=' + Westminster.length);
Westminster[Westminster.length] = createMarker(new GPoint(-76.97801971,39.57043839),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Winters Mill High School",'Westminster=' + Westminster.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(Eldersburg);
map.removeOverlays(Finksburg);
map.removeOverlays(Hampstead);
map.removeOverlays(Manchester);
map.removeOverlays(Mount_Airy);
map.removeOverlays(Mt_Airy);
map.removeOverlays(New_Windsor);
map.removeOverlays(Sykesville);
map.removeOverlays(Taneytown);
map.removeOverlays(Union_Bridge);
map.removeOverlays(Westminster);
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(Westminster);map.removeOverlays(Eldersburg);
map.removeOverlays(Finksburg);
map.removeOverlays(Hampstead);
map.removeOverlays(Manchester);
map.removeOverlays(Mount_Airy);
map.removeOverlays(Mt_Airy);
map.removeOverlays(New_Windsor);
map.removeOverlays(Sykesville);
map.removeOverlays(Taneytown);
map.removeOverlays(Union_Bridge);
map.removeOverlays(Westminster);
map.addOverlays(Eldersburg);
centerByArray(Eldersburg, false, false);
cntMarker += Eldersburg.length;
map.addOverlays(Finksburg);
centerByArray(Finksburg, false, false);
cntMarker += Finksburg.length;
map.addOverlays(Hampstead);
centerByArray(Hampstead, false, false);
cntMarker += Hampstead.length;
map.addOverlays(Manchester);
centerByArray(Manchester, false, false);
cntMarker += Manchester.length;
map.addOverlays(Mount_Airy);
centerByArray(Mount_Airy, false, false);
cntMarker += Mount_Airy.length;
map.addOverlays(Mt_Airy);
centerByArray(Mt_Airy, false, false);
cntMarker += Mt_Airy.length;
map.addOverlays(New_Windsor);
centerByArray(New_Windsor, false, false);
cntMarker += New_Windsor.length;
map.addOverlays(Sykesville);
centerByArray(Sykesville, false, false);
cntMarker += Sykesville.length;
map.addOverlays(Taneytown);
centerByArray(Taneytown, false, false);
cntMarker += Taneytown.length;
map.addOverlays(Union_Bridge);
centerByArray(Union_Bridge, false, false);
cntMarker += Union_Bridge.length;
map.addOverlays(Westminster);
centerByArray(Westminster, false, false);
cntMarker += Westminster.length;
centerByArray(Westminster,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');
}
}