function addMarkers()
{
mySelect = document.getElementById('selection');
Valparaiso = [];Crestview = [];Fort_Walton_Beach = [];Baker = [];Niceville = [];Eglin_Afb = [];Shalimar = [];Destin = [];Ft_Walton = [];Mary_Esther = [];Laurel_Hill = [];mySelect.options[mySelect.options.length] = new Option("Baker schools",'all=Baker');
mySelect.options[mySelect.options.length] = new Option("Crestview schools",'all=Crestview');
mySelect.options[mySelect.options.length] = new Option("Destin schools",'all=Destin');
mySelect.options[mySelect.options.length] = new Option("Eglin Afb schools",'all=Eglin_Afb');
mySelect.options[mySelect.options.length] = new Option("Fort Walton Beach schools",'all=Fort_Walton_Beach');
mySelect.options[mySelect.options.length] = new Option("Ft Walton schools",'all=Ft_Walton');
mySelect.options[mySelect.options.length] = new Option("Laurel Hill schools",'all=Laurel_Hill');
mySelect.options[mySelect.options.length] = new Option("Mary Esther schools",'all=Mary_Esther');
mySelect.options[mySelect.options.length] = new Option("Niceville schools",'all=Niceville');
mySelect.options[mySelect.options.length] = new Option("Shalimar schools",'all=Shalimar');
mySelect.options[mySelect.options.length] = new Option("Valparaiso schools",'all=Valparaiso');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Valparaiso[Valparaiso.length] = createMarker(new GPoint(-86.48999023,30.49356270),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Addie R. Lewis Middle School",'Valparaiso=' + Valparaiso.length);
Crestview[Crestview.length] = createMarker(new GPoint(-86.52940369,30.69650078),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Adjudicated Youth Facility",'Crestview=' + Crestview.length);
Fort_Walton_Beach[Fort_Walton_Beach.length] = createMarker(new GPoint(-86.63194275,30.45352936),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Adolescent Substance Abuse",'Fort_Walton_Beach=' + Fort_Walton_Beach.length);
Fort_Walton_Beach[Fort_Walton_Beach.length] = createMarker(new GPoint(-86.63913727,30.41388893),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Annette P. Edwins Elementary School",'Fort_Walton_Beach=' + Fort_Walton_Beach.length);
Crestview[Crestview.length] = createMarker(new GPoint(-86.61479950,30.71372795),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Antioch Elementary School",'Crestview=' + Crestview.length);
Baker[Baker.length] = createMarker(new GPoint(-86.67937469,30.79336929),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Baker School",'Baker=' + Baker.length);
Niceville[Niceville.length] = createMarker(new GPoint(-86.41822815,30.48968124),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bluewater Elementary School",'Niceville=' + Niceville.length);
Crestview[Crestview.length] = createMarker(new GPoint(-86.57598700,30.78051200),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bob Sikes Elementary School",'Crestview=' + Crestview.length);
Niceville[Niceville.length] = createMarker(new GPoint(-86.47566223,30.52309036),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("C. W. Ruckel Middle School",'Niceville=' + Niceville.length);
Eglin_Afb[Eglin_Afb.length] = createMarker(new GPoint(-86.55232239,30.46413994),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cherokee Elementary School",'Eglin_Afb=' + Eglin_Afb.length);
Fort_Walton_Beach[Fort_Walton_Beach.length] = createMarker(new GPoint(-86.61466900,30.40420000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Choctawatchee Academy",'Fort_Walton_Beach=' + Fort_Walton_Beach.length);
Fort_Walton_Beach[Fort_Walton_Beach.length] = createMarker(new GPoint(-86.61863708,30.44933701),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Choctawhatchee Senior High School",'Fort_Walton_Beach=' + Fort_Walton_Beach.length);
Shalimar[Shalimar.length] = createMarker(new GPoint(-86.57868195,30.44826317),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Clifford Meigs Middle School",'Shalimar=' + Shalimar.length);
Crestview[Crestview.length] = createMarker(new GPoint(-86.55915833,30.78805161),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Crestview Senior High School",'Crestview=' + Crestview.length);
Crestview[Crestview.length] = createMarker(new GPoint(-86.55915833,30.78805161),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Crestview Vocational-technical Center",'Crestview=' + Crestview.length);
Crestview[Crestview.length] = createMarker(new GPoint(-86.57077789,30.76164055),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Crestview Vocational-technical Center (inactive 8",'Crestview=' + Crestview.length);
Crestview[Crestview.length] = createMarker(new GPoint(-86.56094360,30.79478645),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Davidson Middle School",'Crestview=' + Crestview.length);
Destin[Destin.length] = createMarker(new GPoint(-86.49152374,30.40216255),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Destin Elementary School",'Destin=' + Destin.length);
Destin[Destin.length] = createMarker(new GPoint(-86.42242432,30.39682961),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Destin Middle School/regatta Bay",'Destin=' + Destin.length);
Fort_Walton_Beach[Fort_Walton_Beach.length] = createMarker(new GPoint(-86.59751892,30.41992188),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Elliott Point Elementary School",'Fort_Walton_Beach=' + Fort_Walton_Beach.length);
Crestview[Crestview.length] = createMarker(new GPoint(-86.57152900,30.75003100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Emerald Coast Career Institute N",'Crestview=' + Crestview.length);
Ft_Walton[Ft_Walton.length] = createMarker(new GPoint(-86.66778700,30.42454300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Emerald Coast Career Institute S",'Ft_Walton=' + Ft_Walton.length);
Fort_Walton_Beach[Fort_Walton_Beach.length] = createMarker(new GPoint(-86.60591888,30.41043663),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Emerald Coast Marine Institute",'Fort_Walton_Beach=' + Fort_Walton_Beach.length);
Fort_Walton_Beach[Fort_Walton_Beach.length] = createMarker(new GPoint(-86.60646057,30.40645599),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Exceptional Student Education (ina",'Fort_Walton_Beach=' + Fort_Walton_Beach.length);
Mary_Esther[Mary_Esther.length] = createMarker(new GPoint(-86.72837830,30.41223717),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Florosa Elementary School",'Mary_Esther=' + Mary_Esther.length);
Fort_Walton_Beach[Fort_Walton_Beach.length] = createMarker(new GPoint(-86.63945770,30.41296387),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fort Walton Beach High School",'Fort_Walton_Beach=' + Fort_Walton_Beach.length);
Fort_Walton_Beach[Fort_Walton_Beach.length] = createMarker(new GPoint(-86.63945770,30.41296387),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fort Walton Beach Success Academy (formerly Ft. W",'Fort_Walton_Beach=' + Fort_Walton_Beach.length);
Crestview[Crestview.length] = createMarker(new GPoint(-86.57150269,30.74986267),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gulf Coast Residential Care",'Crestview=' + Crestview.length);
Crestview[Crestview.length] = createMarker(new GPoint(-86.52940369,30.69650078),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gulf Coast Youth Academy",'Crestview=' + Crestview.length);
Niceville[Niceville.length] = createMarker(new GPoint(-86.46158600,30.51433754),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("James E. Plew Elementary School",'Niceville=' + Niceville.length);
Fort_Walton_Beach[Fort_Walton_Beach.length] = createMarker(new GPoint(-86.60916901,30.45801163),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kenwood Elementary School",'Fort_Walton_Beach=' + Fort_Walton_Beach.length);
Crestview[Crestview.length] = createMarker(new GPoint(-86.56893921,30.77013779),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Lance C. Richbourg Middle School",'Crestview=' + Crestview.length);
Laurel_Hill[Laurel_Hill.length] = createMarker(new GPoint(-86.46186066,30.95935822),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Laurel Hill School",'Laurel_Hill=' + Laurel_Hill.length);
Fort_Walton_Beach[Fort_Walton_Beach.length] = createMarker(new GPoint(-86.65173340,30.42175484),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Liza Jackson Preparatory School",'Fort_Walton_Beach=' + Fort_Walton_Beach.length);
Shalimar[Shalimar.length] = createMarker(new GPoint(-86.58177948,30.46084023),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Longwood Elementary School",'Shalimar=' + Shalimar.length);
Niceville[Niceville.length] = createMarker(new GPoint(-86.49342346,30.52662468),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lula J. Edge Elementary School",'Niceville=' + Niceville.length);
Mary_Esther[Mary_Esther.length] = createMarker(new GPoint(-86.65818024,30.40968895),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mary Esther Elementary School",'Mary_Esther=' + Mary_Esther.length);
Fort_Walton_Beach[Fort_Walton_Beach.length] = createMarker(new GPoint(-86.63352203,30.42006302),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Max Bruner, Junior Middle School",'Fort_Walton_Beach=' + Fort_Walton_Beach.length);
Niceville[Niceville.length] = createMarker(new GPoint(-86.47800446,30.51882172),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Niceville Senior High School",'Niceville=' + Niceville.length);
Crestview[Crestview.length] = createMarker(new GPoint(-86.57102400,30.76183000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Okaloosa Institute",'Crestview=' + Crestview.length);
Crestview[Crestview.length] = createMarker(new GPoint(-86.56894684,30.76884842),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Northwood Elementary School",'Crestview=' + Crestview.length);
Fort_Walton_Beach[Fort_Walton_Beach.length] = createMarker(new GPoint(-86.60144043,30.40683746),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Nw Florida Ballet Academie Elementary School",'Fort_Walton_Beach=' + Fort_Walton_Beach.length);
Eglin_Afb[Eglin_Afb.length] = createMarker(new GPoint(-86.53749847,30.47125244),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Oak Hill Elementary School",'Eglin_Afb=' + Eglin_Afb.length);
Fort_Walton_Beach[Fort_Walton_Beach.length] = createMarker(new GPoint(-86.60916138,30.44525146),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ocean City Elementary School",'Fort_Walton_Beach=' + Fort_Walton_Beach.length);
Fort_Walton_Beach[Fort_Walton_Beach.length] = createMarker(new GPoint(-86.62544250,30.46576118),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Okaloosa Academy",'Fort_Walton_Beach=' + Fort_Walton_Beach.length);
Fort_Walton_Beach[Fort_Walton_Beach.length] = createMarker(new GPoint(-86.61411285,30.46735764),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Okaloosa Applied Technical Center",'Fort_Walton_Beach=' + Fort_Walton_Beach.length);
Fort_Walton_Beach[Fort_Walton_Beach.length] = createMarker(new GPoint(-86.61466900,30.40420000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Okaloosa County Superintendent's Office",'Fort_Walton_Beach=' + Fort_Walton_Beach.length);
Crestview[Crestview.length] = createMarker(new GPoint(-86.52940369,30.69650078),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Okaloosa Regional Detention Center",'Crestview=' + Crestview.length);
Crestview[Crestview.length] = createMarker(new GPoint(-86.52940369,30.69650078),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Okaloosa Youth Academy",'Crestview=' + Crestview.length);
Crestview[Crestview.length] = createMarker(new GPoint(-86.52940369,30.69650078),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Okaloosa Youth Development Center",'Crestview=' + Crestview.length);
Niceville[Niceville.length] = createMarker(new GPoint(-86.47343000,30.53472600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Owcc Collegiate Charter High School",'Niceville=' + Niceville.length);
Shalimar[Shalimar.length] = createMarker(new GPoint(-86.57517242,30.44944191),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Shalimar Elementary School",'Shalimar=' + Shalimar.length);
Fort_Walton_Beach[Fort_Walton_Beach.length] = createMarker(new GPoint(-86.63756561,30.42043686),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Silver Sands-excep. Children",'Fort_Walton_Beach=' + Fort_Walton_Beach.length);
Crestview[Crestview.length] = createMarker(new GPoint(-86.56437683,30.75381660),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Southside Elementary School",'Crestview=' + Crestview.length);
Valparaiso[Valparaiso.length] = createMarker(new GPoint(-86.50256300,30.51301500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Valparaiso Elementary School",'Valparaiso=' + Valparaiso.length);
Fort_Walton_Beach[Fort_Walton_Beach.length] = createMarker(new GPoint(-86.62186432,30.44897079),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("W. C. Pryor Middle School",'Fort_Walton_Beach=' + Fort_Walton_Beach.length);
Fort_Walton_Beach[Fort_Walton_Beach.length] = createMarker(new GPoint(-86.66779327,30.42436218),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("W. E. Combs School",'Fort_Walton_Beach=' + Fort_Walton_Beach.length);
Crestview[Crestview.length] = createMarker(new GPoint(-86.54348755,30.77269363),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Walker Elementary School",'Crestview=' + Crestview.length);
Fort_Walton_Beach[Fort_Walton_Beach.length] = createMarker(new GPoint(-86.63130188,30.43633652),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wright Elementary School",'Fort_Walton_Beach=' + Fort_Walton_Beach.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(Baker);
map.removeOverlays(Crestview);
map.removeOverlays(Destin);
map.removeOverlays(Eglin_Afb);
map.removeOverlays(Fort_Walton_Beach);
map.removeOverlays(Ft_Walton);
map.removeOverlays(Laurel_Hill);
map.removeOverlays(Mary_Esther);
map.removeOverlays(Niceville);
map.removeOverlays(Shalimar);
map.removeOverlays(Valparaiso);
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(Valparaiso);map.removeOverlays(Baker);
map.removeOverlays(Crestview);
map.removeOverlays(Destin);
map.removeOverlays(Eglin_Afb);
map.removeOverlays(Fort_Walton_Beach);
map.removeOverlays(Ft_Walton);
map.removeOverlays(Laurel_Hill);
map.removeOverlays(Mary_Esther);
map.removeOverlays(Niceville);
map.removeOverlays(Shalimar);
map.removeOverlays(Valparaiso);
map.addOverlays(Baker);
centerByArray(Baker, false, false);
cntMarker += Baker.length;
map.addOverlays(Crestview);
centerByArray(Crestview, false, false);
cntMarker += Crestview.length;
map.addOverlays(Destin);
centerByArray(Destin, false, false);
cntMarker += Destin.length;
map.addOverlays(Eglin_Afb);
centerByArray(Eglin_Afb, false, false);
cntMarker += Eglin_Afb.length;
map.addOverlays(Fort_Walton_Beach);
centerByArray(Fort_Walton_Beach, false, false);
cntMarker += Fort_Walton_Beach.length;
map.addOverlays(Ft_Walton);
centerByArray(Ft_Walton, false, false);
cntMarker += Ft_Walton.length;
map.addOverlays(Laurel_Hill);
centerByArray(Laurel_Hill, false, false);
cntMarker += Laurel_Hill.length;
map.addOverlays(Mary_Esther);
centerByArray(Mary_Esther, false, false);
cntMarker += Mary_Esther.length;
map.addOverlays(Niceville);
centerByArray(Niceville, false, false);
cntMarker += Niceville.length;
map.addOverlays(Shalimar);
centerByArray(Shalimar, false, false);
cntMarker += Shalimar.length;
map.addOverlays(Valparaiso);
centerByArray(Valparaiso, false, false);
cntMarker += Valparaiso.length;
centerByArray(Valparaiso,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');
}
}