function addMarkers(){
mySelect = document.getElementById('selection');
Memphis = [];Nashville = [];Knoxville = [];Hendersonville = [];La_Grange = [];Cordova = [];Lexington = [];Chattanooga = [];Franklin = [];Oak_Ridge = [];Louisville = [];Portland = [];mySelect.options[mySelect.options.length] = new Option("Chattanooga schools",'all=Chattanooga');
mySelect.options[mySelect.options.length] = new Option("Cordova schools",'all=Cordova');
mySelect.options[mySelect.options.length] = new Option("Franklin schools",'all=Franklin');
mySelect.options[mySelect.options.length] = new Option("Hendersonville schools",'all=Hendersonville');
mySelect.options[mySelect.options.length] = new Option("Knoxville schools",'all=Knoxville');
mySelect.options[mySelect.options.length] = new Option("La Grange schools",'all=La_Grange');
mySelect.options[mySelect.options.length] = new Option("Lexington schools",'all=Lexington');
mySelect.options[mySelect.options.length] = new Option("Louisville schools",'all=Louisville');
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("Oak Ridge schools",'all=Oak_Ridge');
mySelect.options[mySelect.options.length] = new Option("Portland schools",'all=Portland');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Memphis[Memphis.length] = createMarker(new GPoint(-90.01732600,35.13276200),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("1st Class Montessori Preschool",'Memphis=' + Memphis.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.89780400,36.11783300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Abintra Montessori School",'Nashville=' + Nashville.length);
Memphis[Memphis.length] = createMarker(new GPoint(-90.00575000,35.14323700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cendrillon Montessori School",'Memphis=' + Memphis.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.79961300,36.11433700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Children's House Of Nashville",'Nashville=' + Nashville.length);
Knoxville[Knoxville.length] = createMarker(new GPoint(-84.15476600,35.88361300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Farragut Montessori School",'Knoxville=' + Knoxville.length);
Knoxville[Knoxville.length] = createMarker(new GPoint(-83.92819000,36.04135700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Garden Montessori School",'Knoxville=' + Knoxville.length);
Knoxville[Knoxville.length] = createMarker(new GPoint(-84.12670000,35.86550000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Giving Tree Montessori",'Knoxville=' + Knoxville.length);
Hendersonville[Hendersonville.length] = createMarker(new GPoint(-86.63392700,36.36927300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Honeysuckle Montessori School",'Hendersonville=' + Hendersonville.length);
Knoxville[Knoxville.length] = createMarker(new GPoint(-83.97651600,35.94181500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Knoxville Montessori School",'Knoxville=' + Knoxville.length);
La_Grange[La_Grange.length] = createMarker(new GPoint(-89.24359200,35.04896000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("La Grange Montessori School",'La_Grange=' + La_Grange.length);
Cordova[Cordova.length] = createMarker(new GPoint(-89.77647000,35.15475500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lamplighter School",'Cordova=' + Cordova.length);
Lexington[Lexington.length] = createMarker(new GPoint(-88.39558800,35.65114400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lexington Montessori Center",'Lexington=' + Lexington.length);
Memphis[Memphis.length] = createMarker(new GPoint(-90.05358000,35.16191200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Maria Montessori School",'Memphis=' + Memphis.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.80284200,36.08902200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Centre",'Nashville=' + Nashville.length);
Knoxville[Knoxville.length] = createMarker(new GPoint(-84.09172300,35.85487400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Internationale School",'Knoxville=' + Knoxville.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.28660400,35.04016100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School",'Chattanooga=' + Chattanooga.length);
Franklin[Franklin.length] = createMarker(new GPoint(-86.88433800,35.91440400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School Of Franklin",'Franklin=' + Franklin.length);
Oak_Ridge[Oak_Ridge.length] = createMarker(new GPoint(-84.23444600,36.01940200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School Of Oak Ridge",'Oak_Ridge=' + Oak_Ridge.length);
Knoxville[Knoxville.length] = createMarker(new GPoint(-83.87884200,36.05672700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Natures Way Montessori School",'Knoxville=' + Knoxville.length);
Louisville[Louisville.length] = createMarker(new GPoint(-83.96087700,35.85193900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Horizon Montessori School",'Louisville=' + Louisville.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.81497600,35.20019700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Olivia's Montessori Preschool",'Memphis=' + Memphis.length);
Portland[Portland.length] = createMarker(new GPoint(-86.53341400,36.58460500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Portland Montessori Academy",'Portland=' + Portland.length);
map.removeOverlays(Chattanooga);
map.removeOverlays(Cordova);
map.removeOverlays(Franklin);
map.removeOverlays(Hendersonville);
map.removeOverlays(Knoxville);
map.removeOverlays(La_Grange);
map.removeOverlays(Lexington);
map.removeOverlays(Louisville);
map.removeOverlays(Memphis);
map.removeOverlays(Nashville);
map.removeOverlays(Oak_Ridge);
map.removeOverlays(Portland);
setTimeout(function(){map.addOverlays(Chattanooga)},1000);
setTimeout(function(){map.addOverlays(Cordova)},1000);
setTimeout(function(){map.addOverlays(Franklin)},1000);
setTimeout(function(){map.addOverlays(Hendersonville)},1000);
setTimeout(function(){map.addOverlays(Knoxville)},1000);
setTimeout(function(){map.addOverlays(La_Grange)},1000);
setTimeout(function(){map.addOverlays(Lexington)},1000);
setTimeout(function(){map.addOverlays(Louisville)},1000);
setTimeout(function(){map.addOverlays(Memphis)},1000);
setTimeout(function(){map.addOverlays(Nashville)},1000);
setTimeout(function(){map.addOverlays(Oak_Ridge)},1000);
setTimeout(function(){map.addOverlays(Portland)},1000);
maxLng = -83.87884200;
maxLat = 36.58460500;
minLng = -90.05358000;
minLat = 35.04016100;
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(Chattanooga);
map.removeOverlays(Cordova);
map.removeOverlays(Franklin);
map.removeOverlays(Hendersonville);
map.removeOverlays(Knoxville);
map.removeOverlays(La_Grange);
map.removeOverlays(Lexington);
map.removeOverlays(Louisville);
map.removeOverlays(Memphis);
map.removeOverlays(Nashville);
map.removeOverlays(Oak_Ridge);
map.removeOverlays(Portland);
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(Memphis);map.removeOverlays(Chattanooga);
map.removeOverlays(Cordova);
map.removeOverlays(Franklin);
map.removeOverlays(Hendersonville);
map.removeOverlays(Knoxville);
map.removeOverlays(La_Grange);
map.removeOverlays(Lexington);
map.removeOverlays(Louisville);
map.removeOverlays(Memphis);
map.removeOverlays(Nashville);
map.removeOverlays(Oak_Ridge);
map.removeOverlays(Portland);
map.addOverlays(Chattanooga);
centerByArray(Chattanooga, false, false);
cntMarker += Chattanooga.length;
map.addOverlays(Cordova);
centerByArray(Cordova, false, false);
cntMarker += Cordova.length;
map.addOverlays(Franklin);
centerByArray(Franklin, false, false);
cntMarker += Franklin.length;
map.addOverlays(Hendersonville);
centerByArray(Hendersonville, false, false);
cntMarker += Hendersonville.length;
map.addOverlays(Knoxville);
centerByArray(Knoxville, false, false);
cntMarker += Knoxville.length;
map.addOverlays(La_Grange);
centerByArray(La_Grange, false, false);
cntMarker += La_Grange.length;
map.addOverlays(Lexington);
centerByArray(Lexington, false, false);
cntMarker += Lexington.length;
map.addOverlays(Louisville);
centerByArray(Louisville, false, false);
cntMarker += Louisville.length;
map.addOverlays(Memphis);
centerByArray(Memphis, false, false);
cntMarker += Memphis.length;
map.addOverlays(Nashville);
centerByArray(Nashville, false, false);
cntMarker += Nashville.length;
map.addOverlays(Oak_Ridge);
centerByArray(Oak_Ridge, false, false);
cntMarker += Oak_Ridge.length;
map.addOverlays(Portland);
centerByArray(Portland, false, false);
cntMarker += Portland.length;
centerByArray(Memphis,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///26200,26152,34619,32956,26336,26062,26066,26148,26199,26216,31825,26398,26221,25906,26393,26175,26230,25908,25979,26197,26198,32961,/all');
//window.open('/map.php?type=2&schools=26200,26152,34619,32956,26336,26062,26066,26148,26199,26216,31825,26398,26221,25906,26393,26175,26230,25908,25979,26197,26198,32961,&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;
}