function addMarkers()
{
mySelect = document.getElementById('selection');
Quincy = [];Chattahoochee = [];Havana = [];Greensboro = [];Gretna = [];Midway = [];mySelect.options[mySelect.options.length] = new Option("Chattahoochee schools",'all=Chattahoochee');
mySelect.options[mySelect.options.length] = new Option("Greensboro schools",'all=Greensboro');
mySelect.options[mySelect.options.length] = new Option("Gretna schools",'all=Gretna');
mySelect.options[mySelect.options.length] = new Option("Havana schools",'all=Havana');
mySelect.options[mySelect.options.length] = new Option("Midway schools",'all=Midway');
mySelect.options[mySelect.options.length] = new Option("Quincy schools",'all=Quincy');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Quincy[Quincy.length] = createMarker(new GPoint(-84.58093900,30.58814100),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bold Step Infant Care",'Quincy=' + Quincy.length);
Quincy[Quincy.length] = createMarker(new GPoint(-84.58100891,30.57943344),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Carter Parramore Academy",'Quincy=' + Quincy.length);
Chattahoochee[Chattahoochee.length] = createMarker(new GPoint(-84.83522797,30.70009422),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Chattahoochee Elementary School",'Chattahoochee=' + Chattahoochee.length);
Quincy[Quincy.length] = createMarker(new GPoint(-84.55680084,30.56599236),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Crossenioroad Academy",'Quincy=' + Quincy.length);
Quincy[Quincy.length] = createMarker(new GPoint(-84.57669067,30.57786369),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dick Howser Center",'Quincy=' + Quincy.length);
Havana[Havana.length] = createMarker(new GPoint(-84.41529846,30.61190033),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("East Gadsden High School",'Havana=' + Havana.length);
Chattahoochee[Chattahoochee.length] = createMarker(new GPoint(-84.80940247,30.67460060),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Florida State Hospital",'Chattahoochee=' + Chattahoochee.length);
Quincy[Quincy.length] = createMarker(new GPoint(-84.58093900,30.58814100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gadsden County Superintendent's Office",'Quincy=' + Quincy.length);
Quincy[Quincy.length] = createMarker(new GPoint(-84.57814789,30.57819939),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gadsden Technical Institute High School",'Quincy=' + Quincy.length);
Quincy[Quincy.length] = createMarker(new GPoint(-84.58276367,30.59123611),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Gadsen Elementary Magnet School",'Quincy=' + Quincy.length);
Quincy[Quincy.length] = createMarker(new GPoint(-84.60131073,30.59113693),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("George W. Munroe Elementary School",'Quincy=' + Quincy.length);
Quincy[Quincy.length] = createMarker(new GPoint(-84.76555634,30.57424736),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Greensboro Elementary School",'Quincy=' + Quincy.length);
Greensboro[Greensboro.length] = createMarker(new GPoint(-84.74330139,30.56909943),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Greensboro High School",'Greensboro=' + Greensboro.length);
Gretna[Gretna.length] = createMarker(new GPoint(-84.66053772,30.60630035),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Gretna Elementary School",'Gretna=' + Gretna.length);
Havana[Havana.length] = createMarker(new GPoint(-84.41966248,30.61548233),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Havana Elementary School",'Havana=' + Havana.length);
Havana[Havana.length] = createMarker(new GPoint(-84.39044189,30.62561417),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Havana Middle School",'Havana=' + Havana.length);
Havana[Havana.length] = createMarker(new GPoint(-84.41187286,30.63793564),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Havana Northside High School",'Havana=' + Havana.length);
Quincy[Quincy.length] = createMarker(new GPoint(-84.57669067,30.57786369),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Head Start Program",'Quincy=' + Quincy.length);
Quincy[Quincy.length] = createMarker(new GPoint(-84.59430695,30.59097862),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("James A. Shanks Middle School",'Quincy=' + Quincy.length);
Midway[Midway.length] = createMarker(new GPoint(-84.45438385,30.49400330),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Midway Magnet Center",'Midway=' + Midway.length);
Quincy[Quincy.length] = createMarker(new GPoint(-84.57669067,30.57786369),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Horizons",'Quincy=' + Quincy.length);
Quincy[Quincy.length] = createMarker(new GPoint(-84.58276367,30.59123611),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Quincy Educational Academy",'Quincy=' + Quincy.length);
Quincy[Quincy.length] = createMarker(new GPoint(-84.60578918,30.65855408),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Saint Johns Elementary School",'Quincy=' + Quincy.length);
Quincy[Quincy.length] = createMarker(new GPoint(-84.58103943,30.57676888),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Stewart Street Elementary School",'Quincy=' + Quincy.length);
Quincy[Quincy.length] = createMarker(new GPoint(-84.57669067,30.57786369),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("W. S. Stephens Alternative Program",'Quincy=' + Quincy.length);
Quincy[Quincy.length] = createMarker(new GPoint(-84.58276367,30.59123611),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Windrush (formerly Bridgewood Academy)",'Quincy=' + Quincy.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(Chattahoochee);
map.removeOverlays(Greensboro);
map.removeOverlays(Gretna);
map.removeOverlays(Havana);
map.removeOverlays(Midway);
map.removeOverlays(Quincy);
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(Quincy);map.removeOverlays(Chattahoochee);
map.removeOverlays(Greensboro);
map.removeOverlays(Gretna);
map.removeOverlays(Havana);
map.removeOverlays(Midway);
map.removeOverlays(Quincy);
map.addOverlays(Chattahoochee);
centerByArray(Chattahoochee, false, false);
cntMarker += Chattahoochee.length;
map.addOverlays(Greensboro);
centerByArray(Greensboro, false, false);
cntMarker += Greensboro.length;
map.addOverlays(Gretna);
centerByArray(Gretna, false, false);
cntMarker += Gretna.length;
map.addOverlays(Havana);
centerByArray(Havana, false, false);
cntMarker += Havana.length;
map.addOverlays(Midway);
centerByArray(Midway, false, false);
cntMarker += Midway.length;
map.addOverlays(Quincy);
centerByArray(Quincy, false, false);
cntMarker += Quincy.length;
centerByArray(Quincy,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');
}
}