function addMarkers(){
mySelect = document.getElementById('selection');
Tampa = [];Miami = [];Apalachicola = [];Fort_Lauderdale = [];Brandon = [];Naples = [];Maitland = [];Middleburg = [];Lecanto = [];Boca_Raton = [];Winter_Haven = [];mySelect.options[mySelect.options.length] = new Option("Apalachicola schools",'all=Apalachicola');
mySelect.options[mySelect.options.length] = new Option("Boca Raton schools",'all=Boca_Raton');
mySelect.options[mySelect.options.length] = new Option("Brandon schools",'all=Brandon');
mySelect.options[mySelect.options.length] = new Option("Fort Lauderdale schools",'all=Fort_Lauderdale');
mySelect.options[mySelect.options.length] = new Option("Lecanto schools",'all=Lecanto');
mySelect.options[mySelect.options.length] = new Option("Maitland schools",'all=Maitland');
mySelect.options[mySelect.options.length] = new Option("Miami schools",'all=Miami');
mySelect.options[mySelect.options.length] = new Option("Middleburg schools",'all=Middleburg');
mySelect.options[mySelect.options.length] = new Option("Naples schools",'all=Naples');
mySelect.options[mySelect.options.length] = new Option("Tampa schools",'all=Tampa');
mySelect.options[mySelect.options.length] = new Option("Winter Haven schools",'all=Winter_Haven');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Tampa[Tampa.length] = createMarker(new GPoint(-82.48845000,28.00212600),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cambridge Christian Schools",'Tampa=' + Tampa.length);
Miami[Miami.length] = createMarker(new GPoint(-80.25088200,25.92705600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Emmanuel Kindergarten & Day Care",'Miami=' + Miami.length);
Apalachicola[Apalachicola.length] = createMarker(new GPoint(-84.98646200,29.72203300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("First Baptist Christian School",'Apalachicola=' + Apalachicola.length);
Fort_Lauderdale[Fort_Lauderdale.length] = createMarker(new GPoint(-80.18769200,26.20380400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fort Lauderdale Christian School",'Fort_Lauderdale=' + Fort_Lauderdale.length);
Brandon[Brandon.length] = createMarker(new GPoint(-82.25288100,27.96172600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grace Christian School",'Brandon=' + Brandon.length);
Naples[Naples.length] = createMarker(new GPoint(-81.68879700,26.25750100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Nicaea Academy",'Naples=' + Naples.length);
Maitland[Maitland.length] = createMarker(new GPoint(-81.37837900,28.63119500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Orangewood Christian School",'Maitland=' + Maitland.length);
Middleburg[Middleburg.length] = createMarker(new GPoint(-81.79740400,30.10901700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pinewood Christian Academy",'Middleburg=' + Middleburg.length);
Lecanto[Lecanto.length] = createMarker(new GPoint(-82.50320600,28.85908400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Seven Rivers Christian",'Lecanto=' + Lecanto.length);
Boca_Raton[Boca_Raton.length] = createMarker(new GPoint(-80.13566200,26.39395600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Spanish River Christian School",'Boca_Raton=' + Boca_Raton.length);
Winter_Haven[Winter_Haven.length] = createMarker(new GPoint(-81.70347300,28.00443900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St John's Christian School",'Winter_Haven=' + Winter_Haven.length);
map.removeOverlays(Apalachicola);
map.removeOverlays(Boca_Raton);
map.removeOverlays(Brandon);
map.removeOverlays(Fort_Lauderdale);
map.removeOverlays(Lecanto);
map.removeOverlays(Maitland);
map.removeOverlays(Miami);
map.removeOverlays(Middleburg);
map.removeOverlays(Naples);
map.removeOverlays(Tampa);
map.removeOverlays(Winter_Haven);
setTimeout(function(){map.addOverlays(Apalachicola)},1000);
setTimeout(function(){map.addOverlays(Boca_Raton)},1000);
setTimeout(function(){map.addOverlays(Brandon)},1000);
setTimeout(function(){map.addOverlays(Fort_Lauderdale)},1000);
setTimeout(function(){map.addOverlays(Lecanto)},1000);
setTimeout(function(){map.addOverlays(Maitland)},1000);
setTimeout(function(){map.addOverlays(Miami)},1000);
setTimeout(function(){map.addOverlays(Middleburg)},1000);
setTimeout(function(){map.addOverlays(Naples)},1000);
setTimeout(function(){map.addOverlays(Tampa)},1000);
setTimeout(function(){map.addOverlays(Winter_Haven)},1000);
maxLng = -80.13566200;
maxLat = 30.10901700;
minLng = -84.98646200;
minLat = 25.92705600;
reCenterMap();
} // 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,11);
/*
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(Apalachicola);
map.removeOverlays(Boca_Raton);
map.removeOverlays(Brandon);
map.removeOverlays(Fort_Lauderdale);
map.removeOverlays(Lecanto);
map.removeOverlays(Maitland);
map.removeOverlays(Miami);
map.removeOverlays(Middleburg);
map.removeOverlays(Naples);
map.removeOverlays(Tampa);
map.removeOverlays(Winter_Haven);
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(Tampa);map.removeOverlays(Apalachicola);
map.removeOverlays(Boca_Raton);
map.removeOverlays(Brandon);
map.removeOverlays(Fort_Lauderdale);
map.removeOverlays(Lecanto);
map.removeOverlays(Maitland);
map.removeOverlays(Miami);
map.removeOverlays(Middleburg);
map.removeOverlays(Naples);
map.removeOverlays(Tampa);
map.removeOverlays(Winter_Haven);
map.addOverlays(Apalachicola);
centerByArray(Apalachicola, false, false);
cntMarker += Apalachicola.length;
map.addOverlays(Boca_Raton);
centerByArray(Boca_Raton, false, false);
cntMarker += Boca_Raton.length;
map.addOverlays(Brandon);
centerByArray(Brandon, false, false);
cntMarker += Brandon.length;
map.addOverlays(Fort_Lauderdale);
centerByArray(Fort_Lauderdale, false, false);
cntMarker += Fort_Lauderdale.length;
map.addOverlays(Lecanto);
centerByArray(Lecanto, false, false);
cntMarker += Lecanto.length;
map.addOverlays(Maitland);
centerByArray(Maitland, false, false);
cntMarker += Maitland.length;
map.addOverlays(Miami);
centerByArray(Miami, false, false);
cntMarker += Miami.length;
map.addOverlays(Middleburg);
centerByArray(Middleburg, false, false);
cntMarker += Middleburg.length;
map.addOverlays(Naples);
centerByArray(Naples, false, false);
cntMarker += Naples.length;
map.addOverlays(Tampa);
centerByArray(Tampa, false, false);
cntMarker += Tampa.length;
map.addOverlays(Winter_Haven);
centerByArray(Winter_Haven, false, false);
cntMarker += Winter_Haven.length;
centerByArray(Tampa,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///6302,31087,6334,6940,6746,6715,6938,6302,6967,31087,6334,6940,6746,6251,6833,6715,6938,7495,/all');
//window.open('/map.php?type=2&schools=6302,31087,6334,6940,6746,6715,6938,6302,6967,31087,6334,6940,6746,6251,6833,6715,6938,7495,&school_level=&radius=&zipcode=&school_type_search=&school_type_code=');
}
}
function createMarker(point, label, icon)
{
var marker = new GMarker(point, icon);
var html = label;
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}