function addMarkers()
{
mySelect = document.getElementById('selection');
Adairsville = [];Acworth = [];Cartersville = [];Emerson = [];Kingston = [];Rydal = [];Taylorsville = [];White = [];mySelect.options[mySelect.options.length] = new Option("Acworth schools",'all=Acworth');
mySelect.options[mySelect.options.length] = new Option("Adairsville schools",'all=Adairsville');
mySelect.options[mySelect.options.length] = new Option("Cartersville schools",'all=Cartersville');
mySelect.options[mySelect.options.length] = new Option("Emerson schools",'all=Emerson');
mySelect.options[mySelect.options.length] = new Option("Kingston schools",'all=Kingston');
mySelect.options[mySelect.options.length] = new Option("Rydal schools",'all=Rydal');
mySelect.options[mySelect.options.length] = new Option("Taylorsville schools",'all=Taylorsville');
mySelect.options[mySelect.options.length] = new Option("White schools",'all=White');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Adairsville[Adairsville.length] = createMarker(new GPoint(-84.93721771,34.37057114),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Adairsville Elementary School",'Adairsville=' + Adairsville.length);
Adairsville[Adairsville.length] = createMarker(new GPoint(-84.93566895,34.36833572),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Adairsville High School",'Adairsville=' + Adairsville.length);
Adairsville[Adairsville.length] = createMarker(new GPoint(-84.93923950,34.36898041),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Adairsville Middle School",'Adairsville=' + Adairsville.length);
Acworth[Acworth.length] = createMarker(new GPoint(-84.67690277,34.06531906),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Allatoona Elementary School",'Acworth=' + Acworth.length);
Cartersville[Cartersville.length] = createMarker(new GPoint(-84.79154205,34.15802002),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bartow Crossroads Academy",'Cartersville=' + Cartersville.length);
Cartersville[Cartersville.length] = createMarker(new GPoint(-84.81542969,34.15111542),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cartersville Elementary School",'Cartersville=' + Cartersville.length);
Cartersville[Cartersville.length] = createMarker(new GPoint(-84.78845978,34.16907883),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cartersville High School",'Cartersville=' + Cartersville.length);
Cartersville[Cartersville.length] = createMarker(new GPoint(-84.82033539,34.12806320),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Cartersville Middle School",'Cartersville=' + Cartersville.length);
Cartersville[Cartersville.length] = createMarker(new GPoint(-84.80969238,34.15011597),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cartersville Primary School",'Cartersville=' + Cartersville.length);
Cartersville[Cartersville.length] = createMarker(new GPoint(-84.81857300,34.22555161),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cass High School",'Cartersville=' + Cartersville.length);
Cartersville[Cartersville.length] = createMarker(new GPoint(-84.86552429,34.24217606),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Cass Middle School",'Cartersville=' + Cartersville.length);
Cartersville[Cartersville.length] = createMarker(new GPoint(-84.80188000,34.19681500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cloverleaf Elementary School",'Cartersville=' + Cartersville.length);
Emerson[Emerson.length] = createMarker(new GPoint(-84.75826263,34.12251663),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Emerson Elementary School",'Emerson=' + Emerson.length);
Kingston[Kingston.length] = createMarker(new GPoint(-84.92649078,34.14779663),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Euharlee Elementary School",'Kingston=' + Kingston.length);
Cartersville[Cartersville.length] = createMarker(new GPoint(-84.86982727,34.22454834),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hamilton Crossing Elementary School",'Cartersville=' + Cartersville.length);
Kingston[Kingston.length] = createMarker(new GPoint(-84.93474579,34.21547699),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kingston Elementary School",'Kingston=' + Kingston.length);
Cartersville[Cartersville.length] = createMarker(new GPoint(-84.87856293,34.16163635),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mission Road Elementary School",'Cartersville=' + Cartersville.length);
Rydal[Rydal.length] = createMarker(new GPoint(-84.77154541,34.35433578),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pine Log Elementary School",'Rydal=' + Rydal.length);
Emerson[Emerson.length] = createMarker(new GPoint(-84.75715637,34.12176514),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("South Central Middle School",'Emerson=' + Emerson.length);
Cartersville[Cartersville.length] = createMarker(new GPoint(-84.79154205,34.15802002),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Stars Preschool Center",'Cartersville=' + Cartersville.length);
Taylorsville[Taylorsville.length] = createMarker(new GPoint(-84.94909668,34.10868073),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Taylorsville Elementary School",'Taylorsville=' + Taylorsville.length);
White[White.length] = createMarker(new GPoint(-84.75879669,34.26819992),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("White Elementary School",'White=' + White.length);
Cartersville[Cartersville.length] = createMarker(new GPoint(-84.83045959,34.11682510),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Woodland High School",'Cartersville=' + Cartersville.length);
Kingston[Kingston.length] = createMarker(new GPoint(-84.92681885,34.14751816),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Woodland Middle School At Euharlee",'Kingston=' + Kingston.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(Acworth);
map.removeOverlays(Adairsville);
map.removeOverlays(Cartersville);
map.removeOverlays(Emerson);
map.removeOverlays(Kingston);
map.removeOverlays(Rydal);
map.removeOverlays(Taylorsville);
map.removeOverlays(White);
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(Adairsville);map.removeOverlays(Acworth);
map.removeOverlays(Adairsville);
map.removeOverlays(Cartersville);
map.removeOverlays(Emerson);
map.removeOverlays(Kingston);
map.removeOverlays(Rydal);
map.removeOverlays(Taylorsville);
map.removeOverlays(White);
map.addOverlays(Acworth);
centerByArray(Acworth, false, false);
cntMarker += Acworth.length;
map.addOverlays(Adairsville);
centerByArray(Adairsville, false, false);
cntMarker += Adairsville.length;
map.addOverlays(Cartersville);
centerByArray(Cartersville, false, false);
cntMarker += Cartersville.length;
map.addOverlays(Emerson);
centerByArray(Emerson, false, false);
cntMarker += Emerson.length;
map.addOverlays(Kingston);
centerByArray(Kingston, false, false);
cntMarker += Kingston.length;
map.addOverlays(Rydal);
centerByArray(Rydal, false, false);
cntMarker += Rydal.length;
map.addOverlays(Taylorsville);
centerByArray(Taylorsville, false, false);
cntMarker += Taylorsville.length;
map.addOverlays(White);
centerByArray(White, false, false);
cntMarker += White.length;
centerByArray(Adairsville,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');
}
}