function addMarkers()
{
mySelect = document.getElementById('selection');
Baldwin = [];Towson = [];Catonsville = [];Reisterstown = [];Perry_Hall = [];Randallstown = [];Cockeysville = [];Owings_Mills = [];Timonium = [];Upperco = [];Halethorpe = [];Lutherville = [];Parkton = [];Monkton = [];Phoenix = [];Kingsville = [];Freeland = [];Sparks = [];Sparrows_Point = [];Pikesville = [];Parkville = [];mySelect.options[mySelect.options.length] = new Option("Baldwin schools",'all=Baldwin');
mySelect.options[mySelect.options.length] = new Option("Catonsville schools",'all=Catonsville');
mySelect.options[mySelect.options.length] = new Option("Cockeysville schools",'all=Cockeysville');
mySelect.options[mySelect.options.length] = new Option("Freeland schools",'all=Freeland');
mySelect.options[mySelect.options.length] = new Option("Halethorpe schools",'all=Halethorpe');
mySelect.options[mySelect.options.length] = new Option("Kingsville schools",'all=Kingsville');
mySelect.options[mySelect.options.length] = new Option("Lutherville schools",'all=Lutherville');
mySelect.options[mySelect.options.length] = new Option("Monkton schools",'all=Monkton');
mySelect.options[mySelect.options.length] = new Option("Owings Mills schools",'all=Owings_Mills');
mySelect.options[mySelect.options.length] = new Option("Parkton schools",'all=Parkton');
mySelect.options[mySelect.options.length] = new Option("Parkville schools",'all=Parkville');
mySelect.options[mySelect.options.length] = new Option("Perry Hall schools",'all=Perry_Hall');
mySelect.options[mySelect.options.length] = new Option("Phoenix schools",'all=Phoenix');
mySelect.options[mySelect.options.length] = new Option("Pikesville schools",'all=Pikesville');
mySelect.options[mySelect.options.length] = new Option("Randallstown schools",'all=Randallstown');
mySelect.options[mySelect.options.length] = new Option("Reisterstown schools",'all=Reisterstown');
mySelect.options[mySelect.options.length] = new Option("Sparks schools",'all=Sparks');
mySelect.options[mySelect.options.length] = new Option("Sparrows Point schools",'all=Sparrows_Point');
mySelect.options[mySelect.options.length] = new Option("Timonium schools",'all=Timonium');
mySelect.options[mySelect.options.length] = new Option("Towson schools",'all=Towson');
mySelect.options[mySelect.options.length] = new Option("Upperco schools",'all=Upperco');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Baldwin[Baldwin.length] = createMarker(new GPoint(-76.52501678,39.49596405),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Carroll Manor Elementary School",'Baldwin=' + Baldwin.length);
Towson[Towson.length] = createMarker(new GPoint(-76.60894012,39.40966415),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Carver Center For Arts & Technology",'Towson=' + Towson.length);
Catonsville[Catonsville.length] = createMarker(new GPoint(-76.72915649,39.27255630),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Catonsville Elementary School",'Catonsville=' + Catonsville.length);
Catonsville[Catonsville.length] = createMarker(new GPoint(-76.77233124,39.27693939),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Catonsville Middle School",'Catonsville=' + Catonsville.length);
Reisterstown[Reisterstown.length] = createMarker(new GPoint(-76.80704498,39.44044876),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cedarmere Elementary School",'Reisterstown=' + Reisterstown.length);
Perry_Hall[Perry_Hall.length] = createMarker(new GPoint(-76.43281555,39.39757538),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Chapel Hill Elementary School",'Perry_Hall=' + Perry_Hall.length);
Reisterstown[Reisterstown.length] = createMarker(new GPoint(-76.82440186,39.46406174),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Chatsworth School",'Reisterstown=' + Reisterstown.length);
Randallstown[Randallstown.length] = createMarker(new GPoint(-76.77882385,39.36920929),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Church Lane Elementary Technology",'Randallstown=' + Randallstown.length);
Cockeysville[Cockeysville.length] = createMarker(new GPoint(-76.63092804,39.47303772),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Cockeysville Middle School",'Cockeysville=' + Cockeysville.length);
Owings_Mills[Owings_Mills.length] = createMarker(new GPoint(-76.81723022,39.39022827),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Deer Park Elementary School",'Owings_Mills=' + Owings_Mills.length);
Randallstown[Randallstown.length] = createMarker(new GPoint(-76.81919861,39.38711929),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Deer Park Middle Magnet School",'Randallstown=' + Randallstown.length);
Timonium[Timonium.length] = createMarker(new GPoint(-76.61413574,39.45886993),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Dulaney High School",'Timonium=' + Timonium.length);
Upperco[Upperco.length] = createMarker(new GPoint(-76.77494812,39.60174942),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fifth District Elementary School",'Upperco=' + Upperco.length);
Reisterstown[Reisterstown.length] = createMarker(new GPoint(-76.83035278,39.46388626),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Franklin Elementary School",'Reisterstown=' + Reisterstown.length);
Reisterstown[Reisterstown.length] = createMarker(new GPoint(-76.81443024,39.44716644),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Franklin High School",'Reisterstown=' + Reisterstown.length);
Reisterstown[Reisterstown.length] = createMarker(new GPoint(-76.82964325,39.46435165),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Franklin Middle School",'Reisterstown=' + Reisterstown.length);
Reisterstown[Reisterstown.length] = createMarker(new GPoint(-76.81333923,39.46414566),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Glyndon Elementary School",'Reisterstown=' + Reisterstown.length);
Halethorpe[Halethorpe.length] = createMarker(new GPoint(-76.68614960,39.24094772),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Halethorpe Elementary School",'Halethorpe=' + Halethorpe.length);
Lutherville[Lutherville.length] = createMarker(new GPoint(-76.60152435,39.41574478),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hampton Elementary School",'Lutherville=' + Lutherville.length);
Parkton[Parkton.length] = createMarker(new GPoint(-76.65997314,39.60120392),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hereford High School",'Parkton=' + Parkton.length);
Monkton[Monkton.length] = createMarker(new GPoint(-76.65133667,39.57107925),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Hereford Middle School",'Monkton=' + Monkton.length);
Randallstown[Randallstown.length] = createMarker(new GPoint(-76.82843781,39.37513733),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hernwood Elementary School",'Randallstown=' + Randallstown.length);
Phoenix[Phoenix.length] = createMarker(new GPoint(-76.56275940,39.50966644),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jacksonville Elementary School",'Phoenix=' + Phoenix.length);
Kingsville[Kingsville.length] = createMarker(new GPoint(-76.41737366,39.45284653),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kingsville Elementary School",'Kingsville=' + Kingsville.length);
Lutherville[Lutherville.length] = createMarker(new GPoint(-76.61968231,39.42638779),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lutherville Laboratory Elementary School",'Lutherville=' + Lutherville.length);
Owings_Mills[Owings_Mills.length] = createMarker(new GPoint(-76.81525421,39.40166855),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("New Town Elementary School",'Owings_Mills=' + Owings_Mills.length);
Owings_Mills[Owings_Mills.length] = createMarker(new GPoint(-76.78299713,39.41949844),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Town High School",'Owings_Mills=' + Owings_Mills.length);
Owings_Mills[Owings_Mills.length] = createMarker(new GPoint(-76.78289795,39.41939926),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Owings Mills Elementary School",'Owings_Mills=' + Owings_Mills.length);
Owings_Mills[Owings_Mills.length] = createMarker(new GPoint(-76.79342651,39.42231750),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Owings Mills High School",'Owings_Mills=' + Owings_Mills.length);
Cockeysville[Cockeysville.length] = createMarker(new GPoint(-76.63044739,39.46284103),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Padonia International Elementary School",'Cockeysville=' + Cockeysville.length);
Timonium[Timonium.length] = createMarker(new GPoint(-76.63924408,39.44432068),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pinewood Elementary School",'Timonium=' + Timonium.length);
Towson[Towson.length] = createMarker(new GPoint(-76.57269287,39.39111328),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pleasant Plains Elementary School",'Towson=' + Towson.length);
Timonium[Timonium.length] = createMarker(new GPoint(-76.61363220,39.45471573),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pot Spring Elementary School",'Timonium=' + Timonium.length);
Freeland[Freeland.length] = createMarker(new GPoint(-76.71121979,39.66640091),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Prettyboy Elementary School",'Freeland=' + Freeland.length);
Randallstown[Randallstown.length] = createMarker(new GPoint(-76.79663849,39.36783981),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Randallstown Elementary School",'Randallstown=' + Randallstown.length);
Randallstown[Randallstown.length] = createMarker(new GPoint(-76.79660034,39.38037872),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Randallstown Evening High School",'Randallstown=' + Randallstown.length);
Randallstown[Randallstown.length] = createMarker(new GPoint(-76.79565430,39.38190842),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Randallstown High School",'Randallstown=' + Randallstown.length);
Reisterstown[Reisterstown.length] = createMarker(new GPoint(-76.81647491,39.45644379),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Reisterstown Elementary School",'Reisterstown=' + Reisterstown.length);
Towson[Towson.length] = createMarker(new GPoint(-76.64758301,39.41403198),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Riderwood Elementary School",'Towson=' + Towson.length);
Lutherville[Lutherville.length] = createMarker(new GPoint(-76.61569977,39.43213654),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Ridgely Middle School",'Lutherville=' + Lutherville.length);
Parkton[Parkton.length] = createMarker(new GPoint(-76.64585876,39.68498993),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Seventh District Elementary School",'Parkton=' + Parkton.length);
Sparks[Sparks.length] = createMarker(new GPoint(-76.66059113,39.54494476),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sparks Elementary School",'Sparks=' + Sparks.length);
Sparrows_Point[Sparrows_Point.length] = createMarker(new GPoint(-76.44383240,39.23889542),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sparrows Point High School",'Sparrows_Point=' + Sparrows_Point.length);
Owings_Mills[Owings_Mills.length] = createMarker(new GPoint(-76.79221344,39.44467545),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Timber Grove Elementary School",'Owings_Mills=' + Owings_Mills.length);
Timonium[Timonium.length] = createMarker(new GPoint(-76.61347961,39.43952179),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Timonium Elementary School",'Timonium=' + Timonium.length);
Towson[Towson.length] = createMarker(new GPoint(-76.60199738,39.39124298),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Towson High Law & Public Policy",'Towson=' + Towson.length);
Cockeysville[Cockeysville.length] = createMarker(new GPoint(-76.60767365,39.47322464),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Warren Elementary School",'Cockeysville=' + Cockeysville.length);
Pikesville[Pikesville.length] = createMarker(new GPoint(-76.69393921,39.37580872),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wellwood International Elementary School",'Pikesville=' + Pikesville.length);
Catonsville[Catonsville.length] = createMarker(new GPoint(-76.72463226,39.28790283),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Westowne Elementary School",'Catonsville=' + Catonsville.length);
Parkville[Parkville.length] = createMarker(new GPoint(-76.55286407,39.38976669),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("White Oak School",'Parkville=' + Parkville.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(Baldwin);
map.removeOverlays(Catonsville);
map.removeOverlays(Cockeysville);
map.removeOverlays(Freeland);
map.removeOverlays(Halethorpe);
map.removeOverlays(Kingsville);
map.removeOverlays(Lutherville);
map.removeOverlays(Monkton);
map.removeOverlays(Owings_Mills);
map.removeOverlays(Parkton);
map.removeOverlays(Parkville);
map.removeOverlays(Perry_Hall);
map.removeOverlays(Phoenix);
map.removeOverlays(Pikesville);
map.removeOverlays(Randallstown);
map.removeOverlays(Reisterstown);
map.removeOverlays(Sparks);
map.removeOverlays(Sparrows_Point);
map.removeOverlays(Timonium);
map.removeOverlays(Towson);
map.removeOverlays(Upperco);
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(Baldwin);map.removeOverlays(Baldwin);
map.removeOverlays(Catonsville);
map.removeOverlays(Cockeysville);
map.removeOverlays(Freeland);
map.removeOverlays(Halethorpe);
map.removeOverlays(Kingsville);
map.removeOverlays(Lutherville);
map.removeOverlays(Monkton);
map.removeOverlays(Owings_Mills);
map.removeOverlays(Parkton);
map.removeOverlays(Parkville);
map.removeOverlays(Perry_Hall);
map.removeOverlays(Phoenix);
map.removeOverlays(Pikesville);
map.removeOverlays(Randallstown);
map.removeOverlays(Reisterstown);
map.removeOverlays(Sparks);
map.removeOverlays(Sparrows_Point);
map.removeOverlays(Timonium);
map.removeOverlays(Towson);
map.removeOverlays(Upperco);
map.addOverlays(Baldwin);
centerByArray(Baldwin, false, false);
cntMarker += Baldwin.length;
map.addOverlays(Catonsville);
centerByArray(Catonsville, false, false);
cntMarker += Catonsville.length;
map.addOverlays(Cockeysville);
centerByArray(Cockeysville, false, false);
cntMarker += Cockeysville.length;
map.addOverlays(Freeland);
centerByArray(Freeland, false, false);
cntMarker += Freeland.length;
map.addOverlays(Halethorpe);
centerByArray(Halethorpe, false, false);
cntMarker += Halethorpe.length;
map.addOverlays(Kingsville);
centerByArray(Kingsville, false, false);
cntMarker += Kingsville.length;
map.addOverlays(Lutherville);
centerByArray(Lutherville, false, false);
cntMarker += Lutherville.length;
map.addOverlays(Monkton);
centerByArray(Monkton, false, false);
cntMarker += Monkton.length;
map.addOverlays(Owings_Mills);
centerByArray(Owings_Mills, false, false);
cntMarker += Owings_Mills.length;
map.addOverlays(Parkton);
centerByArray(Parkton, false, false);
cntMarker += Parkton.length;
map.addOverlays(Parkville);
centerByArray(Parkville, false, false);
cntMarker += Parkville.length;
map.addOverlays(Perry_Hall);
centerByArray(Perry_Hall, false, false);
cntMarker += Perry_Hall.length;
map.addOverlays(Phoenix);
centerByArray(Phoenix, false, false);
cntMarker += Phoenix.length;
map.addOverlays(Pikesville);
centerByArray(Pikesville, false, false);
cntMarker += Pikesville.length;
map.addOverlays(Randallstown);
centerByArray(Randallstown, false, false);
cntMarker += Randallstown.length;
map.addOverlays(Reisterstown);
centerByArray(Reisterstown, false, false);
cntMarker += Reisterstown.length;
map.addOverlays(Sparks);
centerByArray(Sparks, false, false);
cntMarker += Sparks.length;
map.addOverlays(Sparrows_Point);
centerByArray(Sparrows_Point, false, false);
cntMarker += Sparrows_Point.length;
map.addOverlays(Timonium);
centerByArray(Timonium, false, false);
cntMarker += Timonium.length;
map.addOverlays(Towson);
centerByArray(Towson, false, false);
cntMarker += Towson.length;
map.addOverlays(Upperco);
centerByArray(Upperco, false, false);
cntMarker += Upperco.length;
centerByArray(Baldwin,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');
}
}