function addMarkers(){
mySelect = document.getElementById('selection');
Alachua = [];Gainesville = [];Archer = [];High_Springs = [];Sanford = [];mySelect.options[mySelect.options.length] = new Option("Alachua schools",'all=Alachua');
mySelect.options[mySelect.options.length] = new Option("Archer schools",'all=Archer');
mySelect.options[mySelect.options.length] = new Option("Gainesville schools",'all=Gainesville');
mySelect.options[mySelect.options.length] = new Option("High Springs schools",'all=High_Springs');
mySelect.options[mySelect.options.length] = new Option("Sanford schools",'all=Sanford');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Alachua[Alachua.length] = createMarker(new GPoint(-82.49427900,29.79309000),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bhaktivedanta Academy",'Alachua=' + Alachua.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-82.38123700,29.67080700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bnai Israel Day School",'Gainesville=' + Gainesville.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-82.38118300,29.67081400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bnai Israel School",'Gainesville=' + Gainesville.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-82.40134100,29.66243700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Brentwood School",'Gainesville=' + Gainesville.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-82.36808700,29.60018200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Children's Center",'Gainesville=' + Gainesville.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-82.47061800,29.56976100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christian Life Academy",'Gainesville=' + Gainesville.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-82.37170000,29.67710000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Compassionate Outreach Ministries Christian Acdmy",'Gainesville=' + Gainesville.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-82.37665500,29.65964100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cornerstone Academy",'Gainesville=' + Gainesville.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-82.45816000,29.68920000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Countryside Christian School",'Gainesville=' + Gainesville.length);
Alachua[Alachua.length] = createMarker(new GPoint(-82.49427900,29.79309000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Destiny Christian Academy",'Alachua=' + Alachua.length);
Archer[Archer.length] = createMarker(new GPoint(-82.53570000,29.52573100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Family Life Academy",'Archer=' + Archer.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-82.36230100,29.69632500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Family Worship Center",'Gainesville=' + Gainesville.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-82.36836500,29.68136300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Flowers Montessori School",'Gainesville=' + Gainesville.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-82.39790000,29.70770000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gainesville Christian Academy",'Gainesville=' + Gainesville.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-82.41455000,29.63402500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gainesville Country Day School",'Gainesville=' + Gainesville.length);
Alachua[Alachua.length] = createMarker(new GPoint(-82.49010000,29.80670000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Incaf Montessori School",'Alachua=' + Alachua.length);
Archer[Archer.length] = createMarker(new GPoint(-82.50642800,29.54036000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jordan Glen School",'Archer=' + Archer.length);
High_Springs[High_Springs.length] = createMarker(new GPoint(-82.59109500,29.84942900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Living Spring Academy",'High_Springs=' + High_Springs.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-82.42419600,29.63956400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Martha Manson Lower School",'Gainesville=' + Gainesville.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-82.43274400,29.68864800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Millhopper Montessori School",'Gainesville=' + Gainesville.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-82.42593600,29.63944000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Oak Hall School",'Gainesville=' + Gainesville.length);
Sanford[Sanford.length] = createMarker(new GPoint(-81.31054800,28.81092400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Page Private School",'Sanford=' + Sanford.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-82.45725000,29.63080500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Queen Of Peace Cath Academy",'Gainesville=' + Gainesville.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-82.44871300,29.63073300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Rock School",'Gainesville=' + Gainesville.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-82.31903600,29.66669300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Patrick Interparish School",'Gainesville=' + Gainesville.length);
Alachua[Alachua.length] = createMarker(new GPoint(-82.49361200,29.78879400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Spencer House Montessori",'Alachua=' + Alachua.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-82.29995900,29.66951700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Star Christian Center And Academy",'Gainesville=' + Gainesville.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-82.43469100,29.67446600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trilogy School",'Gainesville=' + Gainesville.length);
Alachua[Alachua.length] = createMarker(new GPoint(-82.46259600,29.83042900),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Vaishnava Academy For Girls",'Alachua=' + Alachua.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-82.37255700,29.66577300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Westwood Hills Christian",'Gainesville=' + Gainesville.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-82.19131600,29.63320400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Windsor Christian Academy",'Gainesville=' + Gainesville.length);
Gainesville[Gainesville.length] = createMarker(new GPoint(-82.35186900,29.68836300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Z L Sung Sda School",'Gainesville=' + Gainesville.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/////3/' + showArray);
map.removeOverlays(Alachua);
map.removeOverlays(Archer);
map.removeOverlays(Gainesville);
map.removeOverlays(High_Springs);
map.removeOverlays(Sanford);
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(Alachua);map.removeOverlays(Alachua);
map.removeOverlays(Archer);
map.removeOverlays(Gainesville);
map.removeOverlays(High_Springs);
map.removeOverlays(Sanford);
map.addOverlays(Alachua);
centerByArray(Alachua, false, false);
cntMarker += Alachua.length;
map.addOverlays(Archer);
centerByArray(Archer, false, false);
cntMarker += Archer.length;
map.addOverlays(Gainesville);
centerByArray(Gainesville, false, false);
cntMarker += Gainesville.length;
map.addOverlays(High_Springs);
centerByArray(High_Springs, false, false);
cntMarker += High_Springs.length;
map.addOverlays(Sanford);
centerByArray(Sanford, false, false);
cntMarker += Sanford.length;
centerByArray(Alachua,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=3&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;
}