function addMarkers()
{
mySelect = document.getElementById('selection');
Fort_Oglethorpe = [];Ft_Oglethorpe = [];Ringgold = [];Rossville = [];Tunnel_Hill = [];Rock_Spring = [];mySelect.options[mySelect.options.length] = new Option("Fort Oglethorpe schools",'all=Fort_Oglethorpe');
mySelect.options[mySelect.options.length] = new Option("Ft Oglethorpe schools",'all=Ft_Oglethorpe');
mySelect.options[mySelect.options.length] = new Option("Ringgold schools",'all=Ringgold');
mySelect.options[mySelect.options.length] = new Option("Rock Spring schools",'all=Rock_Spring');
mySelect.options[mySelect.options.length] = new Option("Rossville schools",'all=Rossville');
mySelect.options[mySelect.options.length] = new Option("Tunnel Hill schools",'all=Tunnel_Hill');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Fort_Oglethorpe[Fort_Oglethorpe.length] = createMarker(new GPoint(-85.23009491,34.94578171),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Battlefield Elementary School",'Fort_Oglethorpe=' + Fort_Oglethorpe.length);
Ft_Oglethorpe[Ft_Oglethorpe.length] = createMarker(new GPoint(-85.28227997,34.95132065),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Battlefield Primary",'Ft_Oglethorpe=' + Ft_Oglethorpe.length);
Ringgold[Ringgold.length] = createMarker(new GPoint(-85.14910889,34.91897583),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Boynton Elementary School",'Ringgold=' + Ringgold.length);
Ringgold[Ringgold.length] = createMarker(new GPoint(-85.11051941,34.91365814),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Catoosa County Public Schools Prekindergarten",'Ringgold=' + Ringgold.length);
Fort_Oglethorpe[Fort_Oglethorpe.length] = createMarker(new GPoint(-85.28227997,34.95132065),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Catoosa Crossroads Academy",'Fort_Oglethorpe=' + Fort_Oglethorpe.length);
Rossville[Rossville.length] = createMarker(new GPoint(-85.24863434,34.96346283),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cloud Springs Elementary School",'Rossville=' + Rossville.length);
Ringgold[Ringgold.length] = createMarker(new GPoint(-85.15666199,34.97009659),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Graysville Elementary School",'Ringgold=' + Ringgold.length);
Ringgold[Ringgold.length] = createMarker(new GPoint(-10.00000000,10.00000000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Heritage Middle School",'Ringgold=' + Ringgold.length);
Rossville[Rossville.length] = createMarker(new GPoint(-85.25636292,34.97370148),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Lakeview Middle School",'Rossville=' + Rossville.length);
Fort_Oglethorpe[Fort_Oglethorpe.length] = createMarker(new GPoint(-85.23531342,34.94815063),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lakeview-fort Oglethorpe High School",'Fort_Oglethorpe=' + Fort_Oglethorpe.length);
Ringgold[Ringgold.length] = createMarker(new GPoint(-85.11051941,34.91365814),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northwest Psychoeducational Program",'Ringgold=' + Ringgold.length);
Ringgold[Ringgold.length] = createMarker(new GPoint(-85.14199066,34.89952850),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ringgold Elementary School",'Ringgold=' + Ringgold.length);
Ringgold[Ringgold.length] = createMarker(new GPoint(-85.11061096,34.92092514),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ringgold High School",'Ringgold=' + Ringgold.length);
Ringgold[Ringgold.length] = createMarker(new GPoint(-85.11329651,34.92096329),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Ringgold Middle School",'Ringgold=' + Ringgold.length);
Ringgold[Ringgold.length] = createMarker(new GPoint(-85.14209747,34.89972687),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ringgold Primary School",'Ringgold=' + Ringgold.length);
Tunnel_Hill[Tunnel_Hill.length] = createMarker(new GPoint(-85.07298279,34.90414810),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Tiger Creek Elementary School",'Tunnel_Hill=' + Tunnel_Hill.length);
Rossville[Rossville.length] = createMarker(new GPoint(-85.22360229,34.96009827),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("West Side Elementary School",'Rossville=' + Rossville.length);
Rock_Spring[Rock_Spring.length] = createMarker(new GPoint(-85.16050900,34.77882400),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Woodstation Elementary School",'Rock_Spring=' + Rock_Spring.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,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(Fort_Oglethorpe);
map.removeOverlays(Ft_Oglethorpe);
map.removeOverlays(Ringgold);
map.removeOverlays(Rock_Spring);
map.removeOverlays(Rossville);
map.removeOverlays(Tunnel_Hill);
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(Fort_Oglethorpe);map.removeOverlays(Fort_Oglethorpe);
map.removeOverlays(Ft_Oglethorpe);
map.removeOverlays(Ringgold);
map.removeOverlays(Rock_Spring);
map.removeOverlays(Rossville);
map.removeOverlays(Tunnel_Hill);
map.addOverlays(Fort_Oglethorpe);
centerByArray(Fort_Oglethorpe, false, false);
cntMarker += Fort_Oglethorpe.length;
map.addOverlays(Ft_Oglethorpe);
centerByArray(Ft_Oglethorpe, false, false);
cntMarker += Ft_Oglethorpe.length;
map.addOverlays(Ringgold);
centerByArray(Ringgold, false, false);
cntMarker += Ringgold.length;
map.addOverlays(Rock_Spring);
centerByArray(Rock_Spring, false, false);
cntMarker += Rock_Spring.length;
map.addOverlays(Rossville);
centerByArray(Rossville, false, false);
cntMarker += Rossville.length;
map.addOverlays(Tunnel_Hill);
centerByArray(Tunnel_Hill, false, false);
cntMarker += Tunnel_Hill.length;
centerByArray(Fort_Oglethorpe,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');
}
}