function addMarkers(){
mySelect = document.getElementById('selection');
Albany = [];Rock_Spring = [];Dunwoody = [];Atlanta = [];Columbus = [];Gainesville = [];Calhoun = [];Ellijay = [];Lagrange = [];Dalton = [];East_Point = [];Savannah = [];Pooler = [];Zebulon = [];Brunswick = [];Wildwood = [];mySelect.options[mySelect.options.length] = new Option("Albany schools",'all=Albany');
mySelect.options[mySelect.options.length] = new Option("Atlanta schools",'all=Atlanta');
mySelect.options[mySelect.options.length] = new Option("Brunswick schools",'all=Brunswick');
mySelect.options[mySelect.options.length] = new Option("Calhoun schools",'all=Calhoun');
mySelect.options[mySelect.options.length] = new Option("Columbus schools",'all=Columbus');
mySelect.options[mySelect.options.length] = new Option("Dalton schools",'all=Dalton');
mySelect.options[mySelect.options.length] = new Option("Dunwoody schools",'all=Dunwoody');
mySelect.options[mySelect.options.length] = new Option("East Point schools",'all=East_Point');
mySelect.options[mySelect.options.length] = new Option("Ellijay schools",'all=Ellijay');
mySelect.options[mySelect.options.length] = new Option("Gainesville schools",'all=Gainesville');
mySelect.options[mySelect.options.length] = new Option("Lagrange schools",'all=Lagrange');
mySelect.options[mySelect.options.length] = new Option("Pooler schools",'all=Pooler');
mySelect.options[mySelect.options.length] = new Option("Rock Spring schools",'all=Rock_Spring');
mySelect.options[mySelect.options.length] = new Option("Savannah schools",'all=Savannah');
mySelect.options[mySelect.options.length] = new Option("Wildwood schools",'all=Wildwood');
mySelect.options[mySelect.options.length] = new Option("Zebulon schools",'all=Zebulon');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Albany[Albany.length] = createMarker(new GPoint(-84.29550000,31.52210000),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Albany Community Seventh Day",'Albany=' + Albany.length);
Albany[Albany.length] = createMarker(new GPoint(-84.29550000,31.52210000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Albany Community Sda Church",'Albany=' + Albany.length);
Rock_Spring[Rock_Spring.length] = createMarker(new GPoint(-85.22280000,34.81000000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Alice M Daley Adventist School",'Rock_Spring=' + Rock_Spring.length);
Dunwoody[Dunwoody.length] = createMarker(new GPoint(-84.32707300,33.93864900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Atlanta North School Of Seventh-day Adventists",'Dunwoody=' + Dunwoody.length);
Atlanta[Atlanta.length] = createMarker(new GPoint(-84.46993400,33.76647200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Berean Christian Jr Academy",'Atlanta=' + Atlanta.length);
Columbus[Columbus.length] = createMarker(new GPoint(-84.92437400,32.54009100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Columbus Seventh Day Adventist",'Columbus=' + Columbus.length);
Albany[Albany.length] = createMarker(new GPoint(-84.11404600,31.57624600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Emanuel Sda Jr Academy",'Albany=' + Albany.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-83.81550300,34.30635200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gainesville Christian School",'Gainesville=' + Gainesville.length);
Calhoun[Calhoun.length] = createMarker(new GPoint(-85.01960500,34.46329600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Georgia-cumberland Academy",'Calhoun=' + Calhoun.length);
Atlanta[Atlanta.length] = createMarker(new GPoint(-84.42560000,33.75690000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Greater Atlanta Adventist Academy",'Atlanta=' + Atlanta.length);
Ellijay[Ellijay.length] = createMarker(new GPoint(-84.53510000,34.68440000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Josephine Edwards Christian School",'Ellijay=' + Ellijay.length);
Lagrange[Lagrange.length] = createMarker(new GPoint(-84.98690000,33.03160000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lagrange Seventh-day Adventist Church School",'Lagrange=' + Lagrange.length);
Dalton[Dalton.length] = createMarker(new GPoint(-84.99292700,34.76491500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Learning Tree Elementary School",'Dalton=' + Dalton.length);
East_Point[East_Point.length] = createMarker(new GPoint(-84.47740200,33.66441100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mount Olive Early Learning Center",'East_Point=' + East_Point.length);
Savannah[Savannah.length] = createMarker(new GPoint(-81.11199100,32.04962900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ramah Junior Academy",'Savannah=' + Savannah.length);
Pooler[Pooler.length] = createMarker(new GPoint(-81.24359900,32.15382500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Savannah Adventist Christian School",'Pooler=' + Pooler.length);
Columbus[Columbus.length] = createMarker(new GPoint(-84.97066500,32.45949600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Shepherd Drive Sda School",'Columbus=' + Columbus.length);
Zebulon[Zebulon.length] = createMarker(new GPoint(-84.37097300,33.05879800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Son-shine Christian Academy",'Zebulon=' + Zebulon.length);
Brunswick[Brunswick.length] = createMarker(new GPoint(-81.49350600,31.15846600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Temple Of Truth Christian Community School",'Brunswick=' + Brunswick.length);
Wildwood[Wildwood.length] = createMarker(new GPoint(-85.42755700,34.98229200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wildwood Adventist Elementary School",'Wildwood=' + Wildwood.length);
map.removeOverlays(Albany);
map.removeOverlays(Atlanta);
map.removeOverlays(Brunswick);
map.removeOverlays(Calhoun);
map.removeOverlays(Columbus);
map.removeOverlays(Dalton);
map.removeOverlays(Dunwoody);
map.removeOverlays(East_Point);
map.removeOverlays(Ellijay);
map.removeOverlays(Gainesville);
map.removeOverlays(Lagrange);
map.removeOverlays(Pooler);
map.removeOverlays(Rock_Spring);
map.removeOverlays(Savannah);
map.removeOverlays(Wildwood);
map.removeOverlays(Zebulon);
setTimeout(function(){map.addOverlays(Albany)},1000);
setTimeout(function(){map.addOverlays(Atlanta)},1000);
setTimeout(function(){map.addOverlays(Brunswick)},1000);
setTimeout(function(){map.addOverlays(Calhoun)},1000);
setTimeout(function(){map.addOverlays(Columbus)},1000);
setTimeout(function(){map.addOverlays(Dalton)},1000);
setTimeout(function(){map.addOverlays(Dunwoody)},1000);
setTimeout(function(){map.addOverlays(East_Point)},1000);
setTimeout(function(){map.addOverlays(Ellijay)},1000);
setTimeout(function(){map.addOverlays(Gainesville)},1000);
setTimeout(function(){map.addOverlays(Lagrange)},1000);
setTimeout(function(){map.addOverlays(Pooler)},1000);
setTimeout(function(){map.addOverlays(Rock_Spring)},1000);
setTimeout(function(){map.addOverlays(Savannah)},1000);
setTimeout(function(){map.addOverlays(Wildwood)},1000);
setTimeout(function(){map.addOverlays(Zebulon)},1000);
maxLng = -81.11199100;
maxLat = 34.98229200;
minLng = -85.42755700;
minLat = 31.15846600;
reCenterMap();
} // 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//////' + showArray);
map.removeOverlays(Albany);
map.removeOverlays(Atlanta);
map.removeOverlays(Brunswick);
map.removeOverlays(Calhoun);
map.removeOverlays(Columbus);
map.removeOverlays(Dalton);
map.removeOverlays(Dunwoody);
map.removeOverlays(East_Point);
map.removeOverlays(Ellijay);
map.removeOverlays(Gainesville);
map.removeOverlays(Lagrange);
map.removeOverlays(Pooler);
map.removeOverlays(Rock_Spring);
map.removeOverlays(Savannah);
map.removeOverlays(Wildwood);
map.removeOverlays(Zebulon);
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(Albany);map.removeOverlays(Albany);
map.removeOverlays(Atlanta);
map.removeOverlays(Brunswick);
map.removeOverlays(Calhoun);
map.removeOverlays(Columbus);
map.removeOverlays(Dalton);
map.removeOverlays(Dunwoody);
map.removeOverlays(East_Point);
map.removeOverlays(Ellijay);
map.removeOverlays(Gainesville);
map.removeOverlays(Lagrange);
map.removeOverlays(Pooler);
map.removeOverlays(Rock_Spring);
map.removeOverlays(Savannah);
map.removeOverlays(Wildwood);
map.removeOverlays(Zebulon);
map.addOverlays(Albany);
centerByArray(Albany, false, false);
cntMarker += Albany.length;
map.addOverlays(Atlanta);
centerByArray(Atlanta, false, false);
cntMarker += Atlanta.length;
map.addOverlays(Brunswick);
centerByArray(Brunswick, false, false);
cntMarker += Brunswick.length;
map.addOverlays(Calhoun);
centerByArray(Calhoun, false, false);
cntMarker += Calhoun.length;
map.addOverlays(Columbus);
centerByArray(Columbus, false, false);
cntMarker += Columbus.length;
map.addOverlays(Dalton);
centerByArray(Dalton, false, false);
cntMarker += Dalton.length;
map.addOverlays(Dunwoody);
centerByArray(Dunwoody, false, false);
cntMarker += Dunwoody.length;
map.addOverlays(East_Point);
centerByArray(East_Point, false, false);
cntMarker += East_Point.length;
map.addOverlays(Ellijay);
centerByArray(Ellijay, false, false);
cntMarker += Ellijay.length;
map.addOverlays(Gainesville);
centerByArray(Gainesville, false, false);
cntMarker += Gainesville.length;
map.addOverlays(Lagrange);
centerByArray(Lagrange, false, false);
cntMarker += Lagrange.length;
map.addOverlays(Pooler);
centerByArray(Pooler, false, false);
cntMarker += Pooler.length;
map.addOverlays(Rock_Spring);
centerByArray(Rock_Spring, false, false);
cntMarker += Rock_Spring.length;
map.addOverlays(Savannah);
centerByArray(Savannah, false, false);
cntMarker += Savannah.length;
map.addOverlays(Wildwood);
centerByArray(Wildwood, false, false);
cntMarker += Wildwood.length;
map.addOverlays(Zebulon);
centerByArray(Zebulon, false, false);
cntMarker += Zebulon.length;
centerByArray(Albany,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///7728,7714,7544,7674,33928,7527,7675,33927,33926,7987,7620,7928,7790,7544,33929,7674,7709,7781,7927,7528,7909,33928,7937,/all');
//window.open('/map.php?type=2&schools=7728,7714,7544,7674,33928,7527,7675,33927,33926,7987,7620,7928,7790,7544,33929,7674,7709,7781,7927,7528,7909,33928,7937,&school_level=&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;
}