function addMarkers(){
mySelect = document.getElementById('selection');
Collegedale = [];Chattanooga = [];Hixson = [];Apison = [];Signal_Mountai = [];Soddy_Daisy = [];Ooltewah = [];Signal_Mountain = [];mySelect.options[mySelect.options.length] = new Option("Apison schools",'all=Apison');
mySelect.options[mySelect.options.length] = new Option("Chattanooga schools",'all=Chattanooga');
mySelect.options[mySelect.options.length] = new Option("Collegedale schools",'all=Collegedale');
mySelect.options[mySelect.options.length] = new Option("Hixson schools",'all=Hixson');
mySelect.options[mySelect.options.length] = new Option("Ooltewah schools",'all=Ooltewah');
mySelect.options[mySelect.options.length] = new Option("Signal Mountai schools",'all=Signal_Mountai');
mySelect.options[mySelect.options.length] = new Option("Signal Mountain schools",'all=Signal_Mountain');
mySelect.options[mySelect.options.length] = new Option("Soddy Daisy schools",'all=Soddy_Daisy');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Collegedale[Collegedale.length] = createMarker(new GPoint(-85.07138900,35.06019400),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("A. W. Spalding Elementary School",'Collegedale=' + Collegedale.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.26622600,35.05177900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Avondale SDA Elementary School",'Chattanooga=' + Chattanooga.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.30810000,35.04550000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Baylor School",'Chattanooga=' + Chattanooga.length);
Hixson[Hixson.length] = createMarker(new GPoint(-85.25082200,35.14468300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Berean Academy",'Hixson=' + Hixson.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.21533300,35.04279900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Boyd-buchanan School",'Chattanooga=' + Chattanooga.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.22670000,35.01230000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Brainerd Baptist School",'Chattanooga=' + Chattanooga.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.29088900,35.08354200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bright School",'Chattanooga=' + Chattanooga.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.23443200,35.00789200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calvary Christian School",'Chattanooga=' + Chattanooga.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.33100200,35.00025800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chattanooga Christian School",'Chattanooga=' + Chattanooga.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.25536500,35.05419400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Church Of Jesus Kind Unit 2",'Chattanooga=' + Chattanooga.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.14706100,35.05222100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cumberland Hall Academy",'Chattanooga=' + Chattanooga.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.29795000,35.06188900),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Girls Preparatory School",'Chattanooga=' + Chattanooga.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.13587600,35.03521800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grace Baptist Academy",'Chattanooga=' + Chattanooga.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.17192500,35.04841800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hickory Valley Christian School",'Chattanooga=' + Chattanooga.length);
Hixson[Hixson.length] = createMarker(new GPoint(-85.19662900,35.15653700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hixson Sda School",'Hixson=' + Hixson.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.27340000,35.02950000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Imani Cultural University, Llc",'Chattanooga=' + Chattanooga.length);
Apison[Apison.length] = createMarker(new GPoint(-85.01760000,35.02233700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lester Coon Apison School Of Sda",'Apison=' + Apison.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.24453200,35.00441400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lutheran School",'Chattanooga=' + Chattanooga.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.26477900,35.03002700),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mccallie School",'Chattanooga=' + Chattanooga.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.28660400,35.04016100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School",'Chattanooga=' + Chattanooga.length);
Signal_Mountai[Signal_Mountai.length] = createMarker(new GPoint(-85.35375500,35.12418400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mountainwood Learning Center",'Signal_Mountai=' + Signal_Mountai.length);
Soddy_Daisy[Soddy_Daisy.length] = createMarker(new GPoint(-85.20671300,35.23210200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New South Daisy Christian Academy",'Soddy_Daisy=' + Soddy_Daisy.length);
Ooltewah[Ooltewah.length] = createMarker(new GPoint(-85.05594400,35.09060900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ooltewah Adventist School",'Ooltewah=' + Ooltewah.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.27340000,35.02950000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Orange Grove Center",'Chattanooga=' + Chattanooga.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.23265000,35.00515000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of Perpetual Help School",'Chattanooga=' + Chattanooga.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.26627700,35.11693100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Jude Elementary School",'Chattanooga=' + Chattanooga.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.14195200,35.04352200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Nicholas School",'Chattanooga=' + Chattanooga.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.26921200,35.11696000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Peters Episcopal School",'Chattanooga=' + Chattanooga.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.31957300,35.11531100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Scenic Land School",'Chattanooga=' + Chattanooga.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.33009900,35.06982600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Scholze Center",'Chattanooga=' + Chattanooga.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.24557300,35.02602300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Signal Centers, Inc.",'Chattanooga=' + Chattanooga.length);
Signal_Mountain[Signal_Mountain.length] = createMarker(new GPoint(-85.31365500,35.16278300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Signal Mountain Christian School",'Signal_Mountain=' + Signal_Mountain.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.13886200,35.06262300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Silverdale Baptist Academy",'Chattanooga=' + Chattanooga.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.31274000,35.04394100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Siskin School",'Chattanooga=' + Chattanooga.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.10775800,35.03434800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Standifer Gap Sda School",'Chattanooga=' + Chattanooga.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.27574900,35.03347500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tennessee Temple Academy",'Chattanooga=' + Chattanooga.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.27575100,35.03346700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tennessee Temple Academy",'Chattanooga=' + Chattanooga.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.12313100,35.02613700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Valley Academy",'Chattanooga=' + Chattanooga.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/////1/' + showArray);
map.removeOverlays(Apison);
map.removeOverlays(Chattanooga);
map.removeOverlays(Collegedale);
map.removeOverlays(Hixson);
map.removeOverlays(Ooltewah);
map.removeOverlays(Signal_Mountai);
map.removeOverlays(Signal_Mountain);
map.removeOverlays(Soddy_Daisy);
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(Collegedale);map.removeOverlays(Apison);
map.removeOverlays(Chattanooga);
map.removeOverlays(Collegedale);
map.removeOverlays(Hixson);
map.removeOverlays(Ooltewah);
map.removeOverlays(Signal_Mountai);
map.removeOverlays(Signal_Mountain);
map.removeOverlays(Soddy_Daisy);
map.addOverlays(Apison);
centerByArray(Apison, false, false);
cntMarker += Apison.length;
map.addOverlays(Chattanooga);
centerByArray(Chattanooga, false, false);
cntMarker += Chattanooga.length;
map.addOverlays(Collegedale);
centerByArray(Collegedale, false, false);
cntMarker += Collegedale.length;
map.addOverlays(Hixson);
centerByArray(Hixson, false, false);
cntMarker += Hixson.length;
map.addOverlays(Ooltewah);
centerByArray(Ooltewah, false, false);
cntMarker += Ooltewah.length;
map.addOverlays(Signal_Mountai);
centerByArray(Signal_Mountai, false, false);
cntMarker += Signal_Mountai.length;
map.addOverlays(Signal_Mountain);
centerByArray(Signal_Mountain, false, false);
cntMarker += Signal_Mountain.length;
map.addOverlays(Soddy_Daisy);
centerByArray(Soddy_Daisy, false, false);
cntMarker += Soddy_Daisy.length;
centerByArray(Collegedale,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=1&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;
}