function addMarkers()
{
mySelect = document.getElementById('selection');
Clinton = [];Camden = [];Knoxville = [];Huntingdon = [];Memphis = [];Greenville = [];Ooltewah = [];Chattanooga = [];Harriman = [];Wartburg = [];Union_City = [];Dunlap = [];Soddy_Daisy = [];Carthage = [];Red_Boiling_Springs = [];Waynesboro = [];Lebanon = [];mySelect.options[mySelect.options.length] = new Option("Camden vocational schools",'all=Camden');
mySelect.options[mySelect.options.length] = new Option("Carthage vocational schools",'all=Carthage');
mySelect.options[mySelect.options.length] = new Option("Chattanooga vocational schools",'all=Chattanooga');
mySelect.options[mySelect.options.length] = new Option("Clinton vocational schools",'all=Clinton');
mySelect.options[mySelect.options.length] = new Option("Dunlap vocational schools",'all=Dunlap');
mySelect.options[mySelect.options.length] = new Option("Greenville vocational schools",'all=Greenville');
mySelect.options[mySelect.options.length] = new Option("Harriman vocational schools",'all=Harriman');
mySelect.options[mySelect.options.length] = new Option("Huntingdon vocational schools",'all=Huntingdon');
mySelect.options[mySelect.options.length] = new Option("Knoxville vocational schools",'all=Knoxville');
mySelect.options[mySelect.options.length] = new Option("Lebanon vocational schools",'all=Lebanon');
mySelect.options[mySelect.options.length] = new Option("Memphis vocational schools",'all=Memphis');
mySelect.options[mySelect.options.length] = new Option("Ooltewah vocational schools",'all=Ooltewah');
mySelect.options[mySelect.options.length] = new Option("Red Boiling Springs vocational schools",'all=Red_Boiling_Springs');
mySelect.options[mySelect.options.length] = new Option("Soddy Daisy vocational schools",'all=Soddy_Daisy');
mySelect.options[mySelect.options.length] = new Option("Union City vocational schools",'all=Union_City');
mySelect.options[mySelect.options.length] = new Option("Wartburg vocational schools",'all=Wartburg');
mySelect.options[mySelect.options.length] = new Option("Waynesboro vocational schools",'all=Waynesboro');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Clinton[Clinton.length] = createMarker(new GPoint(-84.08020020,36.16830063),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Anderson Co. Career Technical Center",'Clinton=' + Clinton.length);
Camden[Camden.length] = createMarker(new GPoint(-88.10882300,36.07295100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Benton County Career/technical Center",'Camden=' + Camden.length);
Knoxville[Knoxville.length] = createMarker(new GPoint(-84.12648773,35.96823883),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Byington Solway Vocational High School",'Knoxville=' + Knoxville.length);
Huntingdon[Huntingdon.length] = createMarker(new GPoint(-88.38517761,36.00449371),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Carroll County Technical Center",'Huntingdon=' + Huntingdon.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.95401001,35.13344193),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("East Career Technology Center",'Memphis=' + Memphis.length);
Greenville[Greenville.length] = createMarker(new GPoint(-82.88091278,36.15574265),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Greene Vocational Center",'Greenville=' + Greenville.length);
Ooltewah[Ooltewah.length] = createMarker(new GPoint(-85.05709839,35.18177032),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Harrison Bay Vocational Center",'Ooltewah=' + Ooltewah.length);
Chattanooga[Chattanooga.length] = createMarker(new GPoint(-85.31099701,35.02642441),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Howard Academy Of Academics Technology",'Chattanooga=' + Chattanooga.length);
Memphis[Memphis.length] = createMarker(new GPoint(-90.06508636,35.11024857),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kansas Career And Technical Center",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.92607880,35.16793442),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kingsbury Vocational School",'Memphis=' + Memphis.length);
Harriman[Harriman.length] = createMarker(new GPoint(-84.57472229,35.87206650),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Midtown Educational Center",'Harriman=' + Harriman.length);
Wartburg[Wartburg.length] = createMarker(new GPoint(-84.55332184,36.09889603),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Morgan County Vocational Center",'Wartburg=' + Wartburg.length);
Knoxville[Knoxville.length] = createMarker(new GPoint(-83.92398834,36.08848953),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Knox Vocational Center",'Knoxville=' + Knoxville.length);
Union_City[Union_City.length] = createMarker(new GPoint(-89.05767822,36.44226837),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Obion-lake Vocational Center",'Union_City=' + Union_City.length);
Dunlap[Dunlap.length] = createMarker(new GPoint(-85.39040375,35.38349915),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Seq Bledsoe Vocational Center",'Dunlap=' + Dunlap.length);
Soddy_Daisy[Soddy_Daisy.length] = createMarker(new GPoint(-85.14064300,35.23142300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sequoyah Technology Center",'Soddy_Daisy=' + Soddy_Daisy.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.91851044,35.05722046),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sheffield Vocational High School",'Memphis=' + Memphis.length);
Carthage[Carthage.length] = createMarker(new GPoint(-85.95110321,36.21852875),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Smith County Vocational Center",'Carthage=' + Carthage.length);
Memphis[Memphis.length] = createMarker(new GPoint(-90.06932831,35.04656982),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Southwest Career And Technical School",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.97543335,35.21356201),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trezevant Career And Technical School",'Memphis=' + Memphis.length);
Red_Boiling_Springs[Red_Boiling_Springs.length] = createMarker(new GPoint(-85.83000183,36.54029846),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tri County Vocational Center",'Red_Boiling_Springs=' + Red_Boiling_Springs.length);
Waynesboro[Waynesboro.length] = createMarker(new GPoint(-87.76250458,35.30487823),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wayne County Vocational Center",'Waynesboro=' + Waynesboro.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-86.28493500,36.20276260),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wilson County Vocational Center",'Lebanon=' + Lebanon.length);
maxLng = -82.88091278;
maxLat = 36.54029846;
minLng = -90.06932831;
minLat = 35.02642441;
reCenterMap();
map.removeOverlays(Camden);
map.removeOverlays(Carthage);
map.removeOverlays(Chattanooga);
map.removeOverlays(Clinton);
map.removeOverlays(Dunlap);
map.removeOverlays(Greenville);
map.removeOverlays(Harriman);
map.removeOverlays(Huntingdon);
map.removeOverlays(Knoxville);
map.removeOverlays(Lebanon);
map.removeOverlays(Memphis);
map.removeOverlays(Ooltewah);
map.removeOverlays(Red_Boiling_Springs);
map.removeOverlays(Soddy_Daisy);
map.removeOverlays(Union_City);
map.removeOverlays(Wartburg);
map.removeOverlays(Waynesboro);
setTimeout(function(){map.addOverlays(Camden)},1000);
setTimeout(function(){map.addOverlays(Carthage)},1000);
setTimeout(function(){map.addOverlays(Chattanooga)},1000);
setTimeout(function(){map.addOverlays(Clinton)},1000);
setTimeout(function(){map.addOverlays(Dunlap)},1000);
setTimeout(function(){map.addOverlays(Greenville)},1000);
setTimeout(function(){map.addOverlays(Harriman)},1000);
setTimeout(function(){map.addOverlays(Huntingdon)},1000);
setTimeout(function(){map.addOverlays(Knoxville)},1000);
setTimeout(function(){map.addOverlays(Lebanon)},1000);
setTimeout(function(){map.addOverlays(Memphis)},1000);
setTimeout(function(){map.addOverlays(Ooltewah)},1000);
setTimeout(function(){map.addOverlays(Red_Boiling_Springs)},1000);
setTimeout(function(){map.addOverlays(Soddy_Daisy)},1000);
setTimeout(function(){map.addOverlays(Union_City)},1000);
setTimeout(function(){map.addOverlays(Wartburg)},1000);
setTimeout(function(){map.addOverlays(Waynesboro)},1000);
} // 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,10);
/*
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(Camden);
map.removeOverlays(Carthage);
map.removeOverlays(Chattanooga);
map.removeOverlays(Clinton);
map.removeOverlays(Dunlap);
map.removeOverlays(Greenville);
map.removeOverlays(Harriman);
map.removeOverlays(Huntingdon);
map.removeOverlays(Knoxville);
map.removeOverlays(Lebanon);
map.removeOverlays(Memphis);
map.removeOverlays(Ooltewah);
map.removeOverlays(Red_Boiling_Springs);
map.removeOverlays(Soddy_Daisy);
map.removeOverlays(Union_City);
map.removeOverlays(Wartburg);
map.removeOverlays(Waynesboro);
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(Clinton);map.removeOverlays(Camden);
map.removeOverlays(Carthage);
map.removeOverlays(Chattanooga);
map.removeOverlays(Clinton);
map.removeOverlays(Dunlap);
map.removeOverlays(Greenville);
map.removeOverlays(Harriman);
map.removeOverlays(Huntingdon);
map.removeOverlays(Knoxville);
map.removeOverlays(Lebanon);
map.removeOverlays(Memphis);
map.removeOverlays(Ooltewah);
map.removeOverlays(Red_Boiling_Springs);
map.removeOverlays(Soddy_Daisy);
map.removeOverlays(Union_City);
map.removeOverlays(Wartburg);
map.removeOverlays(Waynesboro);
map.addOverlays(Camden);
centerByArray(Camden, false, false);
cntMarker += Camden.length;
map.addOverlays(Carthage);
centerByArray(Carthage, false, false);
cntMarker += Carthage.length;
map.addOverlays(Chattanooga);
centerByArray(Chattanooga, false, false);
cntMarker += Chattanooga.length;
map.addOverlays(Clinton);
centerByArray(Clinton, false, false);
cntMarker += Clinton.length;
map.addOverlays(Dunlap);
centerByArray(Dunlap, false, false);
cntMarker += Dunlap.length;
map.addOverlays(Greenville);
centerByArray(Greenville, false, false);
cntMarker += Greenville.length;
map.addOverlays(Harriman);
centerByArray(Harriman, false, false);
cntMarker += Harriman.length;
map.addOverlays(Huntingdon);
centerByArray(Huntingdon, false, false);
cntMarker += Huntingdon.length;
map.addOverlays(Knoxville);
centerByArray(Knoxville, false, false);
cntMarker += Knoxville.length;
map.addOverlays(Lebanon);
centerByArray(Lebanon, false, false);
cntMarker += Lebanon.length;
map.addOverlays(Memphis);
centerByArray(Memphis, false, false);
cntMarker += Memphis.length;
map.addOverlays(Ooltewah);
centerByArray(Ooltewah, false, false);
cntMarker += Ooltewah.length;
map.addOverlays(Red_Boiling_Springs);
centerByArray(Red_Boiling_Springs, false, false);
cntMarker += Red_Boiling_Springs.length;
map.addOverlays(Soddy_Daisy);
centerByArray(Soddy_Daisy, false, false);
cntMarker += Soddy_Daisy.length;
map.addOverlays(Union_City);
centerByArray(Union_City, false, false);
cntMarker += Union_City.length;
map.addOverlays(Wartburg);
centerByArray(Wartburg, false, false);
cntMarker += Wartburg.length;
map.addOverlays(Waynesboro);
centerByArray(Waynesboro, false, false);
cntMarker += Waynesboro.length;
centerByArray(Clinton,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');
}
}