function addMarkers()
{
mySelect = document.getElementById('selection');
Vero_Beach = [];Fellsmere = [];Sebastian = [];mySelect.options[mySelect.options.length] = new Option("Fellsmere schools",'all=Fellsmere');
mySelect.options[mySelect.options.length] = new Option("Sebastian schools",'all=Sebastian');
mySelect.options[mySelect.options.length] = new Option("Vero Beach schools",'all=Vero_Beach');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Vero_Beach[Vero_Beach.length] = createMarker(new GPoint(-80.39968500,27.63617900),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Adult And Community Edu School",'Vero_Beach=' + Vero_Beach.length);
Vero_Beach[Vero_Beach.length] = createMarker(new GPoint(-80.41424561,27.67814445),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Alternative Center For Education",'Vero_Beach=' + Vero_Beach.length);
Vero_Beach[Vero_Beach.length] = createMarker(new GPoint(-80.36753845,27.65363884),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Beachland Elementary School",'Vero_Beach=' + Vero_Beach.length);
Vero_Beach[Vero_Beach.length] = createMarker(new GPoint(-80.41455078,27.61046219),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Citrus Elementary School",'Vero_Beach=' + Vero_Beach.length);
Vero_Beach[Vero_Beach.length] = createMarker(new GPoint(-80.42952728,27.67411995),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dodgertown Elementary School",'Vero_Beach=' + Vero_Beach.length);
Vero_Beach[Vero_Beach.length] = createMarker(new GPoint(-80.40517426,27.64463615),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Exceptional Student Education",'Vero_Beach=' + Vero_Beach.length);
Fellsmere[Fellsmere.length] = createMarker(new GPoint(-80.60375214,27.76924706),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fellsmere Elementary School",'Fellsmere=' + Fellsmere.length);
Vero_Beach[Vero_Beach.length] = createMarker(new GPoint(-80.41424561,27.67564011),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Gifford Middle School",'Vero_Beach=' + Vero_Beach.length);
Vero_Beach[Vero_Beach.length] = createMarker(new GPoint(-80.43798828,27.61673737),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Glendale Elementary School",'Vero_Beach=' + Vero_Beach.length);
Vero_Beach[Vero_Beach.length] = createMarker(new GPoint(-80.38307953,27.56791687),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Highlands Elementary School",'Vero_Beach=' + Vero_Beach.length);
Vero_Beach[Vero_Beach.length] = createMarker(new GPoint(-80.43148300,27.65446200),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Indian River Academy",'Vero_Beach=' + Vero_Beach.length);
Vero_Beach[Vero_Beach.length] = createMarker(new GPoint(-80.45506287,27.63493729),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Indian River Charter High School",'Vero_Beach=' + Vero_Beach.length);
Vero_Beach[Vero_Beach.length] = createMarker(new GPoint(-80.39422400,27.63885000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Indian River County Superintendent's Office",'Vero_Beach=' + Vero_Beach.length);
Sebastian[Sebastian.length] = createMarker(new GPoint(-80.44529724,27.74990082),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Liberty Magnet School",'Sebastian=' + Sebastian.length);
Fellsmere[Fellsmere.length] = createMarker(new GPoint(-80.59294128,27.76804733),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("North County Charter School",'Fellsmere=' + Fellsmere.length);
Vero_Beach[Vero_Beach.length] = createMarker(new GPoint(-80.38654327,27.63780975),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Osceola Magnet School",'Vero_Beach=' + Vero_Beach.length);
Vero_Beach[Vero_Beach.length] = createMarker(new GPoint(-80.40574646,27.59538651),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Oslo Middle School",'Vero_Beach=' + Vero_Beach.length);
Sebastian[Sebastian.length] = createMarker(new GPoint(-80.46394348,27.76271248),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pelican Island Elementary School",'Sebastian=' + Sebastian.length);
Vero_Beach[Vero_Beach.length] = createMarker(new GPoint(-80.42510223,27.63123703),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Rosewood Magnet School",'Vero_Beach=' + Vero_Beach.length);
Vero_Beach[Vero_Beach.length] = createMarker(new GPoint(-81.32143900,29.91300400),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Saint Peter's Academy",'Vero_Beach=' + Vero_Beach.length);
Sebastian[Sebastian.length] = createMarker(new GPoint(-80.47091675,27.81609917),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sebastian Elementary School",'Sebastian=' + Sebastian.length);
Sebastian[Sebastian.length] = createMarker(new GPoint(-80.45595551,27.76282120),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Sebastian Junior High Charter",'Sebastian=' + Sebastian.length);
Sebastian[Sebastian.length] = createMarker(new GPoint(-80.47091675,27.81609917),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Sebastian River Middle School",'Sebastian=' + Sebastian.length);
Sebastian[Sebastian.length] = createMarker(new GPoint(-80.47091675,27.81609917),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sebastian River Senior High School",'Sebastian=' + Sebastian.length);
Vero_Beach[Vero_Beach.length] = createMarker(new GPoint(-80.40435791,27.58300209),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Thompson Elementary School",'Vero_Beach=' + Vero_Beach.length);
Vero_Beach[Vero_Beach.length] = createMarker(new GPoint(-80.40351868,27.62368393),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Vero Beach Elementary School",'Vero_Beach=' + Vero_Beach.length);
Vero_Beach[Vero_Beach.length] = createMarker(new GPoint(-80.40281677,27.63066292),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Vero Beach High School",'Vero_Beach=' + Vero_Beach.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,10);
/*
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(Fellsmere);
map.removeOverlays(Sebastian);
map.removeOverlays(Vero_Beach);
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(Vero_Beach);map.removeOverlays(Fellsmere);
map.removeOverlays(Sebastian);
map.removeOverlays(Vero_Beach);
map.addOverlays(Fellsmere);
centerByArray(Fellsmere, false, false);
cntMarker += Fellsmere.length;
map.addOverlays(Sebastian);
centerByArray(Sebastian, false, false);
cntMarker += Sebastian.length;
map.addOverlays(Vero_Beach);
centerByArray(Vero_Beach, false, false);
cntMarker += Vero_Beach.length;
centerByArray(Vero_Beach,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');
}
}