function addMarkers()
{
mySelect = document.getElementById('selection');
Douglasville = [];Lithia_Springs = [];Villa_Rica = [];Winston = [];mySelect.options[mySelect.options.length] = new Option("Douglasville schools",'all=Douglasville');
mySelect.options[mySelect.options.length] = new Option("Lithia Springs schools",'all=Lithia_Springs');
mySelect.options[mySelect.options.length] = new Option("Villa Rica schools",'all=Villa_Rica');
mySelect.options[mySelect.options.length] = new Option("Winston schools",'all=Winston');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Douglasville[Douglasville.length] = createMarker(new GPoint(-84.79246521,33.68204117),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Alexander High School",'Douglasville=' + Douglasville.length);
Lithia_Springs[Lithia_Springs.length] = createMarker(new GPoint(-84.65740204,33.79599380),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Annette Winn Elementary School",'Lithia_Springs=' + Lithia_Springs.length);
Douglasville[Douglasville.length] = createMarker(new GPoint(-84.75379181,33.71168518),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Arbor Station Elementary School",'Douglasville=' + Douglasville.length);
Douglasville[Douglasville.length] = createMarker(new GPoint(-84.70418549,33.77474976),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Beulah Elementary School",'Douglasville=' + Douglasville.length);
Douglasville[Douglasville.length] = createMarker(new GPoint(-84.80532837,33.67345047),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bill Arp Elementary School",'Douglasville=' + Douglasville.length);
Douglasville[Douglasville.length] = createMarker(new GPoint(-84.78170013,33.72540283),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bright Star Elementary School",'Douglasville=' + Douglasville.length);
Douglasville[Douglasville.length] = createMarker(new GPoint(-84.72850037,33.75444412),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Burnett Elementary School",'Douglasville=' + Douglasville.length);
Douglasville[Douglasville.length] = createMarker(new GPoint(-84.71616364,33.69635773),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Chapel Hill Elementary School",'Douglasville=' + Douglasville.length);
Douglasville[Douglasville.length] = createMarker(new GPoint(-84.72038269,33.67238235),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chapel Hill High School",'Douglasville=' + Douglasville.length);
Douglasville[Douglasville.length] = createMarker(new GPoint(-84.71616364,33.69641495),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Chapel Hill Middle School",'Douglasville=' + Douglasville.length);
Douglasville[Douglasville.length] = createMarker(new GPoint(-84.69780731,33.73391342),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Chestnut Log Middle School",'Douglasville=' + Douglasville.length);
Douglasville[Douglasville.length] = createMarker(new GPoint(-84.83345795,33.81217957),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Crossroads High School",'Douglasville=' + Douglasville.length);
Douglasville[Douglasville.length] = createMarker(new GPoint(-84.83345795,33.81217957),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Crossroads Middle School",'Douglasville=' + Douglasville.length);
Douglasville[Douglasville.length] = createMarker(new GPoint(-84.76723480,33.68073654),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dorsett Shoals Elementary School",'Douglasville=' + Douglasville.length);
Douglasville[Douglasville.length] = createMarker(new GPoint(-84.74912400,33.75018000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Douglas County High School",'Douglasville=' + Douglasville.length);
Douglasville[Douglasville.length] = createMarker(new GPoint(-84.72824097,33.75475693),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Eastside Elementary School",'Douglasville=' + Douglasville.length);
Douglasville[Douglasville.length] = createMarker(new GPoint(-84.65947723,33.72303391),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Factory Shoals Elementary School",'Douglasville=' + Douglasville.length);
Douglasville[Douglasville.length] = createMarker(new GPoint(-84.84702301,33.61820984),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Fairplay Middle School",'Douglasville=' + Douglasville.length);
Douglasville[Douglasville.length] = createMarker(new GPoint(-84.72104645,33.67120361),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Holly Springs Elementary School",'Douglasville=' + Douglasville.length);
Lithia_Springs[Lithia_Springs.length] = createMarker(new GPoint(-84.66162109,33.75422668),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lithia Springs Comprehensive High School",'Lithia_Springs=' + Lithia_Springs.length);
Lithia_Springs[Lithia_Springs.length] = createMarker(new GPoint(-84.66087341,33.78845978),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lithia Springs Elementary School",'Lithia_Springs=' + Lithia_Springs.length);
Villa_Rica[Villa_Rica.length] = createMarker(new GPoint(-84.87895966,33.73154449),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mirror Lake Elementary School",'Villa_Rica=' + Villa_Rica.length);
Douglasville[Douglasville.length] = createMarker(new GPoint(-84.68074036,33.74135208),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mount Carmel Elementary School",'Douglasville=' + Douglasville.length);
Douglasville[Douglasville.length] = createMarker(new GPoint(-84.65065765,33.70783234),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("New Manchester Elementary School",'Douglasville=' + Douglasville.length);
Douglasville[Douglasville.length] = createMarker(new GPoint(-84.78455100,33.76136900),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("North Douglas Elementary School",'Douglasville=' + Douglasville.length);
Douglasville[Douglasville.length] = createMarker(new GPoint(-84.84646606,33.61781693),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South Douglas Elementary School",'Douglasville=' + Douglasville.length);
Douglasville[Douglasville.length] = createMarker(new GPoint(-84.74732971,33.75827789),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Stewart Middle School",'Douglasville=' + Douglasville.length);
Lithia_Springs[Lithia_Springs.length] = createMarker(new GPoint(-84.66145325,33.75394821),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sweetwater Elementary School",'Lithia_Springs=' + Lithia_Springs.length);
Lithia_Springs[Lithia_Springs.length] = createMarker(new GPoint(-84.66116333,33.78753662),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Turner Middle School",'Lithia_Springs=' + Lithia_Springs.length);
Winston[Winston.length] = createMarker(new GPoint(-84.81906128,33.72897720),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Winston Elementary School",'Winston=' + Winston.length);
Douglasville[Douglasville.length] = createMarker(new GPoint(-84.77308655,33.69509125),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Yeager Middle School",'Douglasville=' + Douglasville.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(Douglasville);
map.removeOverlays(Lithia_Springs);
map.removeOverlays(Villa_Rica);
map.removeOverlays(Winston);
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(Douglasville);map.removeOverlays(Douglasville);
map.removeOverlays(Lithia_Springs);
map.removeOverlays(Villa_Rica);
map.removeOverlays(Winston);
map.addOverlays(Douglasville);
centerByArray(Douglasville, false, false);
cntMarker += Douglasville.length;
map.addOverlays(Lithia_Springs);
centerByArray(Lithia_Springs, false, false);
cntMarker += Lithia_Springs.length;
map.addOverlays(Villa_Rica);
centerByArray(Villa_Rica, false, false);
cntMarker += Villa_Rica.length;
map.addOverlays(Winston);
centerByArray(Winston, false, false);
cntMarker += Winston.length;
centerByArray(Douglasville,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');
}
}