function addMarkers(){
mySelect = document.getElementById('selection');
Maryville = [];Athens = [];Camden = [];Columbia = [];Ramer = [];Nashville = [];Spencer = [];Woodbury = [];Kingsport = [];Memphis = [];Cleveland = [];Lexington = [];Dresden = [];Scotts_Hill = [];Spring_City = [];mySelect.options[mySelect.options.length] = new Option("Athens schools",'all=Athens');
mySelect.options[mySelect.options.length] = new Option("Camden schools",'all=Camden');
mySelect.options[mySelect.options.length] = new Option("Cleveland schools",'all=Cleveland');
mySelect.options[mySelect.options.length] = new Option("Columbia schools",'all=Columbia');
mySelect.options[mySelect.options.length] = new Option("Dresden schools",'all=Dresden');
mySelect.options[mySelect.options.length] = new Option("Kingsport schools",'all=Kingsport');
mySelect.options[mySelect.options.length] = new Option("Lexington schools",'all=Lexington');
mySelect.options[mySelect.options.length] = new Option("Maryville schools",'all=Maryville');
mySelect.options[mySelect.options.length] = new Option("Memphis schools",'all=Memphis');
mySelect.options[mySelect.options.length] = new Option("Nashville schools",'all=Nashville');
mySelect.options[mySelect.options.length] = new Option("Ramer schools",'all=Ramer');
mySelect.options[mySelect.options.length] = new Option("Scotts Hill schools",'all=Scotts_Hill');
mySelect.options[mySelect.options.length] = new Option("Spencer schools",'all=Spencer');
mySelect.options[mySelect.options.length] = new Option("Spring City schools",'all=Spring_City');
mySelect.options[mySelect.options.length] = new Option("Woodbury schools",'all=Woodbury');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Maryville[Maryville.length] = createMarker(new GPoint(-84.04446800,35.75126700),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Apostolic Christian Academy",'Maryville=' + Maryville.length);
Athens[Athens.length] = createMarker(new GPoint(-84.59300000,35.44270000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Athens Pentecostal Christian School",'Athens=' + Athens.length);
Camden[Camden.length] = createMarker(new GPoint(-88.10437400,36.05707900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Camden United Christian Academy",'Camden=' + Camden.length);
Columbia[Columbia.length] = createMarker(new GPoint(-87.00694900,35.58554300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Columbia Christian Academy",'Columbia=' + Columbia.length);
Ramer[Ramer.length] = createMarker(new GPoint(-88.53971000,35.06236300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eastview Christian Academy",'Ramer=' + Ramer.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.74762400,36.11527800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Christian Development Academy",'Nashville=' + Nashville.length);
Spencer[Spencer.length] = createMarker(new GPoint(-85.46328900,35.73102000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Trinity Academy",'Spencer=' + Spencer.length);
Woodbury[Woodbury.length] = createMarker(new GPoint(-86.05510000,35.81760000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grace Emmanuel Christian Academy",'Woodbury=' + Woodbury.length);
Kingsport[Kingsport.length] = createMarker(new GPoint(-82.55447500,36.57493100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gravely Apostolic Chrn School",'Kingsport=' + Kingsport.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.91880800,35.17238700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grey Road Christian Academy",'Memphis=' + Memphis.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);
Cleveland[Cleveland.length] = createMarker(new GPoint(-84.86107000,35.13981400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Landmark Christian Day School",'Cleveland=' + Cleveland.length);
Lexington[Lexington.length] = createMarker(new GPoint(-88.39530000,35.65440000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lexington Christian Academy",'Lexington=' + Lexington.length);
Dresden[Dresden.length] = createMarker(new GPoint(-88.71040300,36.23493700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Liberty Christian Academy",'Dresden=' + Dresden.length);
Scotts_Hill[Scotts_Hill.length] = createMarker(new GPoint(-88.24850000,35.52690000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Souls Harbor Lighthouse Christian Academy",'Scotts_Hill=' + Scotts_Hill.length);
Spring_City[Spring_City.length] = createMarker(new GPoint(-84.83294700,35.71738700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Spring City Christian Academy",'Spring_City=' + Spring_City.length);
map.removeOverlays(Athens);
map.removeOverlays(Camden);
map.removeOverlays(Cleveland);
map.removeOverlays(Columbia);
map.removeOverlays(Dresden);
map.removeOverlays(Kingsport);
map.removeOverlays(Lexington);
map.removeOverlays(Maryville);
map.removeOverlays(Memphis);
map.removeOverlays(Nashville);
map.removeOverlays(Ramer);
map.removeOverlays(Scotts_Hill);
map.removeOverlays(Spencer);
map.removeOverlays(Spring_City);
map.removeOverlays(Woodbury);
setTimeout(function(){map.addOverlays(Athens)},1000);
setTimeout(function(){map.addOverlays(Camden)},1000);
setTimeout(function(){map.addOverlays(Cleveland)},1000);
setTimeout(function(){map.addOverlays(Columbia)},1000);
setTimeout(function(){map.addOverlays(Dresden)},1000);
setTimeout(function(){map.addOverlays(Kingsport)},1000);
setTimeout(function(){map.addOverlays(Lexington)},1000);
setTimeout(function(){map.addOverlays(Maryville)},1000);
setTimeout(function(){map.addOverlays(Memphis)},1000);
setTimeout(function(){map.addOverlays(Nashville)},1000);
setTimeout(function(){map.addOverlays(Ramer)},1000);
setTimeout(function(){map.addOverlays(Scotts_Hill)},1000);
setTimeout(function(){map.addOverlays(Spencer)},1000);
setTimeout(function(){map.addOverlays(Spring_City)},1000);
setTimeout(function(){map.addOverlays(Woodbury)},1000);
maxLng = -82.55447500;
maxLat = 36.57493100;
minLng = -89.91880800;
minLat = 35.06236300;
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(Athens);
map.removeOverlays(Camden);
map.removeOverlays(Cleveland);
map.removeOverlays(Columbia);
map.removeOverlays(Dresden);
map.removeOverlays(Kingsport);
map.removeOverlays(Lexington);
map.removeOverlays(Maryville);
map.removeOverlays(Memphis);
map.removeOverlays(Nashville);
map.removeOverlays(Ramer);
map.removeOverlays(Scotts_Hill);
map.removeOverlays(Spencer);
map.removeOverlays(Spring_City);
map.removeOverlays(Woodbury);
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(Maryville);map.removeOverlays(Athens);
map.removeOverlays(Camden);
map.removeOverlays(Cleveland);
map.removeOverlays(Columbia);
map.removeOverlays(Dresden);
map.removeOverlays(Kingsport);
map.removeOverlays(Lexington);
map.removeOverlays(Maryville);
map.removeOverlays(Memphis);
map.removeOverlays(Nashville);
map.removeOverlays(Ramer);
map.removeOverlays(Scotts_Hill);
map.removeOverlays(Spencer);
map.removeOverlays(Spring_City);
map.removeOverlays(Woodbury);
map.addOverlays(Athens);
centerByArray(Athens, false, false);
cntMarker += Athens.length;
map.addOverlays(Camden);
centerByArray(Camden, false, false);
cntMarker += Camden.length;
map.addOverlays(Cleveland);
centerByArray(Cleveland, false, false);
cntMarker += Cleveland.length;
map.addOverlays(Columbia);
centerByArray(Columbia, false, false);
cntMarker += Columbia.length;
map.addOverlays(Dresden);
centerByArray(Dresden, false, false);
cntMarker += Dresden.length;
map.addOverlays(Kingsport);
centerByArray(Kingsport, false, false);
cntMarker += Kingsport.length;
map.addOverlays(Lexington);
centerByArray(Lexington, false, false);
cntMarker += Lexington.length;
map.addOverlays(Maryville);
centerByArray(Maryville, false, false);
cntMarker += Maryville.length;
map.addOverlays(Memphis);
centerByArray(Memphis, false, false);
cntMarker += Memphis.length;
map.addOverlays(Nashville);
centerByArray(Nashville, false, false);
cntMarker += Nashville.length;
map.addOverlays(Ramer);
centerByArray(Ramer, false, false);
cntMarker += Ramer.length;
map.addOverlays(Scotts_Hill);
centerByArray(Scotts_Hill, false, false);
cntMarker += Scotts_Hill.length;
map.addOverlays(Spencer);
centerByArray(Spencer, false, false);
cntMarker += Spencer.length;
map.addOverlays(Spring_City);
centerByArray(Spring_City, false, false);
cntMarker += Spring_City.length;
map.addOverlays(Woodbury);
centerByArray(Woodbury, false, false);
cntMarker += Woodbury.length;
centerByArray(Maryville,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///25922,25962,33222,26003,26162,26075,26160,25919,26082,26141,33220,26280,33221,26073,25922,25962,33222,26003,26162,26075,26160,25919,26082,33701,26141,33220,26280,33221,33226,/all');
//window.open('/map.php?type=2&schools=25922,25962,33222,26003,26162,26075,26160,25919,26082,26141,33220,26280,33221,26073,25922,25962,33222,26003,26162,26075,26160,25919,26082,33701,26141,33220,26280,33221,33226,&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;
}