function addMarkers(){
mySelect = document.getElementById('selection');
Port_St_Lucie = [];Fort_Pierce = [];Ft__Pierce = [];Port_Saint_Lucie = [];mySelect.options[mySelect.options.length] = new Option("Fort Pierce schools",'all=Fort_Pierce');
mySelect.options[mySelect.options.length] = new Option("Ft Pierce schools",'all=Ft__Pierce');
mySelect.options[mySelect.options.length] = new Option("Port Saint Lucie schools",'all=Port_Saint_Lucie');
mySelect.options[mySelect.options.length] = new Option("Port St Lucie schools",'all=Port_St_Lucie');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Port_St_Lucie[Port_St_Lucie.length] = createMarker(new GPoint(-80.38317300,27.22310100),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Barnabas Christian Academy",'Port_St_Lucie=' + Port_St_Lucie.length);
Fort_Pierce[Fort_Pierce.length] = createMarker(new GPoint(-80.33295300,27.41229200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethany School",'Fort_Pierce=' + Fort_Pierce.length);
Fort_Pierce[Fort_Pierce.length] = createMarker(new GPoint(-80.35045500,27.38345500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bible Baptist Church And School",'Fort_Pierce=' + Fort_Pierce.length);
Fort_Pierce[Fort_Pierce.length] = createMarker(new GPoint(-80.33398200,27.39489200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Baptist School",'Fort_Pierce=' + Fort_Pierce.length);
Ft__Pierce[Ft__Pierce.length] = createMarker(new GPoint(-80.35793500,27.44139500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Golden Rule Academy",'Ft__Pierce=' + Ft__Pierce.length);
Port_St_Lucie[Port_St_Lucie.length] = createMarker(new GPoint(-80.27396700,27.27865600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Heritage Christian School",'Port_St_Lucie=' + Port_St_Lucie.length);
Fort_Pierce[Fort_Pierce.length] = createMarker(new GPoint(-80.37305400,27.40476600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jes Memorial Sda School",'Fort_Pierce=' + Fort_Pierce.length);
Fort_Pierce[Fort_Pierce.length] = createMarker(new GPoint(-80.36588200,27.47320100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kilpatrick Christian Academy",'Fort_Pierce=' + Fort_Pierce.length);
Fort_Pierce[Fort_Pierce.length] = createMarker(new GPoint(-80.36170000,27.37443000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Liberty Baptist Academy",'Fort_Pierce=' + Fort_Pierce.length);
Fort_Pierce[Fort_Pierce.length] = createMarker(new GPoint(-80.33372000,27.40630000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lighthouse Christian Academy",'Fort_Pierce=' + Fort_Pierce.length);
Port_Saint_Lucie[Port_Saint_Lucie.length] = createMarker(new GPoint(-80.29832200,27.27412800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Morningside Academy",'Port_Saint_Lucie=' + Port_Saint_Lucie.length);
Fort_Pierce[Fort_Pierce.length] = createMarker(new GPoint(-80.32984400,27.37008900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Life Christian Academy",'Fort_Pierce=' + Fort_Pierce.length);
Fort_Pierce[Fort_Pierce.length] = createMarker(new GPoint(-80.45521200,27.44906300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Orange Avenue Baptist School",'Fort_Pierce=' + Fort_Pierce.length);
Fort_Pierce[Fort_Pierce.length] = createMarker(new GPoint(-80.35794400,27.44146100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Palm Vista Christian School",'Fort_Pierce=' + Fort_Pierce.length);
Fort_Pierce[Fort_Pierce.length] = createMarker(new GPoint(-80.34444700,27.39892900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Park Centre Academy",'Fort_Pierce=' + Fort_Pierce.length);
Fort_Pierce[Fort_Pierce.length] = createMarker(new GPoint(-80.35825400,27.44465700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Anastasia School",'Fort_Pierce=' + Fort_Pierce.length);
Fort_Pierce[Fort_Pierce.length] = createMarker(new GPoint(-80.32240300,27.44640300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Andrew's Episcopal School",'Fort_Pierce=' + Fort_Pierce.length);
Fort_Pierce[Fort_Pierce.length] = createMarker(new GPoint(-80.33394400,27.36570000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sun Grove Montessori School",'Fort_Pierce=' + Fort_Pierce.length);
Port_Saint_Lucie[Port_Saint_Lucie.length] = createMarker(new GPoint(-80.40760400,27.32747600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Treasure Coast Christian Academy",'Port_Saint_Lucie=' + Port_Saint_Lucie.length);
Port_Saint_Lucie[Port_Saint_Lucie.length] = createMarker(new GPoint(-80.37288500,27.31447900),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Victory Forge Military Academy",'Port_Saint_Lucie=' + Port_Saint_Lucie.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,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/////1/' + showArray);
map.removeOverlays(Fort_Pierce);
map.removeOverlays(Ft__Pierce);
map.removeOverlays(Port_Saint_Lucie);
map.removeOverlays(Port_St_Lucie);
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(Port_St_Lucie);map.removeOverlays(Fort_Pierce);
map.removeOverlays(Ft__Pierce);
map.removeOverlays(Port_Saint_Lucie);
map.removeOverlays(Port_St_Lucie);
map.addOverlays(Fort_Pierce);
centerByArray(Fort_Pierce, false, false);
cntMarker += Fort_Pierce.length;
map.addOverlays(Ft__Pierce);
centerByArray(Ft__Pierce, false, false);
cntMarker += Ft__Pierce.length;
map.addOverlays(Port_Saint_Lucie);
centerByArray(Port_Saint_Lucie, false, false);
cntMarker += Port_Saint_Lucie.length;
map.addOverlays(Port_St_Lucie);
centerByArray(Port_St_Lucie, false, false);
cntMarker += Port_St_Lucie.length;
centerByArray(Port_St_Lucie,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');
//window.open('/map.php?type=1&schools=&school_level=1&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;
}