function addMarkers(){
mySelect = document.getElementById('selection');
Cocoa = [];West_Melbourne = [];Merritt_Island = [];Rockledge = [];Mims = [];Cocoa_Beach = [];Melbourne = [];Palm_Bay = [];Sharpes = [];Titusville = [];mySelect.options[mySelect.options.length] = new Option("Cocoa schools",'all=Cocoa');
mySelect.options[mySelect.options.length] = new Option("Cocoa Beach schools",'all=Cocoa_Beach');
mySelect.options[mySelect.options.length] = new Option("Melbourne schools",'all=Melbourne');
mySelect.options[mySelect.options.length] = new Option("Merritt Island schools",'all=Merritt_Island');
mySelect.options[mySelect.options.length] = new Option("Mims schools",'all=Mims');
mySelect.options[mySelect.options.length] = new Option("Palm Bay schools",'all=Palm_Bay');
mySelect.options[mySelect.options.length] = new Option("Rockledge schools",'all=Rockledge');
mySelect.options[mySelect.options.length] = new Option("Sharpes schools",'all=Sharpes');
mySelect.options[mySelect.options.length] = new Option("Titusville schools",'all=Titusville');
mySelect.options[mySelect.options.length] = new Option("West Melbourne schools",'all=West_Melbourne');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Cocoa[Cocoa.length] = createMarker(new GPoint(-80.73303700,28.36524500),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Atlantic Inclusive Academy",'Cocoa=' + Cocoa.length);
Cocoa[Cocoa.length] = createMarker(new GPoint(-80.70590000,28.26150000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethel Christian Academy",'Cocoa=' + Cocoa.length);
West_Melbourne[West_Melbourne.length] = createMarker(new GPoint(-80.63867500,28.07523700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Brevard Christian School",'West_Melbourne=' + West_Melbourne.length);
Merritt_Island[Merritt_Island.length] = createMarker(new GPoint(-80.70104300,28.36085400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Brevard Homeschool Academy Inc.",'Merritt_Island=' + Merritt_Island.length);
Rockledge[Rockledge.length] = createMarker(new GPoint(-80.74990000,28.39733700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Brevard Independent Private School",'Rockledge=' + Rockledge.length);
Mims[Mims.length] = createMarker(new GPoint(-80.85692900,28.70856000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christ Aid Academy",'Mims=' + Mims.length);
Merritt_Island[Merritt_Island.length] = createMarker(new GPoint(-80.70142700,28.35765000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christian Home School Coop",'Merritt_Island=' + Merritt_Island.length);
Cocoa[Cocoa.length] = createMarker(new GPoint(-80.77131400,28.36743000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christian Homeschool Co-op#2",'Cocoa=' + Cocoa.length);
Cocoa_Beach[Cocoa_Beach.length] = createMarker(new GPoint(-80.60873800,28.30348800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cocoa Beach Christian School Homeschool Umbrella",'Cocoa_Beach=' + Cocoa_Beach.length);
Melbourne[Melbourne.length] = createMarker(new GPoint(-80.64245500,28.13351100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Community Christian School Inc",'Melbourne=' + Melbourne.length);
Palm_Bay[Palm_Bay.length] = createMarker(new GPoint(-80.65977800,28.01910300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Covenant Christian School",'Palm_Bay=' + Palm_Bay.length);
Cocoa[Cocoa.length] = createMarker(new GPoint(-73.60158000,40.67000000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Creative Learning",'Cocoa=' + Cocoa.length);
Palm_Bay[Palm_Bay.length] = createMarker(new GPoint(-80.59702000,28.05293700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Diamond Community School, Inc.",'Palm_Bay=' + Palm_Bay.length);
Palm_Bay[Palm_Bay.length] = createMarker(new GPoint(-80.68106500,28.03223300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Christian School",'Palm_Bay=' + Palm_Bay.length);
Melbourne[Melbourne.length] = createMarker(new GPoint(-80.62784400,28.07957100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Florida Air Academy",'Melbourne=' + Melbourne.length);
Cocoa[Cocoa.length] = createMarker(new GPoint(-80.79714000,28.47772200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Florida Learning Academy",'Cocoa=' + Cocoa.length);
Melbourne[Melbourne.length] = createMarker(new GPoint(-80.69734900,28.22591400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Trinity Episcopal Academy",'Melbourne=' + Melbourne.length);
Palm_Bay[Palm_Bay.length] = createMarker(new GPoint(-80.60543300,28.03986800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Liberty High School",'Palm_Bay=' + Palm_Bay.length);
Melbourne[Melbourne.length] = createMarker(new GPoint(-80.62121800,28.05711100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Melbourne Central Catholic High School",'Melbourne=' + Melbourne.length);
Merritt_Island[Merritt_Island.length] = createMarker(new GPoint(-80.70107200,28.35600000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Merritt Island Christian School",'Merritt_Island=' + Merritt_Island.length);
Melbourne[Melbourne.length] = createMarker(new GPoint(-80.62161200,28.07956100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Covenant Christian School",'Melbourne=' + Melbourne.length);
Palm_Bay[Palm_Bay.length] = createMarker(new GPoint(-80.60530000,28.04490000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Palm Bay Christian Academy",'Palm_Bay=' + Palm_Bay.length);
Sharpes[Sharpes.length] = createMarker(new GPoint(-80.76020000,28.43190000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pioneer Christian School",'Sharpes=' + Sharpes.length);
Melbourne[Melbourne.length] = createMarker(new GPoint(-80.61928500,28.09689000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rfm Christian Academy",'Melbourne=' + Melbourne.length);
Melbourne[Melbourne.length] = createMarker(new GPoint(-80.63038700,28.12647600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sancta Familia Academy",'Melbourne=' + Melbourne.length);
Titusville[Titusville.length] = createMarker(new GPoint(-80.83094000,28.63870000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Temple Christian Schools",'Titusville=' + Titusville.length);
Melbourne[Melbourne.length] = createMarker(new GPoint(-80.67225500,28.17903700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wade Christian Academy",'Melbourne=' + Melbourne.length);
Melbourne[Melbourne.length] = createMarker(new GPoint(-80.67373900,28.06856300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West Melbourne Christian Academy",'Melbourne=' + Melbourne.length);
Merritt_Island[Merritt_Island.length] = createMarker(new GPoint(-80.70636300,28.40264300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wise Christian School",'Merritt_Island=' + Merritt_Island.length);
Palm_Bay[Palm_Bay.length] = createMarker(new GPoint(-80.61496100,28.03894500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("York Christian Academy",'Palm_Bay=' + Palm_Bay.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/////2/' + showArray);
map.removeOverlays(Cocoa);
map.removeOverlays(Cocoa_Beach);
map.removeOverlays(Melbourne);
map.removeOverlays(Merritt_Island);
map.removeOverlays(Mims);
map.removeOverlays(Palm_Bay);
map.removeOverlays(Rockledge);
map.removeOverlays(Sharpes);
map.removeOverlays(Titusville);
map.removeOverlays(West_Melbourne);
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(Cocoa);map.removeOverlays(Cocoa);
map.removeOverlays(Cocoa_Beach);
map.removeOverlays(Melbourne);
map.removeOverlays(Merritt_Island);
map.removeOverlays(Mims);
map.removeOverlays(Palm_Bay);
map.removeOverlays(Rockledge);
map.removeOverlays(Sharpes);
map.removeOverlays(Titusville);
map.removeOverlays(West_Melbourne);
map.addOverlays(Cocoa);
centerByArray(Cocoa, false, false);
cntMarker += Cocoa.length;
map.addOverlays(Cocoa_Beach);
centerByArray(Cocoa_Beach, false, false);
cntMarker += Cocoa_Beach.length;
map.addOverlays(Melbourne);
centerByArray(Melbourne, false, false);
cntMarker += Melbourne.length;
map.addOverlays(Merritt_Island);
centerByArray(Merritt_Island, false, false);
cntMarker += Merritt_Island.length;
map.addOverlays(Mims);
centerByArray(Mims, false, false);
cntMarker += Mims.length;
map.addOverlays(Palm_Bay);
centerByArray(Palm_Bay, false, false);
cntMarker += Palm_Bay.length;
map.addOverlays(Rockledge);
centerByArray(Rockledge, false, false);
cntMarker += Rockledge.length;
map.addOverlays(Sharpes);
centerByArray(Sharpes, false, false);
cntMarker += Sharpes.length;
map.addOverlays(Titusville);
centerByArray(Titusville, false, false);
cntMarker += Titusville.length;
map.addOverlays(West_Melbourne);
centerByArray(West_Melbourne, false, false);
cntMarker += West_Melbourne.length;
centerByArray(Cocoa,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=2&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;
}