function addMarkers(){
mySelect = document.getElementById('selection');
Columbia = [];Savage = [];Clarksville = [];Marriottsville = [];Ellicott_City = [];Glenwood = [];Woodbine = [];Fulton = [];Laurel = [];Mount_Airy = [];Elkridge = [];Cooksville = [];mySelect.options[mySelect.options.length] = new Option("Clarksville schools",'all=Clarksville');
mySelect.options[mySelect.options.length] = new Option("Columbia schools",'all=Columbia');
mySelect.options[mySelect.options.length] = new Option("Cooksville schools",'all=Cooksville');
mySelect.options[mySelect.options.length] = new Option("Elkridge schools",'all=Elkridge');
mySelect.options[mySelect.options.length] = new Option("Ellicott City schools",'all=Ellicott_City');
mySelect.options[mySelect.options.length] = new Option("Fulton schools",'all=Fulton');
mySelect.options[mySelect.options.length] = new Option("Glenwood schools",'all=Glenwood');
mySelect.options[mySelect.options.length] = new Option("Laurel schools",'all=Laurel');
mySelect.options[mySelect.options.length] = new Option("Marriottsville schools",'all=Marriottsville');
mySelect.options[mySelect.options.length] = new Option("Mount Airy schools",'all=Mount_Airy');
mySelect.options[mySelect.options.length] = new Option("Savage schools",'all=Savage');
mySelect.options[mySelect.options.length] = new Option("Woodbine schools",'all=Woodbine');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Columbia[Columbia.length] = createMarker(new GPoint(-76.87041600,39.19237600),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Atholton Adventist Academy",'Columbia=' + Columbia.length);
Columbia[Columbia.length] = createMarker(new GPoint(-76.84724700,39.20935400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bet Yeladim Inc",'Columbia=' + Columbia.length);
Savage[Savage.length] = createMarker(new GPoint(-76.82080000,39.13800000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethel Christian Academy",'Savage=' + Savage.length);
Columbia[Columbia.length] = createMarker(new GPoint(-76.88647800,39.20962800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bright Stars Learning Academy",'Columbia=' + Columbia.length);
Clarksville[Clarksville.length] = createMarker(new GPoint(-76.94500400,39.20644900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Brookfield Christian School",'Clarksville=' + Clarksville.length);
Columbia[Columbia.length] = createMarker(new GPoint(-76.86542700,39.22230300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bryant Woods Montessori Childrens House",'Columbia=' + Columbia.length);
Columbia[Columbia.length] = createMarker(new GPoint(-76.81445300,39.20693700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Celebration Christian Academy",'Columbia=' + Columbia.length);
Marriottsville[Marriottsville.length] = createMarker(new GPoint(-76.90055200,39.30006300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chapelgate Christian Academy",'Marriottsville=' + Marriottsville.length);
Columbia[Columbia.length] = createMarker(new GPoint(-76.84636200,39.21368800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Children S House Montessori",'Columbia=' + Columbia.length);
Columbia[Columbia.length] = createMarker(new GPoint(-76.81384500,39.22787800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Children's World Learning Center",'Columbia=' + Columbia.length);
Columbia[Columbia.length] = createMarker(new GPoint(-76.81962300,39.22710500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Childrens Manor School",'Columbia=' + Columbia.length);
Columbia[Columbia.length] = createMarker(new GPoint(-76.80347500,39.18307300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Children's Discovery Center",'Columbia=' + Columbia.length);
Ellicott_City[Ellicott_City.length] = createMarker(new GPoint(-76.81043100,39.24901800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Children's Manor Montessori",'Ellicott_City=' + Ellicott_City.length);
Columbia[Columbia.length] = createMarker(new GPoint(-76.87162300,39.17847400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Columbia Academy",'Columbia=' + Columbia.length);
Columbia[Columbia.length] = createMarker(new GPoint(-76.87571600,39.22270600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Columbia Montessori School",'Columbia=' + Columbia.length);
Glenwood[Glenwood.length] = createMarker(new GPoint(-77.02839500,39.28717600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cornerstone Academy Of Glenwood",'Glenwood=' + Glenwood.length);
Ellicott_City[Ellicott_City.length] = createMarker(new GPoint(-76.82656000,39.28120800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Crossroads Adventist School",'Ellicott_City=' + Ellicott_City.length);
Ellicott_City[Ellicott_City.length] = createMarker(new GPoint(-76.83253200,39.27241600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ellicott City Children's House",'Ellicott_City=' + Ellicott_City.length);
Columbia[Columbia.length] = createMarker(new GPoint(-76.86362200,39.20053700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gan Israel Day School",'Columbia=' + Columbia.length);
Ellicott_City[Ellicott_City.length] = createMarker(new GPoint(-76.95448400,39.25670800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Glenelg Country School",'Ellicott_City=' + Ellicott_City.length);
Woodbine[Woodbine.length] = createMarker(new GPoint(-77.02799900,39.32019000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Glenwood Country Day School",'Woodbine=' + Woodbine.length);
Marriottsville[Marriottsville.length] = createMarker(new GPoint(-76.89479500,39.30799200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Goddard School In Marriottsville, The",'Marriottsville=' + Marriottsville.length);
Marriottsville[Marriottsville.length] = createMarker(new GPoint(-76.89492200,39.30790900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Goddard School of Marriottsville",'Marriottsville=' + Marriottsville.length);
Columbia[Columbia.length] = createMarker(new GPoint(-76.81569900,39.23262400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Goddard School, The",'Columbia=' + Columbia.length);
Columbia[Columbia.length] = createMarker(new GPoint(-76.88101000,39.19349500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Goddard School, The",'Columbia=' + Columbia.length);
Fulton[Fulton.length] = createMarker(new GPoint(-76.94100900,39.17661600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("High Road Academy",'Fulton=' + Fulton.length);
Columbia[Columbia.length] = createMarker(new GPoint(-76.84979100,39.20235700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Julia Brown Montessori School",'Columbia=' + Columbia.length);
Laurel[Laurel.length] = createMarker(new GPoint(-76.84011300,39.10999100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Julia Brown Montessori Schools",'Laurel=' + Laurel.length);
Ellicott_City[Ellicott_City.length] = createMarker(new GPoint(-76.86280500,39.28194000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Kid's Place",'Ellicott_City=' + Ellicott_City.length);
Columbia[Columbia.length] = createMarker(new GPoint(-76.87694500,39.21567500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kindercare",'Columbia=' + Columbia.length);
Ellicott_City[Ellicott_City.length] = createMarker(new GPoint(-76.80104100,39.27766500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Linwood Center",'Ellicott_City=' + Ellicott_City.length);
Columbia[Columbia.length] = createMarker(new GPoint(-76.86575300,39.22233700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lornwood Day Care & Gifted Center",'Columbia=' + Columbia.length);
Columbia[Columbia.length] = createMarker(new GPoint(-76.84399700,39.18574000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lornwood School",'Columbia=' + Columbia.length);
Columbia[Columbia.length] = createMarker(new GPoint(-76.82020800,39.23248800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Love Of Learning Montessori School",'Columbia=' + Columbia.length);
Mount_Airy[Mount_Airy.length] = createMarker(new GPoint(-77.09643000,39.34864700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mount Airy Christian Academy",'Mount_Airy=' + Mount_Airy.length);
Ellicott_City[Ellicott_City.length] = createMarker(new GPoint(-76.76953100,39.23836100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of Perpetual Help School",'Ellicott_City=' + Ellicott_City.length);
Marriottsville[Marriottsville.length] = createMarker(new GPoint(-76.89526000,39.33576500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Peter Pan Learning Center",'Marriottsville=' + Marriottsville.length);
Laurel[Laurel.length] = createMarker(new GPoint(-76.82772200,39.11141800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Phillips School - Laurel",'Laurel=' + Laurel.length);
Ellicott_City[Ellicott_City.length] = createMarker(new GPoint(-76.82971400,39.28339600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Resurrection-St. Paul School",'Ellicott_City=' + Ellicott_City.length);
Elkridge[Elkridge.length] = createMarker(new GPoint(-76.71562300,39.21076500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Augustine",'Elkridge=' + Elkridge.length);
Clarksville[Clarksville.length] = createMarker(new GPoint(-76.94333200,39.20431600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Louis School",'Clarksville=' + Clarksville.length);
Ellicott_City[Ellicott_City.length] = createMarker(new GPoint(-76.82996800,39.27268100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Johns Parish Day School",'Ellicott_City=' + Ellicott_City.length);
Ellicott_City[Ellicott_City.length] = createMarker(new GPoint(-76.77396000,39.23220200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity School",'Ellicott_City=' + Ellicott_City.length);
Cooksville[Cooksville.length] = createMarker(new GPoint(-77.00381200,39.31925200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Woodmont Academy",'Cooksville=' + Cooksville.length);
Columbia[Columbia.length] = createMarker(new GPoint(-76.81962300,39.22710500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Young Care Inc",'Columbia=' + Columbia.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(Clarksville);
map.removeOverlays(Columbia);
map.removeOverlays(Cooksville);
map.removeOverlays(Elkridge);
map.removeOverlays(Ellicott_City);
map.removeOverlays(Fulton);
map.removeOverlays(Glenwood);
map.removeOverlays(Laurel);
map.removeOverlays(Marriottsville);
map.removeOverlays(Mount_Airy);
map.removeOverlays(Savage);
map.removeOverlays(Woodbine);
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(Columbia);map.removeOverlays(Clarksville);
map.removeOverlays(Columbia);
map.removeOverlays(Cooksville);
map.removeOverlays(Elkridge);
map.removeOverlays(Ellicott_City);
map.removeOverlays(Fulton);
map.removeOverlays(Glenwood);
map.removeOverlays(Laurel);
map.removeOverlays(Marriottsville);
map.removeOverlays(Mount_Airy);
map.removeOverlays(Savage);
map.removeOverlays(Woodbine);
map.addOverlays(Clarksville);
centerByArray(Clarksville, false, false);
cntMarker += Clarksville.length;
map.addOverlays(Columbia);
centerByArray(Columbia, false, false);
cntMarker += Columbia.length;
map.addOverlays(Cooksville);
centerByArray(Cooksville, false, false);
cntMarker += Cooksville.length;
map.addOverlays(Elkridge);
centerByArray(Elkridge, false, false);
cntMarker += Elkridge.length;
map.addOverlays(Ellicott_City);
centerByArray(Ellicott_City, false, false);
cntMarker += Ellicott_City.length;
map.addOverlays(Fulton);
centerByArray(Fulton, false, false);
cntMarker += Fulton.length;
map.addOverlays(Glenwood);
centerByArray(Glenwood, false, false);
cntMarker += Glenwood.length;
map.addOverlays(Laurel);
centerByArray(Laurel, false, false);
cntMarker += Laurel.length;
map.addOverlays(Marriottsville);
centerByArray(Marriottsville, false, false);
cntMarker += Marriottsville.length;
map.addOverlays(Mount_Airy);
centerByArray(Mount_Airy, false, false);
cntMarker += Mount_Airy.length;
map.addOverlays(Savage);
centerByArray(Savage, false, false);
cntMarker += Savage.length;
map.addOverlays(Woodbine);
centerByArray(Woodbine, false, false);
cntMarker += Woodbine.length;
centerByArray(Columbia,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;
}