function addMarkers()
{
mySelect = document.getElementById('selection');
Wagener = [];Langley = [];Aiken = [];Belvedere = [];Graniteville = [];Clearwater = [];Gloverville = [];New_Ellenton = [];N_Augusta = [];Jackson = [];Bath = [];North_Augusta = [];Ridge_Spring = [];Monetta = [];Warrenville = [];mySelect.options[mySelect.options.length] = new Option("Aiken schools",'all=Aiken');
mySelect.options[mySelect.options.length] = new Option("Bath schools",'all=Bath');
mySelect.options[mySelect.options.length] = new Option("Belvedere schools",'all=Belvedere');
mySelect.options[mySelect.options.length] = new Option("Clearwater schools",'all=Clearwater');
mySelect.options[mySelect.options.length] = new Option("Gloverville schools",'all=Gloverville');
mySelect.options[mySelect.options.length] = new Option("Graniteville schools",'all=Graniteville');
mySelect.options[mySelect.options.length] = new Option("Jackson schools",'all=Jackson');
mySelect.options[mySelect.options.length] = new Option("Langley schools",'all=Langley');
mySelect.options[mySelect.options.length] = new Option("Monetta schools",'all=Monetta');
mySelect.options[mySelect.options.length] = new Option("N Augusta schools",'all=N_Augusta');
mySelect.options[mySelect.options.length] = new Option("New Ellenton schools",'all=New_Ellenton');
mySelect.options[mySelect.options.length] = new Option("North Augusta schools",'all=North_Augusta');
mySelect.options[mySelect.options.length] = new Option("Ridge Spring schools",'all=Ridge_Spring');
mySelect.options[mySelect.options.length] = new Option("Wagener schools",'all=Wagener');
mySelect.options[mySelect.options.length] = new Option("Warrenville schools",'all=Warrenville');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Wagener[Wagener.length] = createMarker(new GPoint(-81.40380096,33.65660095),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("A L Corbett Middle School",'Wagener=' + Wagener.length);
Langley[Langley.length] = createMarker(new GPoint(-81.84408100,33.51794400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Aiken County Career & Technical Center",'Langley=' + Langley.length);
Aiken[Aiken.length] = createMarker(new GPoint(-81.76790619,33.52689362),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Aiken Elementary School",'Aiken=' + Aiken.length);
Aiken[Aiken.length] = createMarker(new GPoint(-81.71746063,33.57984161),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Aiken High/aiken High Annex",'Aiken=' + Aiken.length);
Aiken[Aiken.length] = createMarker(new GPoint(-81.69034576,33.58011246),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Aiken Middle School",'Aiken=' + Aiken.length);
Aiken[Aiken.length] = createMarker(new GPoint(-81.72016600,33.56674400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Aiken Performing Arts Academy (charter)",'Aiken=' + Aiken.length);
Belvedere[Belvedere.length] = createMarker(new GPoint(-81.93787384,33.52822113),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Belvedere Elementary School",'Belvedere=' + Belvedere.length);
Graniteville[Graniteville.length] = createMarker(new GPoint(-81.81781006,33.57001495),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Byrd Elementary School",'Graniteville=' + Graniteville.length);
Aiken[Aiken.length] = createMarker(new GPoint(-81.71377563,33.48216629),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Chukker Creek Elementary School",'Aiken=' + Aiken.length);
Clearwater[Clearwater.length] = createMarker(new GPoint(-81.89219666,33.49660110),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clearwater Elementary School",'Clearwater=' + Clearwater.length);
Wagener[Wagener.length] = createMarker(new GPoint(-81.36426544,33.64730072),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cyril B Busbee Elementary School",'Wagener=' + Wagener.length);
Aiken[Aiken.length] = createMarker(new GPoint(-81.67475891,33.55002975),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("East Aiken Elementary School",'Aiken=' + Aiken.length);
Gloverville[Gloverville.length] = createMarker(new GPoint(-81.82730103,33.52479935),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Gloverville Elementary School",'Gloverville=' + Gloverville.length);
New_Ellenton[New_Ellenton.length] = createMarker(new GPoint(-81.67874146,33.40770340),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Greendale Elementary School",'New_Ellenton=' + New_Ellenton.length);
N_Augusta[N_Augusta.length] = createMarker(new GPoint(-81.98359680,33.51131439),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hammond Hill Elementary School",'N_Augusta=' + N_Augusta.length);
Aiken[Aiken.length] = createMarker(new GPoint(-81.67544556,33.64611816),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("J D Lever Elementary School",'Aiken=' + Aiken.length);
Jackson[Jackson.length] = createMarker(new GPoint(-81.79370880,33.34254837),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Jackson Middle School",'Jackson=' + Jackson.length);
Bath[Bath.length] = createMarker(new GPoint(-81.86910248,33.50439835),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'Bath=' + Bath.length);
Aiken[Aiken.length] = createMarker(new GPoint(-81.72035980,33.56673050),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Kennedy/lloyd Charter School",'Aiken=' + Aiken.length);
Langley[Langley.length] = createMarker(new GPoint(-81.84410095,33.51770020),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Langley Bath Clearwater Middle School",'Langley=' + Langley.length);
Graniteville[Graniteville.length] = createMarker(new GPoint(-81.80705261,33.56742477),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Leavelle Mccampbell Middle School",'Graniteville=' + Graniteville.length);
Langley[Langley.length] = createMarker(new GPoint(-81.84410095,33.51770020),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Midland Valley High School",'Langley=' + Langley.length);
Graniteville[Graniteville.length] = createMarker(new GPoint(-81.84353638,33.53015518),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Midland Valley Preparatory School",'Graniteville=' + Graniteville.length);
Aiken[Aiken.length] = createMarker(new GPoint(-81.71438599,33.52562714),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Millbrook Elementary School",'Aiken=' + Aiken.length);
Aiken[Aiken.length] = createMarker(new GPoint(-81.71387482,33.52552032),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Minnie B Kennedy Middle School",'Aiken=' + Aiken.length);
North_Augusta[North_Augusta.length] = createMarker(new GPoint(-81.96023000,33.54257400),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mossy Creek Elementary School",'North_Augusta=' + North_Augusta.length);
New_Ellenton[New_Ellenton.length] = createMarker(new GPoint(-81.68479919,33.39979935),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("New Ellenton Middle School",'New_Ellenton=' + New_Ellenton.length);
N_Augusta[N_Augusta.length] = createMarker(new GPoint(-81.96789551,33.49412537),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("North Augusta Elementary School",'N_Augusta=' + N_Augusta.length);
North_Augusta[North_Augusta.length] = createMarker(new GPoint(-81.97270966,33.53276825),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Augusta High School",'North_Augusta=' + North_Augusta.length);
N_Augusta[N_Augusta.length] = createMarker(new GPoint(-81.95214081,33.49841690),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("North Augusta Middle School",'N_Augusta=' + N_Augusta.length);
Aiken[Aiken.length] = createMarker(new GPoint(-81.57569885,33.51431274),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Oakwood- Windsor Elementary School",'Aiken=' + Aiken.length);
North_Augusta[North_Augusta.length] = createMarker(new GPoint(-81.97248077,33.52876663),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Paul Knox Middle School",'North_Augusta=' + North_Augusta.length);
Aiken[Aiken.length] = createMarker(new GPoint(-81.69015503,33.58028793),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pinecrest/north Aiken Elementary School",'Aiken=' + Aiken.length);
Aiken[Aiken.length] = createMarker(new GPoint(-81.82316589,33.37309647),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Redcliffe Elementary School",'Aiken=' + Aiken.length);
Ridge_Spring[Ridge_Spring.length] = createMarker(new GPoint(-81.65843201,33.84833908),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ridge Spring Monetta Elementary School",'Ridge_Spring=' + Ridge_Spring.length);
Monetta[Monetta.length] = createMarker(new GPoint(-81.62556458,33.82207870),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ridge-spring Monetta High School",'Monetta=' + Monetta.length);
Aiken[Aiken.length] = createMarker(new GPoint(-81.71070862,33.56262589),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Schofield Middle School",'Aiken=' + Aiken.length);
Aiken[Aiken.length] = createMarker(new GPoint(-81.75736237,33.39495468),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Silver Bluff High School",'Aiken=' + Aiken.length);
Aiken[Aiken.length] = createMarker(new GPoint(-81.71472931,33.52521515),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Aiken High School",'Aiken=' + Aiken.length);
Wagener[Wagener.length] = createMarker(new GPoint(-81.36426544,33.64647293),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wagener Salley High School",'Wagener=' + Wagener.length);
Warrenville[Warrenville.length] = createMarker(new GPoint(-81.78411102,33.52554703),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Warrenville Elementary School",'Warrenville=' + Warrenville.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(Aiken);
map.removeOverlays(Bath);
map.removeOverlays(Belvedere);
map.removeOverlays(Clearwater);
map.removeOverlays(Gloverville);
map.removeOverlays(Graniteville);
map.removeOverlays(Jackson);
map.removeOverlays(Langley);
map.removeOverlays(Monetta);
map.removeOverlays(N_Augusta);
map.removeOverlays(New_Ellenton);
map.removeOverlays(North_Augusta);
map.removeOverlays(Ridge_Spring);
map.removeOverlays(Wagener);
map.removeOverlays(Warrenville);
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(Wagener);map.removeOverlays(Aiken);
map.removeOverlays(Bath);
map.removeOverlays(Belvedere);
map.removeOverlays(Clearwater);
map.removeOverlays(Gloverville);
map.removeOverlays(Graniteville);
map.removeOverlays(Jackson);
map.removeOverlays(Langley);
map.removeOverlays(Monetta);
map.removeOverlays(N_Augusta);
map.removeOverlays(New_Ellenton);
map.removeOverlays(North_Augusta);
map.removeOverlays(Ridge_Spring);
map.removeOverlays(Wagener);
map.removeOverlays(Warrenville);
map.addOverlays(Aiken);
centerByArray(Aiken, false, false);
cntMarker += Aiken.length;
map.addOverlays(Bath);
centerByArray(Bath, false, false);
cntMarker += Bath.length;
map.addOverlays(Belvedere);
centerByArray(Belvedere, false, false);
cntMarker += Belvedere.length;
map.addOverlays(Clearwater);
centerByArray(Clearwater, false, false);
cntMarker += Clearwater.length;
map.addOverlays(Gloverville);
centerByArray(Gloverville, false, false);
cntMarker += Gloverville.length;
map.addOverlays(Graniteville);
centerByArray(Graniteville, false, false);
cntMarker += Graniteville.length;
map.addOverlays(Jackson);
centerByArray(Jackson, false, false);
cntMarker += Jackson.length;
map.addOverlays(Langley);
centerByArray(Langley, false, false);
cntMarker += Langley.length;
map.addOverlays(Monetta);
centerByArray(Monetta, false, false);
cntMarker += Monetta.length;
map.addOverlays(N_Augusta);
centerByArray(N_Augusta, false, false);
cntMarker += N_Augusta.length;
map.addOverlays(New_Ellenton);
centerByArray(New_Ellenton, false, false);
cntMarker += New_Ellenton.length;
map.addOverlays(North_Augusta);
centerByArray(North_Augusta, false, false);
cntMarker += North_Augusta.length;
map.addOverlays(Ridge_Spring);
centerByArray(Ridge_Spring, false, false);
cntMarker += Ridge_Spring.length;
map.addOverlays(Wagener);
centerByArray(Wagener, false, false);
cntMarker += Wagener.length;
map.addOverlays(Warrenville);
centerByArray(Warrenville, false, false);
cntMarker += Warrenville.length;
centerByArray(Wagener,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');
}
}