function addMarkers(){
mySelect = document.getElementById('selection');
Forest_Hill = [];Bel_Air = [];Havre_De_Grace = [];Joppa = [];Street = [];Darlington = [];Churchville = [];Abingdon = [];Aberdeen = [];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("Churchville schools",'all=Churchville');
mySelect.options[mySelect.options.length] = new Option("Darlington schools",'all=Darlington');
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("Joppa schools",'all=Joppa');
mySelect.options[mySelect.options.length] = new Option("Street schools",'all=Street');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Forest_Hill[Forest_Hill.length] = createMarker(new GPoint(-76.38674900,39.57913700),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Advent Lutheran Elementary School",'Forest_Hill=' + Forest_Hill.length);
Bel_Air[Bel_Air.length] = createMarker(new GPoint(-76.32026500,39.59576800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Awakening Child Montessori School",'Bel_Air=' + Bel_Air.length);
Bel_Air[Bel_Air.length] = createMarker(new GPoint(-76.32352600,39.49639700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bel Air Kiddie Academy",'Bel_Air=' + Bel_Air.length);
Bel_Air[Bel_Air.length] = createMarker(new GPoint(-76.37501600,39.54296300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bel Forest Christian Academy",'Bel_Air=' + Bel_Air.length);
Havre_De_Grace[Havre_De_Grace.length] = createMarker(new GPoint(-76.14879900,39.57583000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethel Christian Academy",'Havre_De_Grace=' + Havre_De_Grace.length);
Joppa[Joppa.length] = createMarker(new GPoint(-76.33312100,39.41203700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chesapeake Christian School",'Joppa=' + Joppa.length);
Street[Street.length] = createMarker(new GPoint(-76.37850900,39.66796300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Childrens Center Of N Harford",'Street=' + Street.length);
Bel_Air[Bel_Air.length] = createMarker(new GPoint(-76.32718500,39.50262900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Emmorton Baptist Academy",'Bel_Air=' + Bel_Air.length);
Darlington[Darlington.length] = createMarker(new GPoint(-76.22091000,39.65250900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Harford Christian School",'Darlington=' + Darlington.length);
Bel_Air[Bel_Air.length] = createMarker(new GPoint(-76.34631600,39.55009600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Harford Day School",'Bel_Air=' + Bel_Air.length);
Street[Street.length] = createMarker(new GPoint(-76.37828500,39.66819400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Harford Friends School",'Street=' + Street.length);
Bel_Air[Bel_Air.length] = createMarker(new GPoint(-76.32874300,39.51321800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Harford Lutheran School",'Bel_Air=' + Bel_Air.length);
Bel_Air[Bel_Air.length] = createMarker(new GPoint(-76.34930000,39.65300000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Highlands School The",'Bel_Air=' + Bel_Air.length);
Joppa[Joppa.length] = createMarker(new GPoint(-76.37452100,39.48090200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hudson Sda School",'Joppa=' + Joppa.length);
Churchville[Churchville.length] = createMarker(new GPoint(-76.26770800,39.55463300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Monarch Montessori School",'Churchville=' + Churchville.length);
Churchville[Churchville.length] = createMarker(new GPoint(-76.25898900,39.55540500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Monarch Montessori School",'Churchville=' + Churchville.length);
Joppa[Joppa.length] = createMarker(new GPoint(-76.37387800,39.46978500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mountain Christian School",'Joppa=' + Joppa.length);
Abingdon[Abingdon.length] = createMarker(new GPoint(-76.31362500,39.48957100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Covenant Christian School",'Abingdon=' + Abingdon.length);
Bel_Air[Bel_Air.length] = createMarker(new GPoint(-76.34932000,39.54134600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Margaret Elementary School",'Bel_Air=' + Bel_Air.length);
Aberdeen[Aberdeen.length] = createMarker(new GPoint(-76.17035900,39.50799400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Joan Of Arc Elementary School",'Aberdeen=' + Aberdeen.length);
Joppa[Joppa.length] = createMarker(new GPoint(-76.34149000,39.43943600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Lutheran School",'Joppa=' + Joppa.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/////1/' + showArray);
map.removeOverlays(Aberdeen);
map.removeOverlays(Abingdon);
map.removeOverlays(Bel_Air);
map.removeOverlays(Churchville);
map.removeOverlays(Darlington);
map.removeOverlays(Forest_Hill);
map.removeOverlays(Havre_De_Grace);
map.removeOverlays(Joppa);
map.removeOverlays(Street);
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(Forest_Hill);map.removeOverlays(Aberdeen);
map.removeOverlays(Abingdon);
map.removeOverlays(Bel_Air);
map.removeOverlays(Churchville);
map.removeOverlays(Darlington);
map.removeOverlays(Forest_Hill);
map.removeOverlays(Havre_De_Grace);
map.removeOverlays(Joppa);
map.removeOverlays(Street);
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(Churchville);
centerByArray(Churchville, false, false);
cntMarker += Churchville.length;
map.addOverlays(Darlington);
centerByArray(Darlington, false, false);
cntMarker += Darlington.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(Joppa);
centerByArray(Joppa, false, false);
cntMarker += Joppa.length;
map.addOverlays(Street);
centerByArray(Street, false, false);
cntMarker += Street.length;
centerByArray(Forest_Hill,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=1&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;
}