function addMarkers()
{
mySelect = document.getElementById('selection');
Gainesville = [];Nicholson = [];Commerce = [];Watkinsville = [];Jefferson = [];Maysville = [];Talmo = [];Athens = [];Hoschton = [];Braselton = [];mySelect.options[mySelect.options.length] = new Option("Athens schools",'all=Athens');
mySelect.options[mySelect.options.length] = new Option("Braselton schools",'all=Braselton');
mySelect.options[mySelect.options.length] = new Option("Commerce schools",'all=Commerce');
mySelect.options[mySelect.options.length] = new Option("Gainesville schools",'all=Gainesville');
mySelect.options[mySelect.options.length] = new Option("Hoschton schools",'all=Hoschton');
mySelect.options[mySelect.options.length] = new Option("Jefferson schools",'all=Jefferson');
mySelect.options[mySelect.options.length] = new Option("Maysville schools",'all=Maysville');
mySelect.options[mySelect.options.length] = new Option("Nicholson schools",'all=Nicholson');
mySelect.options[mySelect.options.length] = new Option("Talmo schools",'all=Talmo');
mySelect.options[mySelect.options.length] = new Option("Watkinsville schools",'all=Watkinsville');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Gainesville[Gainesville.length] = createMarker(new GPoint(-83.82968800,34.29403800),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Alpine Psychoeducational Program",'Gainesville=' + Gainesville.length);
Nicholson[Nicholson.length] = createMarker(new GPoint(-83.43154144,34.11408997),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Benton Elementary School",'Nicholson=' + Nicholson.length);
Commerce[Commerce.length] = createMarker(new GPoint(-83.46183777,34.19609451),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Commerce Elementary School",'Commerce=' + Commerce.length);
Commerce[Commerce.length] = createMarker(new GPoint(-83.46488953,34.19951248),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Commerce High School",'Commerce=' + Commerce.length);
Commerce[Commerce.length] = createMarker(new GPoint(-83.46264648,34.19377899),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Commerce Middle School",'Commerce=' + Commerce.length);
Watkinsville[Watkinsville.length] = createMarker(new GPoint(-83.40927400,33.86328000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Crossroads Alternative School",'Watkinsville=' + Watkinsville.length);
Commerce[Commerce.length] = createMarker(new GPoint(-83.50627899,34.20816040),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("East Jackson Elementary School",'Commerce=' + Commerce.length);
Commerce[Commerce.length] = createMarker(new GPoint(-83.47203064,34.14757156),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("East Jackson Middle School",'Commerce=' + Commerce.length);
Jefferson[Jefferson.length] = createMarker(new GPoint(-83.57097900,34.11865700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jackson County Crossroads",'Jefferson=' + Jefferson.length);
Jefferson[Jefferson.length] = createMarker(new GPoint(-83.59500122,34.10230637),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jackson County High School",'Jefferson=' + Jefferson.length);
Jefferson[Jefferson.length] = createMarker(new GPoint(-83.58419037,34.12349319),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'Jefferson=' + Jefferson.length);
Jefferson[Jefferson.length] = createMarker(new GPoint(-83.58097076,34.12333679),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jefferson High School",'Jefferson=' + Jefferson.length);
Jefferson[Jefferson.length] = createMarker(new GPoint(-83.58666229,34.12217331),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Jefferson Middle School",'Jefferson=' + Jefferson.length);
Maysville[Maysville.length] = createMarker(new GPoint(-83.55760193,34.24457169),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Maysville Elementary School",'Maysville=' + Maysville.length);
Talmo[Talmo.length] = createMarker(new GPoint(-83.69671631,34.17799377),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("North Jackson Elementary School",'Talmo=' + Talmo.length);
Jefferson[Jefferson.length] = createMarker(new GPoint(-83.56964874,34.11281586),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Regional Evening Alternative School",'Jefferson=' + Jefferson.length);
Athens[Athens.length] = createMarker(new GPoint(-83.49925232,34.03984833),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South Jackson Elementary School",'Athens=' + Athens.length);
Hoschton[Hoschton.length] = createMarker(new GPoint(-83.76155853,34.09663010),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("West Jackson Intermediate School",'Hoschton=' + Hoschton.length);
Jefferson[Jefferson.length] = createMarker(new GPoint(-83.68708038,34.09426117),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("West Jackson Middle School",'Jefferson=' + Jefferson.length);
Braselton[Braselton.length] = createMarker(new GPoint(-83.76229095,34.10583115),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("West Jackson Primary",'Braselton=' + Braselton.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(Athens);
map.removeOverlays(Braselton);
map.removeOverlays(Commerce);
map.removeOverlays(Gainesville);
map.removeOverlays(Hoschton);
map.removeOverlays(Jefferson);
map.removeOverlays(Maysville);
map.removeOverlays(Nicholson);
map.removeOverlays(Talmo);
map.removeOverlays(Watkinsville);
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(Gainesville);map.removeOverlays(Athens);
map.removeOverlays(Braselton);
map.removeOverlays(Commerce);
map.removeOverlays(Gainesville);
map.removeOverlays(Hoschton);
map.removeOverlays(Jefferson);
map.removeOverlays(Maysville);
map.removeOverlays(Nicholson);
map.removeOverlays(Talmo);
map.removeOverlays(Watkinsville);
map.addOverlays(Athens);
centerByArray(Athens, false, false);
cntMarker += Athens.length;
map.addOverlays(Braselton);
centerByArray(Braselton, false, false);
cntMarker += Braselton.length;
map.addOverlays(Commerce);
centerByArray(Commerce, false, false);
cntMarker += Commerce.length;
map.addOverlays(Gainesville);
centerByArray(Gainesville, false, false);
cntMarker += Gainesville.length;
map.addOverlays(Hoschton);
centerByArray(Hoschton, false, false);
cntMarker += Hoschton.length;
map.addOverlays(Jefferson);
centerByArray(Jefferson, false, false);
cntMarker += Jefferson.length;
map.addOverlays(Maysville);
centerByArray(Maysville, false, false);
cntMarker += Maysville.length;
map.addOverlays(Nicholson);
centerByArray(Nicholson, false, false);
cntMarker += Nicholson.length;
map.addOverlays(Talmo);
centerByArray(Talmo, false, false);
cntMarker += Talmo.length;
map.addOverlays(Watkinsville);
centerByArray(Watkinsville, false, false);
cntMarker += Watkinsville.length;
centerByArray(Gainesville,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');
}
}