function addMarkers()
{
mySelect = document.getElementById('selection');
Santa_Rosa_Beach = [];Freeport = [];Defuniak_Springs = [];Paxton = [];mySelect.options[mySelect.options.length] = new Option("Defuniak Springs schools",'all=Defuniak_Springs');
mySelect.options[mySelect.options.length] = new Option("Freeport schools",'all=Freeport');
mySelect.options[mySelect.options.length] = new Option("Paxton schools",'all=Paxton');
mySelect.options[mySelect.options.length] = new Option("Santa Rosa Beach schools",'all=Santa_Rosa_Beach');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Santa_Rosa_Beach[Santa_Rosa_Beach.length] = createMarker(new GPoint(-86.11868286,30.36853981),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bay Early Education Center",'Santa_Rosa_Beach=' + Santa_Rosa_Beach.length);
Santa_Rosa_Beach[Santa_Rosa_Beach.length] = createMarker(new GPoint(-10.00000000,10.00000000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Emerald Coast Middle School",'Santa_Rosa_Beach=' + Santa_Rosa_Beach.length);
Freeport[Freeport.length] = createMarker(new GPoint(-86.13623810,30.49809074),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Freeport Elementary School",'Freeport=' + Freeport.length);
Freeport[Freeport.length] = createMarker(new GPoint(-86.13295746,30.50243187),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Freeport Middle School",'Freeport=' + Freeport.length);
Freeport[Freeport.length] = createMarker(new GPoint(-86.12319183,30.53872681),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Freeport Senior High School",'Freeport=' + Freeport.length);
Defuniak_Springs[Defuniak_Springs.length] = createMarker(new GPoint(-10.00000000,10.00000000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Maude Saunders Elementary School",'Defuniak_Springs=' + Defuniak_Springs.length);
Paxton[Paxton.length] = createMarker(new GPoint(-86.30728149,30.98163033),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Paxton High School",'Paxton=' + Paxton.length);
Santa_Rosa_Beach[Santa_Rosa_Beach.length] = createMarker(new GPoint(-86.17739868,30.34860039),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Seaside Neighborhood School",'Santa_Rosa_Beach=' + Santa_Rosa_Beach.length);
Santa_Rosa_Beach[Santa_Rosa_Beach.length] = createMarker(new GPoint(-86.15380096,30.37879944),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Walton High School",'Santa_Rosa_Beach=' + Santa_Rosa_Beach.length);
Santa_Rosa_Beach[Santa_Rosa_Beach.length] = createMarker(new GPoint(-86.26308441,30.36121750),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Van R. Butler Elementary School",'Santa_Rosa_Beach=' + Santa_Rosa_Beach.length);
Defuniak_Springs[Defuniak_Springs.length] = createMarker(new GPoint(-86.09555817,30.72012329),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Walton Academy, Inc.",'Defuniak_Springs=' + Defuniak_Springs.length);
Defuniak_Springs[Defuniak_Springs.length] = createMarker(new GPoint(-82.34698600,31.21218800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Walton County Superintendent's Office",'Defuniak_Springs=' + Defuniak_Springs.length);
Defuniak_Springs[Defuniak_Springs.length] = createMarker(new GPoint(-86.13046265,30.73747063),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Walton County Vocational School",'Defuniak_Springs=' + Defuniak_Springs.length);
Defuniak_Springs[Defuniak_Springs.length] = createMarker(new GPoint(-86.12007141,30.71289825),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Walton Middle School",'Defuniak_Springs=' + Defuniak_Springs.length);
Defuniak_Springs[Defuniak_Springs.length] = createMarker(new GPoint(-86.12243652,30.74256325),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Walton Senior High School",'Defuniak_Springs=' + Defuniak_Springs.length);
Defuniak_Springs[Defuniak_Springs.length] = createMarker(new GPoint(-86.13637543,30.72445679),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("West Defuniak Elementary School",'Defuniak_Springs=' + Defuniak_Springs.length);
Defuniak_Springs[Defuniak_Springs.length] = createMarker(new GPoint(-86.15768433,30.73215294),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wlc Intensive Halfway House",'Defuniak_Springs=' + Defuniak_Springs.length);
Defuniak_Springs[Defuniak_Springs.length] = createMarker(new GPoint(-86.15768433,30.73215294),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wlc Shop (formerly Nafi Sh",'Defuniak_Springs=' + Defuniak_Springs.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(Defuniak_Springs);
map.removeOverlays(Freeport);
map.removeOverlays(Paxton);
map.removeOverlays(Santa_Rosa_Beach);
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(Santa_Rosa_Beach);map.removeOverlays(Defuniak_Springs);
map.removeOverlays(Freeport);
map.removeOverlays(Paxton);
map.removeOverlays(Santa_Rosa_Beach);
map.addOverlays(Defuniak_Springs);
centerByArray(Defuniak_Springs, false, false);
cntMarker += Defuniak_Springs.length;
map.addOverlays(Freeport);
centerByArray(Freeport, false, false);
cntMarker += Freeport.length;
map.addOverlays(Paxton);
centerByArray(Paxton, false, false);
cntMarker += Paxton.length;
map.addOverlays(Santa_Rosa_Beach);
centerByArray(Santa_Rosa_Beach, false, false);
cntMarker += Santa_Rosa_Beach.length;
centerByArray(Santa_Rosa_Beach,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');
}
}