function addMarkers()
{
mySelect = document.getElementById('selection');
Anthony = [];Ocala = [];Belleview = [];Dunnellon = [];Silver_Springs = [];Fort_Mccoy = [];Summerfield = [];Lowell = [];Mcintosh = [];Citra = [];Reddick = [];Sparr = [];Weirsdale = [];mySelect.options[mySelect.options.length] = new Option("Anthony schools",'all=Anthony');
mySelect.options[mySelect.options.length] = new Option("Belleview schools",'all=Belleview');
mySelect.options[mySelect.options.length] = new Option("Citra schools",'all=Citra');
mySelect.options[mySelect.options.length] = new Option("Dunnellon schools",'all=Dunnellon');
mySelect.options[mySelect.options.length] = new Option("Fort Mccoy schools",'all=Fort_Mccoy');
mySelect.options[mySelect.options.length] = new Option("Lowell schools",'all=Lowell');
mySelect.options[mySelect.options.length] = new Option("Mcintosh schools",'all=Mcintosh');
mySelect.options[mySelect.options.length] = new Option("Ocala schools",'all=Ocala');
mySelect.options[mySelect.options.length] = new Option("Reddick schools",'all=Reddick');
mySelect.options[mySelect.options.length] = new Option("Silver Springs schools",'all=Silver_Springs');
mySelect.options[mySelect.options.length] = new Option("Sparr schools",'all=Sparr');
mySelect.options[mySelect.options.length] = new Option("Summerfield schools",'all=Summerfield');
mySelect.options[mySelect.options.length] = new Option("Weirsdale schools",'all=Weirsdale');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Anthony[Anthony.length] = createMarker(new GPoint(-82.11160278,29.28945732),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Anthony Elementary School",'Anthony=' + Anthony.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.14019775,29.18689919),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Arc Idea Part H Birth-3 Elementary School",'Ocala=' + Ocala.length);
Belleview[Belleview.length] = createMarker(new GPoint(-82.05577850,29.05492973),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Belleview Elementary School",'Belleview=' + Belleview.length);
Belleview[Belleview.length] = createMarker(new GPoint(-82.08685303,29.07390404),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Belleview High School",'Belleview=' + Belleview.length);
Belleview[Belleview.length] = createMarker(new GPoint(-82.08685303,29.07301521),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Belleview Middle School",'Belleview=' + Belleview.length);
Belleview[Belleview.length] = createMarker(new GPoint(-81.99484253,29.04907036),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Belleview-santos Elementary School",'Belleview=' + Belleview.length);
Belleview[Belleview.length] = createMarker(new GPoint(-82.08685303,29.07390404),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cfcc Academy",'Belleview=' + Belleview.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.17723083,29.17501831),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("College Park Elementary School",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.14730072,29.17856026),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Community Technical & Adult Education Center",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.15665436,29.18236351),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dr. N.h. Jones Elementary School",'Ocala=' + Ocala.length);
Dunnellon[Dunnellon.length] = createMarker(new GPoint(-82.41923523,29.07465553),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dunnellon Elementary School",'Dunnellon=' + Dunnellon.length);
Dunnellon[Dunnellon.length] = createMarker(new GPoint(-82.41921997,29.07884979),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Dunnellon High School",'Dunnellon=' + Dunnellon.length);
Dunnellon[Dunnellon.length] = createMarker(new GPoint(-82.46710100,29.05127800),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Dunnellon Middle School",'Dunnellon=' + Dunnellon.length);
Silver_Springs[Silver_Springs.length] = createMarker(new GPoint(-81.91179657,29.20106316),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("East Marion Elementary School",'Silver_Springs=' + Silver_Springs.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.13240051,29.18053627),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Eighth Street Elementary School",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.00483704,29.08308411),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Emerald Shores Elementary School",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.14256287,29.22766495),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Evergreen Elementary School",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.18888855,29.28066254),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fessenden Elementary School",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.11619568,29.18516350),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Forest High School",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.11540985,29.19206810),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Fort King Middle School",'Ocala=' + Ocala.length);
Fort_Mccoy[Fort_Mccoy.length] = createMarker(new GPoint(-81.85569763,29.37199974),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fort Mccoy School",'Fort_Mccoy=' + Fort_Mccoy.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.14019775,29.18689919),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Future Leaders Academy For Arts And Science",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.01550293,29.11993790),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Greenway Elementary School",'Ocala=' + Ocala.length);
Summerfield[Summerfield.length] = createMarker(new GPoint(-82.01285553,29.00773621),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Harbour View Elementary School",'Summerfield=' + Summerfield.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.09363556,29.17163658),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hillcrest",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.13951874,29.18702126),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Howard Middle School",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.10937200,29.22297700),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Infinity School/marion County Elementary School",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.22595600,29.10154100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kingsbury Academy",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-81.98065948,29.07732391),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lake Weir High School",'Ocala=' + Ocala.length);
Summerfield[Summerfield.length] = createMarker(new GPoint(-81.98335266,28.99852371),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Lake Weir Middle School",'Summerfield=' + Summerfield.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.14939880,29.18993759),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Madison Street Academy Of Visual And Performing Ar",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.06984711,29.16403770),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Maplewood Elementary School",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.08357239,29.14223671),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Marion Charter School",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.10907745,29.22313690),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Marion County Jail",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.13236237,29.18386269),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Marion County Prek Program",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.14037900,29.18752000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Marion County Superintendent's Office",'Ocala=' + Ocala.length);
Lowell[Lowell.length] = createMarker(new GPoint(-82.20501709,29.38146019),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Marion Juvenile Correction",'Lowell=' + Lowell.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.17283630,29.19706345),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Marion Reg. Juvenile Detention Center",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.11630400,29.18536600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Marion Technical Institute",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.10907745,29.22313690),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Marion Youth Development Center",'Ocala=' + Ocala.length);
Mcintosh[Mcintosh.length] = createMarker(new GPoint(-82.28109741,29.37929916),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mcintosh Area Charter School",'Mcintosh=' + Mcintosh.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.14019775,29.18689919),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mrmc Speech/language Elementary School",'Ocala=' + Ocala.length);
Citra[Citra.length] = createMarker(new GPoint(-82.13946533,29.33839798),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Marion High School",'Citra=' + Citra.length);
Citra[Citra.length] = createMarker(new GPoint(-82.10965729,29.41183090),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("North Marion Middle School",'Citra=' + Citra.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.12348938,29.21516228),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Oakcrest Elementary School",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.08312988,29.24700165),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ocala Springs Elementary School",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.13215637,29.18232346),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Osceola Middle School",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.10314178,29.20293808),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pace Center For Girls, Inc.",'Ocala=' + Ocala.length);
Reddick[Reddick.length] = createMarker(new GPoint(-82.20314026,29.36703682),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Reddick-collier Elementary School",'Reddick=' + Reddick.length);
Dunnellon[Dunnellon.length] = createMarker(new GPoint(-82.44625854,29.15306282),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Romeo Elementary School",'Dunnellon=' + Dunnellon.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.19408417,29.15073395),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Saddlewood Elementary School",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.13606262,29.12768173),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Shady Hill Elementary School",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.10723877,29.20160484),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Silver River Marine Institute",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.12197876,29.16047859),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South Ocala Elementary School",'Ocala=' + Ocala.length);
Sparr[Sparr.length] = createMarker(new GPoint(-82.11270142,29.33830070),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sparr Elementary School",'Sparr=' + Sparr.length);
Weirsdale[Weirsdale.length] = createMarker(new GPoint(-81.92967987,28.97903633),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Stanton-weirsdale Elementary School",'Weirsdale=' + Weirsdale.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.10907745,29.22313690),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Storefront High School",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.13236237,29.18386269),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Student Services/ese",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.19784546,29.00605774),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sunrise Elementary School",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.13637543,29.21543694),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Vanguard High School",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.08671570,29.18185616),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ward-highlands Elementary School",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.25173950,29.15088844),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West Port High School",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.25173950,29.15088844),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("West Port Middle School",'Ocala=' + Ocala.length);
Ocala[Ocala.length] = createMarker(new GPoint(-82.12351990,29.19189262),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wyomina Park Elementary School",'Ocala=' + Ocala.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(Anthony);
map.removeOverlays(Belleview);
map.removeOverlays(Citra);
map.removeOverlays(Dunnellon);
map.removeOverlays(Fort_Mccoy);
map.removeOverlays(Lowell);
map.removeOverlays(Mcintosh);
map.removeOverlays(Ocala);
map.removeOverlays(Reddick);
map.removeOverlays(Silver_Springs);
map.removeOverlays(Sparr);
map.removeOverlays(Summerfield);
map.removeOverlays(Weirsdale);
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(Anthony);map.removeOverlays(Anthony);
map.removeOverlays(Belleview);
map.removeOverlays(Citra);
map.removeOverlays(Dunnellon);
map.removeOverlays(Fort_Mccoy);
map.removeOverlays(Lowell);
map.removeOverlays(Mcintosh);
map.removeOverlays(Ocala);
map.removeOverlays(Reddick);
map.removeOverlays(Silver_Springs);
map.removeOverlays(Sparr);
map.removeOverlays(Summerfield);
map.removeOverlays(Weirsdale);
map.addOverlays(Anthony);
centerByArray(Anthony, false, false);
cntMarker += Anthony.length;
map.addOverlays(Belleview);
centerByArray(Belleview, false, false);
cntMarker += Belleview.length;
map.addOverlays(Citra);
centerByArray(Citra, false, false);
cntMarker += Citra.length;
map.addOverlays(Dunnellon);
centerByArray(Dunnellon, false, false);
cntMarker += Dunnellon.length;
map.addOverlays(Fort_Mccoy);
centerByArray(Fort_Mccoy, false, false);
cntMarker += Fort_Mccoy.length;
map.addOverlays(Lowell);
centerByArray(Lowell, false, false);
cntMarker += Lowell.length;
map.addOverlays(Mcintosh);
centerByArray(Mcintosh, false, false);
cntMarker += Mcintosh.length;
map.addOverlays(Ocala);
centerByArray(Ocala, false, false);
cntMarker += Ocala.length;
map.addOverlays(Reddick);
centerByArray(Reddick, false, false);
cntMarker += Reddick.length;
map.addOverlays(Silver_Springs);
centerByArray(Silver_Springs, false, false);
cntMarker += Silver_Springs.length;
map.addOverlays(Sparr);
centerByArray(Sparr, false, false);
cntMarker += Sparr.length;
map.addOverlays(Summerfield);
centerByArray(Summerfield, false, false);
cntMarker += Summerfield.length;
map.addOverlays(Weirsdale);
centerByArray(Weirsdale, false, false);
cntMarker += Weirsdale.length;
centerByArray(Anthony,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');
}
}