function addMarkers()
{
mySelect = document.getElementById('selection');
Dothan = [];Dothan[Dothan.length] = createMarker(new GPoint(-85.35388184,31.19379234),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Beverlye Middle School",'Dothan=' + Dothan.length);
Dothan[Dothan.length] = createMarker(new GPoint(-85.37467194,31.23497772),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Carver Magnet School For Mathematics, Science And",'Dothan=' + Dothan.length);
Dothan[Dothan.length] = createMarker(new GPoint(-85.39253235,31.19665337),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cloverdale Elementary School",'Dothan=' + Dothan.length);
Dothan[Dothan.length] = createMarker(new GPoint(-85.39321899,31.20850945),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Dothan High School",'Dothan=' + Dothan.length);
Dothan[Dothan.length] = createMarker(new GPoint(-85.38104248,31.26575089),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Dothan Technology Center",'Dothan=' + Dothan.length);
Dothan[Dothan.length] = createMarker(new GPoint(-85.42173004,31.23783875),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Girard Elementary School",'Dothan=' + Dothan.length);
Dothan[Dothan.length] = createMarker(new GPoint(-85.42173004,31.24117470),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Girard Middle School",'Dothan=' + Dothan.length);
Dothan[Dothan.length] = createMarker(new GPoint(-85.37523651,31.21107674),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Grandview Elementary School",'Dothan=' + Dothan.length);
Dothan[Dothan.length] = createMarker(new GPoint(-85.42832947,31.21927452),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Heard Elementary School",'Dothan=' + Dothan.length);
Dothan[Dothan.length] = createMarker(new GPoint(-85.34790802,31.19298363),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hidden Lake Elementary School",'Dothan=' + Dothan.length);
Dothan[Dothan.length] = createMarker(new GPoint(-85.48587799,31.22028732),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Highlands Elementary School",'Dothan=' + Dothan.length);
Dothan[Dothan.length] = createMarker(new GPoint(-85.43510437,31.20494843),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Honeysuckle Middle School",'Dothan=' + Dothan.length);
Dothan[Dothan.length] = createMarker(new GPoint(-85.39260101,31.22679329),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Houston County Alternative School",'Dothan=' + Dothan.length);
Dothan[Dothan.length] = createMarker(new GPoint(-85.37263489,31.23387527),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jerry Lee Faine Elementary School",'Dothan=' + Dothan.length);
Dothan[Dothan.length] = createMarker(new GPoint(-85.46467590,31.27739716),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kelly Springs Elementary School",'Dothan=' + Dothan.length);
Dothan[Dothan.length] = createMarker(new GPoint(-85.39567566,31.27157402),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Landmark Elementary School",'Dothan=' + Dothan.length);
Dothan[Dothan.length] = createMarker(new GPoint(-85.40216827,31.23564339),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Montana Academic Magnet School",'Dothan=' + Dothan.length);
Dothan[Dothan.length] = createMarker(new GPoint(-85.38013458,31.26635551),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northview High School",'Dothan=' + Dothan.length);
Dothan[Dothan.length] = createMarker(new GPoint(-85.38973999,31.24263763),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("P.a.s.s. Academy",'Dothan=' + Dothan.length);
Dothan[Dothan.length] = createMarker(new GPoint(-85.52324700,31.00462400),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Rehobeth Elementary School",'Dothan=' + Dothan.length);
Dothan[Dothan.length] = createMarker(new GPoint(-85.41432190,31.16925049),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rehobeth High School",'Dothan=' + Dothan.length);
Dothan[Dothan.length] = createMarker(new GPoint(-85.52324700,31.00462400),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Rehobeth Middle School",'Dothan=' + Dothan.length);
Dothan[Dothan.length] = createMarker(new GPoint(-85.41363525,31.21017456),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Selma Street Elementary School",'Dothan=' + Dothan.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(Dothan);
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(Dothan);map.removeOverlays(Dothan);
map.addOverlays(Dothan);
centerByArray(Dothan, false, false);
cntMarker += Dothan.length;
centerByArray(Dothan,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');
}
}