function addMarkers(){
mySelect = document.getElementById('selection');
Nashville = [];Old_Hickory = [];Antioch = [];Madison = [];Mount_Juliet = [];Brentwood = [];Whites_Creek = [];mySelect.options[mySelect.options.length] = new Option("Antioch schools",'all=Antioch');
mySelect.options[mySelect.options.length] = new Option("Brentwood schools",'all=Brentwood');
mySelect.options[mySelect.options.length] = new Option("Madison schools",'all=Madison');
mySelect.options[mySelect.options.length] = new Option("Mount Juliet schools",'all=Mount_Juliet');
mySelect.options[mySelect.options.length] = new Option("Nashville schools",'all=Nashville');
mySelect.options[mySelect.options.length] = new Option("Old Hickory schools",'all=Old_Hickory');
mySelect.options[mySelect.options.length] = new Option("Whites Creek schools",'all=Whites_Creek');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Nashville[Nashville.length] = createMarker(new GPoint(-86.70398400,36.03633300),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cedarcreek Schoolhouse Academy",'Nashville=' + Nashville.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.87810600,36.05048000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christ Presbyterian Academy",'Nashville=' + Nashville.length);
Old_Hickory[Old_Hickory.length] = createMarker(new GPoint(-86.62699600,36.22528100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christian Life Academy",'Old_Hickory=' + Old_Hickory.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.73629600,36.10991600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Community High School",'Nashville=' + Nashville.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.79504400,36.10646200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("David Lipscomb Campus School",'Nashville=' + Nashville.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.77533400,36.27941200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Davidson Academy",'Nashville=' + Nashville.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.64965500,36.18188200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Donelson Christian Academy",'Nashville=' + Nashville.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.83993800,36.12439700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Ensworth School",'Nashville=' + Nashville.length);
Antioch[Antioch.length] = createMarker(new GPoint(-86.63676500,36.06542300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ezell-Harding Christian School",'Antioch=' + Antioch.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.76836900,36.09923600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Father Ryan High School",'Nashville=' + Nashville.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.77218900,36.08321100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Franklin Road Academy",'Nashville=' + Nashville.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.74106600,36.09598100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Genesis Lc/genesis Academy",'Nashville=' + Nashville.length);
Madison[Madison.length] = createMarker(new GPoint(-86.73740700,36.24936700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Goodpasture Christian School",'Madison=' + Madison.length);
Madison[Madison.length] = createMarker(new GPoint(-86.74158700,36.24995700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Goodpasture High School",'Madison=' + Madison.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.83864700,36.10302700),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Harpeth Hall School",'Nashville=' + Nashville.length);
Mount_Juliet[Mount_Juliet.length] = createMarker(new GPoint(-86.51915200,36.19877000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Heritage Christian Academy - Mt. Juliet",'Mount_Juliet=' + Mount_Juliet.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.77850200,36.14142800),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Hermitage Hall",'Nashville=' + Nashville.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.83987700,36.20204900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Institute Of Learning Resea",'Nashville=' + Nashville.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.74855900,36.12578700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jesus Only Academy",'Nashville=' + Nashville.length);
Antioch[Antioch.length] = createMarker(new GPoint(-86.67296500,36.05243900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lighthouse Christian School",'Antioch=' + Antioch.length);
Madison[Madison.length] = createMarker(new GPoint(-86.70630000,36.26230000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Madison Academy",'Madison=' + Madison.length);
Madison[Madison.length] = createMarker(new GPoint(-86.69763600,36.25309400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Metro Christian Academy",'Madison=' + Madison.length);
Brentwood[Brentwood.length] = createMarker(new GPoint(-86.74678600,36.03057100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Academy",'Brentwood=' + Brentwood.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.83785200,36.13020800),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Montgomery Bell Academy",'Nashville=' + Nashville.length);
Antioch[Antioch.length] = createMarker(new GPoint(-86.68466200,36.07404700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Nashville Academy",'Antioch=' + Antioch.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.93009000,36.10821900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Nashville Christian School",'Nashville=' + Nashville.length);
Whites_Creek[Whites_Creek.length] = createMarker(new GPoint(-86.77671600,36.29367400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pioneer Christian Academy",'Whites_Creek=' + Whites_Creek.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.80318300,36.13876500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Psychiatric Hospital At Vander",'Nashville=' + Nashville.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.74089100,36.10280300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Radnor Baptist Academy",'Nashville=' + Nashville.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.84124800,36.12917900),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("St. Cecilia Academy",'Nashville=' + Nashville.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.73990000,36.18100000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Teach-timothy Endeavo Academy Chr",'Nashville=' + Nashville.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.79859200,36.14409300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("University School Of Nashville",'Nashville=' + Nashville.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.78893700,36.17404800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wallace Academy",'Nashville=' + Nashville.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,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/////2/' + showArray);
map.removeOverlays(Antioch);
map.removeOverlays(Brentwood);
map.removeOverlays(Madison);
map.removeOverlays(Mount_Juliet);
map.removeOverlays(Nashville);
map.removeOverlays(Old_Hickory);
map.removeOverlays(Whites_Creek);
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(Nashville);map.removeOverlays(Antioch);
map.removeOverlays(Brentwood);
map.removeOverlays(Madison);
map.removeOverlays(Mount_Juliet);
map.removeOverlays(Nashville);
map.removeOverlays(Old_Hickory);
map.removeOverlays(Whites_Creek);
map.addOverlays(Antioch);
centerByArray(Antioch, false, false);
cntMarker += Antioch.length;
map.addOverlays(Brentwood);
centerByArray(Brentwood, false, false);
cntMarker += Brentwood.length;
map.addOverlays(Madison);
centerByArray(Madison, false, false);
cntMarker += Madison.length;
map.addOverlays(Mount_Juliet);
centerByArray(Mount_Juliet, false, false);
cntMarker += Mount_Juliet.length;
map.addOverlays(Nashville);
centerByArray(Nashville, false, false);
cntMarker += Nashville.length;
map.addOverlays(Old_Hickory);
centerByArray(Old_Hickory, false, false);
cntMarker += Old_Hickory.length;
map.addOverlays(Whites_Creek);
centerByArray(Whites_Creek, false, false);
cntMarker += Whites_Creek.length;
centerByArray(Nashville,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');
//window.open('/map.php?type=1&schools=&school_level=2&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;
}