function addMarkers(){
mySelect = document.getElementById('selection');
Bartlett = [];Chattanooga = [];Clarksville = [];Cleveland = [];Collierville = [];Cookeville = [];Cordova = [];Germantown = [];Gray = [];Hendersonville = [];Jasper = [];Johnson_City = [];Kingsport = [];Knoxville = [];Memphis = [];Nashville = [];Signal_Mountai = [];mySelect.options[mySelect.options.length] = new Option("Bartlett schools",'all=Bartlett');
mySelect.options[mySelect.options.length] = new Option("Chattanooga schools",'all=Chattanooga');
mySelect.options[mySelect.options.length] = new Option("Clarksville schools",'all=Clarksville');
mySelect.options[mySelect.options.length] = new Option("Cleveland schools",'all=Cleveland');
mySelect.options[mySelect.options.length] = new Option("Collierville schools",'all=Collierville');
mySelect.options[mySelect.options.length] = new Option("Cookeville schools",'all=Cookeville');
mySelect.options[mySelect.options.length] = new Option("Cordova schools",'all=Cordova');
mySelect.options[mySelect.options.length] = new Option("Germantown schools",'all=Germantown');
mySelect.options[mySelect.options.length] = new Option("Gray schools",'all=Gray');
mySelect.options[mySelect.options.length] = new Option("Hendersonville schools",'all=Hendersonville');
mySelect.options[mySelect.options.length] = new Option("Jasper schools",'all=Jasper');
mySelect.options[mySelect.options.length] = new Option("Johnson City schools",'all=Johnson_City');
mySelect.options[mySelect.options.length] = new Option("Kingsport schools",'all=Kingsport');
mySelect.options[mySelect.options.length] = new Option("Knoxville schools",'all=Knoxville');
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("Signal Mountai schools",'all=Signal_Mountai');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Bartlett[Bartlett.length] = createMarker(new GPoint(-89.86713400,35.20445500),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bartlett Baptist Preschool & Kindergarten",'Bartlett=' + Bartlett.length);
Bartlett[Bartlett.length] = createMarker(new GPoint(-89.87401300,35.20467400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bartlett United Methodist Pres",'Bartlett=' + Bartlett.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);
Clarksville[Clarksville.length] = createMarker(new GPoint(-87.35023200,36.52937700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Immaculate Conception Preschoo",'Clarksville=' + Clarksville.length);
Clarksville[Clarksville.length] = createMarker(new GPoint(-87.24166000,36.51910000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Little Country School House",'Clarksville=' + Clarksville.length);
Cleveland[Cleveland.length] = createMarker(new GPoint(-84.83413100,35.18932100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("First Baptist Weekday Ministry",'Cleveland=' + Cleveland.length);
Collierville[Collierville.length] = createMarker(new GPoint(-89.67671500,35.04591800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Collierville Methodist Preschool",'Collierville=' + Collierville.length);
Cookeville[Cookeville.length] = createMarker(new GPoint(-85.48735600,36.17573700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Childgarden",'Cookeville=' + Cookeville.length);
Cordova[Cordova.length] = createMarker(new GPoint(-89.78403300,35.15617700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Harding Academy Cordova Kindergarten",'Cordova=' + Cordova.length);
Germantown[Germantown.length] = createMarker(new GPoint(-89.78809700,35.09509100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Farmington Presbyterian Day School",'Germantown=' + Germantown.length);
Germantown[Germantown.length] = createMarker(new GPoint(-89.81044500,35.08516700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Germantown United Meth Prescl",'Germantown=' + Germantown.length);
Gray[Gray.length] = createMarker(new GPoint(-82.47510400,36.41849300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tri Cities Christian School",'Gray=' + Gray.length);
Hendersonville[Hendersonville.length] = createMarker(new GPoint(-86.62000000,36.30470000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hendersonville Bible Kindergarten",'Hendersonville=' + Hendersonville.length);
Jasper[Jasper.length] = createMarker(new GPoint(-85.59621700,35.06413700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Learning Center",'Jasper=' + Jasper.length);
Johnson_City[Johnson_City.length] = createMarker(new GPoint(-82.34964000,36.31310900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Early Learning Center 1st United",'Johnson_City=' + Johnson_City.length);
Johnson_City[Johnson_City.length] = createMarker(new GPoint(-82.35087600,36.31790600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Munsey Kindergarten",'Johnson_City=' + Johnson_City.length);
Johnson_City[Johnson_City.length] = createMarker(new GPoint(-82.35362400,36.31978700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central Baptist Church",'Johnson_City=' + Johnson_City.length);
Kingsport[Kingsport.length] = createMarker(new GPoint(-82.55352700,36.55008000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Paul's Day School And Kindergarten",'Kingsport=' + Kingsport.length);
Knoxville[Knoxville.length] = createMarker(new GPoint(-83.99360000,35.93650000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("My School",'Knoxville=' + Knoxville.length);
Knoxville[Knoxville.length] = createMarker(new GPoint(-84.05352800,35.92689500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West End Christian School",'Knoxville=' + Knoxville.length);
Knoxville[Knoxville.length] = createMarker(new GPoint(-84.04631500,35.92890400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West Hills Baptist Preschool And Kindergarten",'Knoxville=' + Knoxville.length);
Knoxville[Knoxville.length] = createMarker(new GPoint(-84.08478700,35.91189500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cedar Springs Weekday School",'Knoxville=' + Knoxville.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.90891900,35.20629300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("True Light Heritage Place",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.84562900,35.08342100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Emmanuel United Methodist Kindergarten",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.99201400,35.15477300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Evergreen Presbyterian Kindergarten",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-90.00319600,35.13568500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Idlewild Presbyterian Kindergarten",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.84391700,35.09918500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Memphis Jewish Community Center",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.91688500,35.21546900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Raleigh United Meth Kindergarten",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.94543100,35.11837400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Luke's Day School",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.84853100,35.11142200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Temple Israel Kindergarten",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.94086700,35.11783700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("University Churches Early Chil",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.94576700,35.11948700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Highland St Church Of Christ Preschool & Kdgn",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.87225500,35.07420200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Children's World Learning Center",'Memphis=' + Memphis.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.80052400,36.20696200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Born Again Christian Academy",'Nashville=' + Nashville.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.81268200,36.06611800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Otter Creek Kindergarten Nursery School",'Nashville=' + Nashville.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.82371200,36.17072000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Schrader Lane Child Care Center",'Nashville=' + Nashville.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.82881400,36.16697600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tsu Early Learning Center",'Nashville=' + Nashville.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.83365800,36.13170200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Westminster Kindergarten",'Nashville=' + Nashville.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);
map.removeOverlays(Bartlett);
map.removeOverlays(Chattanooga);
map.removeOverlays(Clarksville);
map.removeOverlays(Cleveland);
map.removeOverlays(Collierville);
map.removeOverlays(Cookeville);
map.removeOverlays(Cordova);
map.removeOverlays(Germantown);
map.removeOverlays(Gray);
map.removeOverlays(Hendersonville);
map.removeOverlays(Jasper);
map.removeOverlays(Johnson_City);
map.removeOverlays(Kingsport);
map.removeOverlays(Knoxville);
map.removeOverlays(Memphis);
map.removeOverlays(Nashville);
map.removeOverlays(Signal_Mountai);
setTimeout(function(){map.addOverlays(Bartlett)},1000);
setTimeout(function(){map.addOverlays(Chattanooga)},1000);
setTimeout(function(){map.addOverlays(Clarksville)},1000);
setTimeout(function(){map.addOverlays(Cleveland)},1000);
setTimeout(function(){map.addOverlays(Collierville)},1000);
setTimeout(function(){map.addOverlays(Cookeville)},1000);
setTimeout(function(){map.addOverlays(Cordova)},1000);
setTimeout(function(){map.addOverlays(Germantown)},1000);
setTimeout(function(){map.addOverlays(Gray)},1000);
setTimeout(function(){map.addOverlays(Hendersonville)},1000);
setTimeout(function(){map.addOverlays(Jasper)},1000);
setTimeout(function(){map.addOverlays(Johnson_City)},1000);
setTimeout(function(){map.addOverlays(Kingsport)},1000);
setTimeout(function(){map.addOverlays(Knoxville)},1000);
setTimeout(function(){map.addOverlays(Memphis)},1000);
setTimeout(function(){map.addOverlays(Nashville)},1000);
setTimeout(function(){map.addOverlays(Signal_Mountai)},1000);
maxLng = -82.34964000;
maxLat = 36.55008000;
minLng = -90.00319600;
minLat = 35.04591800;
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(Bartlett);
map.removeOverlays(Chattanooga);
map.removeOverlays(Clarksville);
map.removeOverlays(Cleveland);
map.removeOverlays(Collierville);
map.removeOverlays(Cookeville);
map.removeOverlays(Cordova);
map.removeOverlays(Germantown);
map.removeOverlays(Gray);
map.removeOverlays(Hendersonville);
map.removeOverlays(Jasper);
map.removeOverlays(Johnson_City);
map.removeOverlays(Kingsport);
map.removeOverlays(Knoxville);
map.removeOverlays(Memphis);
map.removeOverlays(Nashville);
map.removeOverlays(Signal_Mountai);
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(Bartlett);map.removeOverlays(Bartlett);
map.removeOverlays(Chattanooga);
map.removeOverlays(Clarksville);
map.removeOverlays(Cleveland);
map.removeOverlays(Collierville);
map.removeOverlays(Cookeville);
map.removeOverlays(Cordova);
map.removeOverlays(Germantown);
map.removeOverlays(Gray);
map.removeOverlays(Hendersonville);
map.removeOverlays(Jasper);
map.removeOverlays(Johnson_City);
map.removeOverlays(Kingsport);
map.removeOverlays(Knoxville);
map.removeOverlays(Memphis);
map.removeOverlays(Nashville);
map.removeOverlays(Signal_Mountai);
map.addOverlays(Bartlett);
centerByArray(Bartlett, false, false);
cntMarker += Bartlett.length;
map.addOverlays(Chattanooga);
centerByArray(Chattanooga, false, false);
cntMarker += Chattanooga.length;
map.addOverlays(Clarksville);
centerByArray(Clarksville, false, false);
cntMarker += Clarksville.length;
map.addOverlays(Cleveland);
centerByArray(Cleveland, false, false);
cntMarker += Cleveland.length;
map.addOverlays(Collierville);
centerByArray(Collierville, false, false);
cntMarker += Collierville.length;
map.addOverlays(Cookeville);
centerByArray(Cookeville, false, false);
cntMarker += Cookeville.length;
map.addOverlays(Cordova);
centerByArray(Cordova, false, false);
cntMarker += Cordova.length;
map.addOverlays(Germantown);
centerByArray(Germantown, false, false);
cntMarker += Germantown.length;
map.addOverlays(Gray);
centerByArray(Gray, false, false);
cntMarker += Gray.length;
map.addOverlays(Hendersonville);
centerByArray(Hendersonville, false, false);
cntMarker += Hendersonville.length;
map.addOverlays(Jasper);
centerByArray(Jasper, false, false);
cntMarker += Jasper.length;
map.addOverlays(Johnson_City);
centerByArray(Johnson_City, false, false);
cntMarker += Johnson_City.length;
map.addOverlays(Kingsport);
centerByArray(Kingsport, false, false);
cntMarker += Kingsport.length;
map.addOverlays(Knoxville);
centerByArray(Knoxville, false, false);
cntMarker += Knoxville.length;
map.addOverlays(Memphis);
centerByArray(Memphis, false, false);
cntMarker += Memphis.length;
map.addOverlays(Nashville);
centerByArray(Nashville, false, false);
cntMarker += Nashville.length;
map.addOverlays(Signal_Mountai);
centerByArray(Signal_Mountai, false, false);
cntMarker += Signal_Mountai.length;
centerByArray(Bartlett,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=2&schools=&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;
}