function addMarkers(){
mySelect = document.getElementById('selection');
Atlanta = [];Gainesville = [];Roswell = [];Augusta = [];Macon = [];Marietta = [];Decatur = [];Senoia = [];Rabun_Gap = [];Tallulah_Falls = [];Perry = [];College_Park = [];mySelect.options[mySelect.options.length] = new Option("Atlanta schools",'all=Atlanta');
mySelect.options[mySelect.options.length] = new Option("Augusta schools",'all=Augusta');
mySelect.options[mySelect.options.length] = new Option("College Park schools",'all=College_Park');
mySelect.options[mySelect.options.length] = new Option("Decatur schools",'all=Decatur');
mySelect.options[mySelect.options.length] = new Option("Gainesville schools",'all=Gainesville');
mySelect.options[mySelect.options.length] = new Option("Macon schools",'all=Macon');
mySelect.options[mySelect.options.length] = new Option("Marietta schools",'all=Marietta');
mySelect.options[mySelect.options.length] = new Option("Perry schools",'all=Perry');
mySelect.options[mySelect.options.length] = new Option("Rabun Gap schools",'all=Rabun_Gap');
mySelect.options[mySelect.options.length] = new Option("Roswell schools",'all=Roswell');
mySelect.options[mySelect.options.length] = new Option("Senoia schools",'all=Senoia');
mySelect.options[mySelect.options.length] = new Option("Tallulah Falls schools",'all=Tallulah_Falls');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Atlanta[Atlanta.length] = createMarker(new GPoint(-84.42629700,33.84496000),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Atlanta Girls' School",'Atlanta=' + Atlanta.length);
Atlanta[Atlanta.length] = createMarker(new GPoint(-84.30255900,33.98375500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Brandon Hall School",'Atlanta=' + Atlanta.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-83.86276000,34.26094000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Brenau Academy",'Gainesville=' + Gainesville.length);
Roswell[Roswell.length] = createMarker(new GPoint(-84.31352800,34.01839100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Brimarsh Academy",'Roswell=' + Roswell.length);
Atlanta[Atlanta.length] = createMarker(new GPoint(-84.38587400,33.76439300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Canterbury School",'Atlanta=' + Atlanta.length);
Augusta[Augusta.length] = createMarker(new GPoint(-82.00772100,33.48985500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Curtis Baptist School (pk-12)",'Augusta=' + Augusta.length);
Augusta[Augusta.length] = createMarker(new GPoint(-82.00738200,33.45392000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ebenezer Sda School",'Augusta=' + Augusta.length);
Macon[Macon.length] = createMarker(new GPoint(-83.66633900,32.80623700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ernest Saloom Academy",'Macon=' + Macon.length);
Marietta[Marietta.length] = createMarker(new GPoint(-84.52776000,34.01081900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lafayette Academy",'Marietta=' + Marietta.length);
Decatur[Decatur.length] = createMarker(new GPoint(-84.29246300,33.76051800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lullwater School Inc",'Decatur=' + Decatur.length);
Senoia[Senoia.length] = createMarker(new GPoint(-84.58830300,33.29721900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Peachtree Baptist Academy",'Senoia=' + Senoia.length);
Rabun_Gap[Rabun_Gap.length] = createMarker(new GPoint(-83.39088800,34.96181200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rabun-Gap Nacoochee School",'Rabun_Gap=' + Rabun_Gap.length);
Tallulah_Falls[Tallulah_Falls.length] = createMarker(new GPoint(-83.39083900,34.72804000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tallulah Falls School",'Tallulah_Falls=' + Tallulah_Falls.length);
Atlanta[Atlanta.length] = createMarker(new GPoint(-84.44761100,33.86422800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity School, Inc",'Atlanta=' + Atlanta.length);
Perry[Perry.length] = createMarker(new GPoint(-83.73120000,32.46300000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Westfield Schools",'Perry=' + Perry.length);
Augusta[Augusta.length] = createMarker(new GPoint(-82.04377100,33.48863300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Westminster Schools Of Augusta",'Augusta=' + Augusta.length);
College_Park[College_Park.length] = createMarker(new GPoint(-84.44334900,33.66266300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Woodward Academy",'College_Park=' + College_Park.length);
Macon[Macon.length] = createMarker(new GPoint(-83.70723600,32.80293500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("World Of Faith Christian Academy",'Macon=' + Macon.length);
map.removeOverlays(Atlanta);
map.removeOverlays(Augusta);
map.removeOverlays(College_Park);
map.removeOverlays(Decatur);
map.removeOverlays(Gainesville);
map.removeOverlays(Macon);
map.removeOverlays(Marietta);
map.removeOverlays(Perry);
map.removeOverlays(Rabun_Gap);
map.removeOverlays(Roswell);
map.removeOverlays(Senoia);
map.removeOverlays(Tallulah_Falls);
setTimeout(function(){map.addOverlays(Atlanta)},1000);
setTimeout(function(){map.addOverlays(Augusta)},1000);
setTimeout(function(){map.addOverlays(College_Park)},1000);
setTimeout(function(){map.addOverlays(Decatur)},1000);
setTimeout(function(){map.addOverlays(Gainesville)},1000);
setTimeout(function(){map.addOverlays(Macon)},1000);
setTimeout(function(){map.addOverlays(Marietta)},1000);
setTimeout(function(){map.addOverlays(Perry)},1000);
setTimeout(function(){map.addOverlays(Rabun_Gap)},1000);
setTimeout(function(){map.addOverlays(Roswell)},1000);
setTimeout(function(){map.addOverlays(Senoia)},1000);
setTimeout(function(){map.addOverlays(Tallulah_Falls)},1000);
maxLng = -82.00738200;
maxLat = 34.96181200;
minLng = -84.58830300;
minLat = 32.46300000;
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(Atlanta);
map.removeOverlays(Augusta);
map.removeOverlays(College_Park);
map.removeOverlays(Decatur);
map.removeOverlays(Gainesville);
map.removeOverlays(Macon);
map.removeOverlays(Marietta);
map.removeOverlays(Perry);
map.removeOverlays(Rabun_Gap);
map.removeOverlays(Roswell);
map.removeOverlays(Senoia);
map.removeOverlays(Tallulah_Falls);
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(Atlanta);map.removeOverlays(Atlanta);
map.removeOverlays(Augusta);
map.removeOverlays(College_Park);
map.removeOverlays(Decatur);
map.removeOverlays(Gainesville);
map.removeOverlays(Macon);
map.removeOverlays(Marietta);
map.removeOverlays(Perry);
map.removeOverlays(Rabun_Gap);
map.removeOverlays(Roswell);
map.removeOverlays(Senoia);
map.removeOverlays(Tallulah_Falls);
map.addOverlays(Atlanta);
centerByArray(Atlanta, false, false);
cntMarker += Atlanta.length;
map.addOverlays(Augusta);
centerByArray(Augusta, false, false);
cntMarker += Augusta.length;
map.addOverlays(College_Park);
centerByArray(College_Park, false, false);
cntMarker += College_Park.length;
map.addOverlays(Decatur);
centerByArray(Decatur, false, false);
cntMarker += Decatur.length;
map.addOverlays(Gainesville);
centerByArray(Gainesville, false, false);
cntMarker += Gainesville.length;
map.addOverlays(Macon);
centerByArray(Macon, false, false);
cntMarker += Macon.length;
map.addOverlays(Marietta);
centerByArray(Marietta, false, false);
cntMarker += Marietta.length;
map.addOverlays(Perry);
centerByArray(Perry, false, false);
cntMarker += Perry.length;
map.addOverlays(Rabun_Gap);
centerByArray(Rabun_Gap, false, false);
cntMarker += Rabun_Gap.length;
map.addOverlays(Roswell);
centerByArray(Roswell, false, false);
cntMarker += Roswell.length;
map.addOverlays(Senoia);
centerByArray(Senoia, false, false);
cntMarker += Senoia.length;
map.addOverlays(Tallulah_Falls);
centerByArray(Tallulah_Falls, false, false);
cntMarker += Tallulah_Falls.length;
centerByArray(Atlanta,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///7541,7570,7648,8043,7571,7679,7779,8039,7906,7984,7541,7570,7591,8018,7648,7672,8043,8054,7807,8057,7779,8039,7906,7576,7885,/all');
//window.open('/map.php?type=2&schools=7541,7570,7648,8043,7571,7679,7779,8039,7906,7984,7541,7570,7591,8018,7648,7672,8043,8054,7807,8057,7779,8039,7906,7576,7885,&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;
}