function addMarkers()
{
mySelect = document.getElementById('selection');
Aberdeen = [];Abingdon = [];Bel_Air = [];Belcamp = [];Churchville = [];Darlington = [];Edgewood = [];Street = [];Fallston = [];Forest_Hill = [];Havre_De_Grace = [];Jarrettsville = [];Joppa = [];White_Hall = [];Pylesville = [];mySelect.options[mySelect.options.length] = new Option("Aberdeen schools",'all=Aberdeen');
mySelect.options[mySelect.options.length] = new Option("Abingdon schools",'all=Abingdon');
mySelect.options[mySelect.options.length] = new Option("Bel Air schools",'all=Bel_Air');
mySelect.options[mySelect.options.length] = new Option("Belcamp schools",'all=Belcamp');
mySelect.options[mySelect.options.length] = new Option("Churchville schools",'all=Churchville');
mySelect.options[mySelect.options.length] = new Option("Darlington schools",'all=Darlington');
mySelect.options[mySelect.options.length] = new Option("Edgewood schools",'all=Edgewood');
mySelect.options[mySelect.options.length] = new Option("Fallston schools",'all=Fallston');
mySelect.options[mySelect.options.length] = new Option("Forest Hill schools",'all=Forest_Hill');
mySelect.options[mySelect.options.length] = new Option("Havre De Grace schools",'all=Havre_De_Grace');
mySelect.options[mySelect.options.length] = new Option("Jarrettsville schools",'all=Jarrettsville');
mySelect.options[mySelect.options.length] = new Option("Joppa schools",'all=Joppa');
mySelect.options[mySelect.options.length] = new Option("Pylesville schools",'all=Pylesville');
mySelect.options[mySelect.options.length] = new Option("Street schools",'all=Street');
mySelect.options[mySelect.options.length] = new Option("White Hall schools",'all=White_Hall');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Aberdeen[Aberdeen.length] = createMarker(new GPoint(-76.17172241,39.51770020),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Aberdeen High School",'Aberdeen=' + Aberdeen.length);
Aberdeen[Aberdeen.length] = createMarker(new GPoint(-76.16711426,39.51530457),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Aberdeen Middle School",'Aberdeen=' + Aberdeen.length);
Abingdon[Abingdon.length] = createMarker(new GPoint(-76.32728577,39.47822571),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Abingdon Elementary School",'Abingdon=' + Abingdon.length);
Aberdeen[Aberdeen.length] = createMarker(new GPoint(-76.29229736,39.42286682),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Alternative Center",'Aberdeen=' + Aberdeen.length);
Aberdeen[Aberdeen.length] = createMarker(new GPoint(-76.17172241,39.51770020),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Alternative Center/aberdeen High/hsp High School",'Aberdeen=' + Aberdeen.length);
Aberdeen[Aberdeen.length] = createMarker(new GPoint(-76.17024231,39.51252747),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bakerfield Elementary School",'Aberdeen=' + Aberdeen.length);
Bel_Air[Bel_Air.length] = createMarker(new GPoint(-76.35021973,39.53809738),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bel Air Elementary School",'Bel_Air=' + Bel_Air.length);
Bel_Air[Bel_Air.length] = createMarker(new GPoint(-76.34555054,39.53078079),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bel Air High School",'Bel_Air=' + Bel_Air.length);
Bel_Air[Bel_Air.length] = createMarker(new GPoint(-76.34436035,39.52810669),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bel Air Middle School",'Bel_Air=' + Bel_Air.length);
Bel_Air[Bel_Air.length] = createMarker(new GPoint(-76.33300781,39.56225586),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("C. Milton Wright High School",'Bel_Air=' + Bel_Air.length);
Belcamp[Belcamp.length] = createMarker(new GPoint(-76.23858643,39.47594452),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Church Creek Elementary School",'Belcamp=' + Belcamp.length);
Churchville[Churchville.length] = createMarker(new GPoint(-76.24851990,39.56037140),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Churchville Elementary School",'Churchville=' + Churchville.length);
Darlington[Darlington.length] = createMarker(new GPoint(-76.20209503,39.63868332),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Darlington Elementary School",'Darlington=' + Darlington.length);
Edgewood[Edgewood.length] = createMarker(new GPoint(-76.29244232,39.42292786),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Deerfield Elementary School",'Edgewood=' + Edgewood.length);
Street[Street.length] = createMarker(new GPoint(-76.38082500,39.66660400),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dublin Elementary School",'Street=' + Street.length);
Edgewood[Edgewood.length] = createMarker(new GPoint(-76.30329895,39.42195511),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Edgewood Elementary School",'Edgewood=' + Edgewood.length);
Edgewood[Edgewood.length] = createMarker(new GPoint(-76.29070282,39.42365646),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Edgewood High School",'Edgewood=' + Edgewood.length);
Edgewood[Edgewood.length] = createMarker(new GPoint(-76.29226685,39.42302322),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Edgewood Middle School",'Edgewood=' + Edgewood.length);
Bel_Air[Bel_Air.length] = createMarker(new GPoint(-76.34556580,39.50868988),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Emmorton Elementary School",'Bel_Air=' + Bel_Air.length);
Fallston[Fallston.length] = createMarker(new GPoint(-76.41402435,39.52410126),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fallston High School",'Fallston=' + Fallston.length);
Fallston[Fallston.length] = createMarker(new GPoint(-76.41406250,39.52404022),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Fallston Middle School",'Fallston=' + Fallston.length);
Forest_Hill[Forest_Hill.length] = createMarker(new GPoint(-76.38777924,39.58547974),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Forest Hill Elementary School",'Forest_Hill=' + Forest_Hill.length);
Forest_Hill[Forest_Hill.length] = createMarker(new GPoint(-76.38578033,39.56683731),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Forest Lakes Elementary School",'Forest_Hill=' + Forest_Hill.length);
Bel_Air[Bel_Air.length] = createMarker(new GPoint(-76.32564545,39.55421066),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fountain Green Elementary School",'Bel_Air=' + Bel_Air.length);
Aberdeen[Aberdeen.length] = createMarker(new GPoint(-76.17789459,39.50358582),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("G. Lisby Elementary At Hillsdale",'Aberdeen=' + Aberdeen.length);
Aberdeen[Aberdeen.length] = createMarker(new GPoint(-76.15796661,39.50657272),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Halls Cross Roads Elementary School",'Aberdeen=' + Aberdeen.length);
Bel_Air[Bel_Air.length] = createMarker(new GPoint(-76.28640747,39.55927658),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Harford Technical High School",'Bel_Air=' + Bel_Air.length);
Havre_De_Grace[Havre_De_Grace.length] = createMarker(new GPoint(-76.09677124,39.54234695),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Havre De Grace Elementary School",'Havre_De_Grace=' + Havre_De_Grace.length);
Havre_De_Grace[Havre_De_Grace.length] = createMarker(new GPoint(-76.09522247,39.54755020),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Havre De Grace High School",'Havre_De_Grace=' + Havre_De_Grace.length);
Havre_De_Grace[Havre_De_Grace.length] = createMarker(new GPoint(-76.10792542,39.54683304),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Havre De Grace Middle School",'Havre_De_Grace=' + Havre_De_Grace.length);
Bel_Air[Bel_Air.length] = createMarker(new GPoint(-76.34783936,39.57779312),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hickory Elementary School",'Bel_Air=' + Bel_Air.length);
Bel_Air[Bel_Air.length] = createMarker(new GPoint(-76.33985138,39.52654266),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Homestead/wakefield Elementary School",'Bel_Air=' + Bel_Air.length);
Jarrettsville[Jarrettsville.length] = createMarker(new GPoint(-76.48742676,39.60313034),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jarrettsville Elementary School",'Jarrettsville=' + Jarrettsville.length);
Bel_Air[Bel_Air.length] = createMarker(new GPoint(-76.28659821,39.55503464),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("John Archer School",'Bel_Air=' + Bel_Air.length);
Joppa[Joppa.length] = createMarker(new GPoint(-76.36293793,39.41942978),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Joppatowne Elementary School",'Joppa=' + Joppa.length);
Joppa[Joppa.length] = createMarker(new GPoint(-76.35103607,39.41098022),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Joppatowne High School",'Joppa=' + Joppa.length);
Joppa[Joppa.length] = createMarker(new GPoint(-76.33343506,39.41181946),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Magnolia Elementary School",'Joppa=' + Joppa.length);
Joppa[Joppa.length] = createMarker(new GPoint(-76.33162689,39.40735626),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Magnolia Middle School",'Joppa=' + Joppa.length);
Havre_De_Grace[Havre_De_Grace.length] = createMarker(new GPoint(-76.10677338,39.56213760),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Meadowvale Elementary School",'Havre_De_Grace=' + Havre_De_Grace.length);
White_Hall[White_Hall.length] = createMarker(new GPoint(-76.53267670,39.69995499),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Norrisville Elementary School",'White_Hall=' + White_Hall.length);
Jarrettsville[Jarrettsville.length] = createMarker(new GPoint(-76.45953369,39.63354111),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("North Bend Elementary School",'Jarrettsville=' + Jarrettsville.length);
Pylesville[Pylesville.length] = createMarker(new GPoint(-76.40776062,39.67309952),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("North Harford Elementary School",'Pylesville=' + Pylesville.length);
Pylesville[Pylesville.length] = createMarker(new GPoint(-76.40399170,39.67539597),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Harford High School",'Pylesville=' + Pylesville.length);
Pylesville[Pylesville.length] = createMarker(new GPoint(-76.40841675,39.67272949),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("North Harford Middle School",'Pylesville=' + Pylesville.length);
Bel_Air[Bel_Air.length] = createMarker(new GPoint(-76.29159546,39.55526352),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Prospect Mill Elementary School",'Bel_Air=' + Bel_Air.length);
Bel_Air[Bel_Air.length] = createMarker(new GPoint(-76.33108521,39.51531982),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ring Factory Elementary School",'Bel_Air=' + Bel_Air.length);
Joppa[Joppa.length] = createMarker(new GPoint(-76.33903503,39.39979553),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Riverside Elementary School",'Joppa=' + Joppa.length);
Havre_De_Grace[Havre_De_Grace.length] = createMarker(new GPoint(-76.13740540,39.52311707),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Roye-williams Elementary School",'Havre_De_Grace=' + Havre_De_Grace.length);
Bel_Air[Bel_Air.length] = createMarker(new GPoint(-76.33024597,39.54676819),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Southampton Middle School",'Bel_Air=' + Bel_Air.length);
Abingdon[Abingdon.length] = createMarker(new GPoint(-76.27738953,39.46200943),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("William Paca/old Post Road Elementary School",'Abingdon=' + Abingdon.length);
Abingdon[Abingdon.length] = createMarker(new GPoint(-76.30714417,39.48194885),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("William S. James Elementary School",'Abingdon=' + Abingdon.length);
Fallston[Fallston.length] = createMarker(new GPoint(-76.44232941,39.53046036),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Youths Benefit Elementary School",'Fallston=' + Fallston.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(Aberdeen);
map.removeOverlays(Abingdon);
map.removeOverlays(Bel_Air);
map.removeOverlays(Belcamp);
map.removeOverlays(Churchville);
map.removeOverlays(Darlington);
map.removeOverlays(Edgewood);
map.removeOverlays(Fallston);
map.removeOverlays(Forest_Hill);
map.removeOverlays(Havre_De_Grace);
map.removeOverlays(Jarrettsville);
map.removeOverlays(Joppa);
map.removeOverlays(Pylesville);
map.removeOverlays(Street);
map.removeOverlays(White_Hall);
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(Aberdeen);map.removeOverlays(Aberdeen);
map.removeOverlays(Abingdon);
map.removeOverlays(Bel_Air);
map.removeOverlays(Belcamp);
map.removeOverlays(Churchville);
map.removeOverlays(Darlington);
map.removeOverlays(Edgewood);
map.removeOverlays(Fallston);
map.removeOverlays(Forest_Hill);
map.removeOverlays(Havre_De_Grace);
map.removeOverlays(Jarrettsville);
map.removeOverlays(Joppa);
map.removeOverlays(Pylesville);
map.removeOverlays(Street);
map.removeOverlays(White_Hall);
map.addOverlays(Aberdeen);
centerByArray(Aberdeen, false, false);
cntMarker += Aberdeen.length;
map.addOverlays(Abingdon);
centerByArray(Abingdon, false, false);
cntMarker += Abingdon.length;
map.addOverlays(Bel_Air);
centerByArray(Bel_Air, false, false);
cntMarker += Bel_Air.length;
map.addOverlays(Belcamp);
centerByArray(Belcamp, false, false);
cntMarker += Belcamp.length;
map.addOverlays(Churchville);
centerByArray(Churchville, false, false);
cntMarker += Churchville.length;
map.addOverlays(Darlington);
centerByArray(Darlington, false, false);
cntMarker += Darlington.length;
map.addOverlays(Edgewood);
centerByArray(Edgewood, false, false);
cntMarker += Edgewood.length;
map.addOverlays(Fallston);
centerByArray(Fallston, false, false);
cntMarker += Fallston.length;
map.addOverlays(Forest_Hill);
centerByArray(Forest_Hill, false, false);
cntMarker += Forest_Hill.length;
map.addOverlays(Havre_De_Grace);
centerByArray(Havre_De_Grace, false, false);
cntMarker += Havre_De_Grace.length;
map.addOverlays(Jarrettsville);
centerByArray(Jarrettsville, false, false);
cntMarker += Jarrettsville.length;
map.addOverlays(Joppa);
centerByArray(Joppa, false, false);
cntMarker += Joppa.length;
map.addOverlays(Pylesville);
centerByArray(Pylesville, false, false);
cntMarker += Pylesville.length;
map.addOverlays(Street);
centerByArray(Street, false, false);
cntMarker += Street.length;
map.addOverlays(White_Hall);
centerByArray(White_Hall, false, false);
cntMarker += White_Hall.length;
centerByArray(Aberdeen,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');
}
}