function addMarkers()
{
mySelect = document.getElementById('selection');
Peachtree_City = [];Brooks = [];Fayetteville = [];Tyrone = [];mySelect.options[mySelect.options.length] = new Option("Brooks schools",'all=Brooks');
mySelect.options[mySelect.options.length] = new Option("Fayetteville schools",'all=Fayetteville');
mySelect.options[mySelect.options.length] = new Option("Peachtree City schools",'all=Peachtree_City');
mySelect.options[mySelect.options.length] = new Option("Tyrone schools",'all=Tyrone');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Peachtree_City[Peachtree_City.length] = createMarker(new GPoint(-84.56784058,33.40629578),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Booth Middle School",'Peachtree_City=' + Peachtree_City.length);
Peachtree_City[Peachtree_City.length] = createMarker(new GPoint(-84.54632568,33.38907242),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Braelinn Elementary School",'Peachtree_City=' + Peachtree_City.length);
Brooks[Brooks.length] = createMarker(new GPoint(-84.46468353,33.29053879),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Brooks Elementary School",'Brooks=' + Brooks.length);
Fayetteville[Fayetteville.length] = createMarker(new GPoint(-84.50904846,33.44042206),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cleveland Elementary School",'Fayetteville=' + Fayetteville.length);
Peachtree_City[Peachtree_City.length] = createMarker(new GPoint(-84.55734253,33.38869858),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Crabapple Lane Elementary School",'Peachtree_City=' + Peachtree_City.length);
Fayetteville[Fayetteville.length] = createMarker(new GPoint(-84.44499207,33.44791412),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("East Fayette Elementary School",'Fayetteville=' + Fayetteville.length);
Fayetteville[Fayetteville.length] = createMarker(new GPoint(-84.46032715,33.45073318),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Evening School",'Fayetteville=' + Fayetteville.length);
Fayetteville[Fayetteville.length] = createMarker(new GPoint(-84.55713654,33.38858032),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fayette County High School",'Fayetteville=' + Fayetteville.length);
Fayetteville[Fayetteville.length] = createMarker(new GPoint(-84.46559143,33.44330215),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Fayette Middle School",'Fayetteville=' + Fayetteville.length);
Fayetteville[Fayetteville.length] = createMarker(new GPoint(-84.46376038,33.45673752),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fayetteville Intermediate Elementary School",'Fayetteville=' + Fayetteville.length);
Tyrone[Tyrone.length] = createMarker(new GPoint(-84.57205200,33.49528885),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Flat Rock Middle School",'Tyrone=' + Tyrone.length);
Fayetteville[Fayetteville.length] = createMarker(new GPoint(-84.46508789,33.45676041),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hood Avenue Primary Elementary School",'Fayetteville=' + Fayetteville.length);
Peachtree_City[Peachtree_City.length] = createMarker(new GPoint(-84.57104492,33.38423920),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Huddleston Elementary School",'Peachtree_City=' + Peachtree_City.length);
Peachtree_City[Peachtree_City.length] = createMarker(new GPoint(-84.59999084,33.42955780),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kedron Elementary School",'Peachtree_City=' + Peachtree_City.length);
Peachtree_City[Peachtree_City.length] = createMarker(new GPoint(-84.56099701,33.41825485),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mcintosh High School",'Peachtree_City=' + Peachtree_City.length);
Fayetteville[Fayetteville.length] = createMarker(new GPoint(-84.47042847,33.51094055),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("North Fayette Elementary School",'Fayetteville=' + Fayetteville.length);
Peachtree_City[Peachtree_City.length] = createMarker(new GPoint(-84.54010010,33.38415527),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Oak Grove Elementary School",'Peachtree_City=' + Peachtree_City.length);
Peachtree_City[Peachtree_City.length] = createMarker(new GPoint(-84.59788513,33.40905380),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Peachtree City Elementary School",'Peachtree_City=' + Peachtree_City.length);
Fayetteville[Fayetteville.length] = createMarker(new GPoint(-84.51776123,33.34192657),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Peeples Elementary School",'Fayetteville=' + Fayetteville.length);
Fayetteville[Fayetteville.length] = createMarker(new GPoint(-84.51899719,33.34044266),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Rising Starr Middle School",'Fayetteville=' + Fayetteville.length);
Tyrone[Tyrone.length] = createMarker(new GPoint(-84.57231140,33.49504852),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Robert J. Burch Elementary School",'Tyrone=' + Tyrone.length);
Tyrone[Tyrone.length] = createMarker(new GPoint(-84.57434845,33.49506378),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sandy Creek High School",'Tyrone=' + Tyrone.length);
Fayetteville[Fayetteville.length] = createMarker(new GPoint(-84.47701263,33.37965393),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sara Harp Minter Elementary School",'Fayetteville=' + Fayetteville.length);
Fayetteville[Fayetteville.length] = createMarker(new GPoint(-84.46883392,33.44447327),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Spring Hill Elementary School",'Fayetteville=' + Fayetteville.length);
Fayetteville[Fayetteville.length] = createMarker(new GPoint(-84.52056122,33.34002686),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Starrs Mill High School",'Fayetteville=' + Fayetteville.length);
Tyrone[Tyrone.length] = createMarker(new GPoint(-84.59709167,33.47543335),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Tyrone Elementary School",'Tyrone=' + Tyrone.length);
Fayetteville[Fayetteville.length] = createMarker(new GPoint(-84.47081700,33.37674000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Whitewater High School",'Fayetteville=' + Fayetteville.length);
Fayetteville[Fayetteville.length] = createMarker(new GPoint(-84.47166443,33.38781357),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Whitewater Middle School",'Fayetteville=' + Fayetteville.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(Brooks);
map.removeOverlays(Fayetteville);
map.removeOverlays(Peachtree_City);
map.removeOverlays(Tyrone);
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(Peachtree_City);map.removeOverlays(Brooks);
map.removeOverlays(Fayetteville);
map.removeOverlays(Peachtree_City);
map.removeOverlays(Tyrone);
map.addOverlays(Brooks);
centerByArray(Brooks, false, false);
cntMarker += Brooks.length;
map.addOverlays(Fayetteville);
centerByArray(Fayetteville, false, false);
cntMarker += Fayetteville.length;
map.addOverlays(Peachtree_City);
centerByArray(Peachtree_City, false, false);
cntMarker += Peachtree_City.length;
map.addOverlays(Tyrone);
centerByArray(Tyrone, false, false);
cntMarker += Tyrone.length;
centerByArray(Peachtree_City,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');
}
}