function addMarkers(){
mySelect = document.getElementById('selection');
Seminole = [];Gulf_Shores = [];Fairhope = [];Daphne = [];Robertsdale = [];Spanish_Fort = [];Foley = [];Elberta = [];mySelect.options[mySelect.options.length] = new Option("Daphne schools",'all=Daphne');
mySelect.options[mySelect.options.length] = new Option("Elberta schools",'all=Elberta');
mySelect.options[mySelect.options.length] = new Option("Fairhope schools",'all=Fairhope');
mySelect.options[mySelect.options.length] = new Option("Foley schools",'all=Foley');
mySelect.options[mySelect.options.length] = new Option("Gulf Shores schools",'all=Gulf_Shores');
mySelect.options[mySelect.options.length] = new Option("Robertsdale schools",'all=Robertsdale');
mySelect.options[mySelect.options.length] = new Option("Seminole schools",'all=Seminole');
mySelect.options[mySelect.options.length] = new Option("Spanish Fort schools",'all=Spanish_Fort');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Seminole[Seminole.length] = createMarker(new GPoint(-87.46910500,30.50926300),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Academy At Mission Samaria",'Seminole=' + Seminole.length);
Gulf_Shores[Gulf_Shores.length] = createMarker(new GPoint(-87.68289400,30.32485000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Academy of Arts & Sciences",'Gulf_Shores=' + Gulf_Shores.length);
Fairhope[Fairhope.length] = createMarker(new GPoint(-87.89340400,30.55834000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bayshore Christian School",'Fairhope=' + Fairhope.length);
Daphne[Daphne.length] = createMarker(new GPoint(-87.90546600,30.60126500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bayside Academy",'Daphne=' + Daphne.length);
Robertsdale[Robertsdale.length] = createMarker(new GPoint(-87.62920000,30.58330000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central Christian School",'Robertsdale=' + Robertsdale.length);
Daphne[Daphne.length] = createMarker(new GPoint(-87.90596900,30.60784000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christ The King Catholic School",'Daphne=' + Daphne.length);
Daphne[Daphne.length] = createMarker(new GPoint(-87.85311300,30.64033700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eastern Shore Christian Academy",'Daphne=' + Daphne.length);
Fairhope[Fairhope.length] = createMarker(new GPoint(-87.87942600,30.52349400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eastern Shore Early Childhood",'Fairhope=' + Fairhope.length);
Robertsdale[Robertsdale.length] = createMarker(new GPoint(-87.63201200,30.58314200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Presbyterian Christian School",'Robertsdale=' + Robertsdale.length);
Gulf_Shores[Gulf_Shores.length] = createMarker(new GPoint(-87.68310400,30.27732000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grace Christian Academy",'Gulf_Shores=' + Gulf_Shores.length);
Fairhope[Fairhope.length] = createMarker(new GPoint(-87.88120400,30.50837800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Marietta Johnson School Of Organic Education",'Fairhope=' + Fairhope.length);
Spanish_Fort[Spanish_Fort.length] = createMarker(new GPoint(-87.91820000,30.72400000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Old Spanish Fort Chrst School",'Spanish_Fort=' + Spanish_Fort.length);
Foley[Foley.length] = createMarker(new GPoint(-87.67011200,30.35556300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Open Door Christian School",'Foley=' + Foley.length);
Robertsdale[Robertsdale.length] = createMarker(new GPoint(-87.71693500,30.56224000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Patrick School",'Robertsdale=' + Robertsdale.length);
Elberta[Elberta.length] = createMarker(new GPoint(-87.55940000,30.38890000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Benedict School",'Elberta=' + Elberta.length);
Foley[Foley.length] = createMarker(new GPoint(-87.67308300,30.35578500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Victory Christian School",'Foley=' + Foley.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(Daphne);
map.removeOverlays(Elberta);
map.removeOverlays(Fairhope);
map.removeOverlays(Foley);
map.removeOverlays(Gulf_Shores);
map.removeOverlays(Robertsdale);
map.removeOverlays(Seminole);
map.removeOverlays(Spanish_Fort);
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(Seminole);map.removeOverlays(Daphne);
map.removeOverlays(Elberta);
map.removeOverlays(Fairhope);
map.removeOverlays(Foley);
map.removeOverlays(Gulf_Shores);
map.removeOverlays(Robertsdale);
map.removeOverlays(Seminole);
map.removeOverlays(Spanish_Fort);
map.addOverlays(Daphne);
centerByArray(Daphne, false, false);
cntMarker += Daphne.length;
map.addOverlays(Elberta);
centerByArray(Elberta, false, false);
cntMarker += Elberta.length;
map.addOverlays(Fairhope);
centerByArray(Fairhope, false, false);
cntMarker += Fairhope.length;
map.addOverlays(Foley);
centerByArray(Foley, false, false);
cntMarker += Foley.length;
map.addOverlays(Gulf_Shores);
centerByArray(Gulf_Shores, false, false);
cntMarker += Gulf_Shores.length;
map.addOverlays(Robertsdale);
centerByArray(Robertsdale, false, false);
cntMarker += Robertsdale.length;
map.addOverlays(Seminole);
centerByArray(Seminole, false, false);
cntMarker += Seminole.length;
map.addOverlays(Spanish_Fort);
centerByArray(Spanish_Fort, false, false);
cntMarker += Spanish_Fort.length;
centerByArray(Seminole,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;
}