function addMarkers()
{
mySelect = document.getElementById('selection');
Warner_Robins = [];Bonaire = [];Centerville = [];Byron = [];Perry = [];Kathleen = [];Robins_Afb = [];mySelect.options[mySelect.options.length] = new Option("Bonaire schools",'all=Bonaire');
mySelect.options[mySelect.options.length] = new Option("Byron schools",'all=Byron');
mySelect.options[mySelect.options.length] = new Option("Centerville schools",'all=Centerville');
mySelect.options[mySelect.options.length] = new Option("Kathleen schools",'all=Kathleen');
mySelect.options[mySelect.options.length] = new Option("Perry schools",'all=Perry');
mySelect.options[mySelect.options.length] = new Option("Robins Afb schools",'all=Robins_Afb');
mySelect.options[mySelect.options.length] = new Option("Warner Robins schools",'all=Warner_Robins');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Warner_Robins[Warner_Robins.length] = createMarker(new GPoint(-83.61325836,32.61324310),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bert Rumble Middle School",'Warner_Robins=' + Warner_Robins.length);
Bonaire[Bonaire.length] = createMarker(new GPoint(-83.60053253,32.54890823),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bonaire Elementary School",'Bonaire=' + Bonaire.length);
Bonaire[Bonaire.length] = createMarker(new GPoint(-83.59622955,32.54547882),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bonaire Middle School",'Bonaire=' + Bonaire.length);
Centerville[Centerville.length] = createMarker(new GPoint(-83.68953705,32.62870789),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Centerville Elementary School",'Centerville=' + Centerville.length);
Warner_Robins[Warner_Robins.length] = createMarker(new GPoint(-83.64679718,32.64319992),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("David A. Perdue Primary",'Warner_Robins=' + Warner_Robins.length);
Byron[Byron.length] = createMarker(new GPoint(-83.70917511,32.63046265),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Eagle Springs Elementary School",'Byron=' + Byron.length);
Warner_Robins[Warner_Robins.length] = createMarker(new GPoint(-83.67647552,32.57112122),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Feagin Mill Middle School",'Warner_Robins=' + Warner_Robins.length);
Warner_Robins[Warner_Robins.length] = createMarker(new GPoint(-83.65583038,32.59580612),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Houston County Career And Technology Center",'Warner_Robins=' + Warner_Robins.length);
Warner_Robins[Warner_Robins.length] = createMarker(new GPoint(-83.64855957,32.64302063),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Houston County High School",'Warner_Robins=' + Warner_Robins.length);
Warner_Robins[Warner_Robins.length] = createMarker(new GPoint(-83.62185669,32.65610504),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Houston County Psychological Services Department",'Warner_Robins=' + Warner_Robins.length);
Perry[Perry.length] = createMarker(new GPoint(-83.65343475,32.45701981),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kings Chapel Elementary School",'Perry=' + Perry.length);
Warner_Robins[Warner_Robins.length] = createMarker(new GPoint(-83.64679718,32.64319992),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lake Joy Elementary School",'Warner_Robins=' + Warner_Robins.length);
Warner_Robins[Warner_Robins.length] = createMarker(new GPoint(-83.61540222,32.63863754),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lindsey Elementary School",'Warner_Robins=' + Warner_Robins.length);
Warner_Robins[Warner_Robins.length] = createMarker(new GPoint(-83.60655975,32.61183929),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Linwood Elementary School",'Warner_Robins=' + Warner_Robins.length);
Kathleen[Kathleen.length] = createMarker(new GPoint(-83.60800171,32.49576187),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Matthew Arthur Elementary School",'Kathleen=' + Kathleen.length);
Warner_Robins[Warner_Robins.length] = createMarker(new GPoint(-83.63867950,32.61255264),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Miller Elementary School",'Warner_Robins=' + Warner_Robins.length);
Perry[Perry.length] = createMarker(new GPoint(-83.71113586,32.46177292),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Morningside Elementary School",'Perry=' + Perry.length);
Warner_Robins[Warner_Robins.length] = createMarker(new GPoint(-83.65510559,32.65738297),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Northside Elementary School",'Warner_Robins=' + Warner_Robins.length);
Warner_Robins[Warner_Robins.length] = createMarker(new GPoint(-83.63005066,32.62643814),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northside High School",'Warner_Robins=' + Warner_Robins.length);
Warner_Robins[Warner_Robins.length] = createMarker(new GPoint(-83.64566040,32.63463593),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Northside Middle School",'Warner_Robins=' + Warner_Robins.length);
Warner_Robins[Warner_Robins.length] = createMarker(new GPoint(-83.62936401,32.62396622),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Parkwood Elementary School",'Warner_Robins=' + Warner_Robins.length);
Warner_Robins[Warner_Robins.length] = createMarker(new GPoint(-83.61732483,32.59999466),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pearl Stephens Elementary School",'Warner_Robins=' + Warner_Robins.length);
Warner_Robins[Warner_Robins.length] = createMarker(new GPoint(-83.60015106,32.62147141),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Perdue Elementary School",'Warner_Robins=' + Warner_Robins.length);
Perry[Perry.length] = createMarker(new GPoint(-83.72708893,32.45722580),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Perry Elementary School",'Perry=' + Perry.length);
Perry[Perry.length] = createMarker(new GPoint(-83.72647858,32.46693802),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Perry High School",'Perry=' + Perry.length);
Perry[Perry.length] = createMarker(new GPoint(-83.74262238,32.49330139),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Perry Middle School",'Perry=' + Perry.length);
Perry[Perry.length] = createMarker(new GPoint(-83.72303772,32.46106339),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Perry Primary School",'Perry=' + Perry.length);
Warner_Robins[Warner_Robins.length] = createMarker(new GPoint(-83.68761444,32.60948944),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Quail Run Elementary School",'Warner_Robins=' + Warner_Robins.length);
Robins_Afb[Robins_Afb.length] = createMarker(new GPoint(-83.60655975,32.61183929),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Robins Elementary School",'Robins_Afb=' + Robins_Afb.length);
Warner_Robins[Warner_Robins.length] = createMarker(new GPoint(-83.63458252,32.59523773),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Russell Elementary School",'Warner_Robins=' + Warner_Robins.length);
Warner_Robins[Warner_Robins.length] = createMarker(new GPoint(-83.65081024,32.60393143),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Shirley Hills Elementary School",'Warner_Robins=' + Warner_Robins.length);
Centerville[Centerville.length] = createMarker(new GPoint(-83.62989044,32.62643814),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Tabor Middle School",'Centerville=' + Centerville.length);
Perry[Perry.length] = createMarker(new GPoint(-83.72248840,32.44982147),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Tucker Elementary School",'Perry=' + Perry.length);
Warner_Robins[Warner_Robins.length] = createMarker(new GPoint(-83.61293793,32.61234283),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Warner Robins High School",'Warner_Robins=' + Warner_Robins.length);
Warner_Robins[Warner_Robins.length] = createMarker(new GPoint(-83.65376282,32.60002136),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Warner Robins Middle School",'Warner_Robins=' + Warner_Robins.length);
Warner_Robins[Warner_Robins.length] = createMarker(new GPoint(-83.61209869,32.60884094),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Watson Center",'Warner_Robins=' + Warner_Robins.length);
Warner_Robins[Warner_Robins.length] = createMarker(new GPoint(-83.62266541,32.62033844),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Westside Elementary School",'Warner_Robins=' + Warner_Robins.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(Bonaire);
map.removeOverlays(Byron);
map.removeOverlays(Centerville);
map.removeOverlays(Kathleen);
map.removeOverlays(Perry);
map.removeOverlays(Robins_Afb);
map.removeOverlays(Warner_Robins);
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(Warner_Robins);map.removeOverlays(Bonaire);
map.removeOverlays(Byron);
map.removeOverlays(Centerville);
map.removeOverlays(Kathleen);
map.removeOverlays(Perry);
map.removeOverlays(Robins_Afb);
map.removeOverlays(Warner_Robins);
map.addOverlays(Bonaire);
centerByArray(Bonaire, false, false);
cntMarker += Bonaire.length;
map.addOverlays(Byron);
centerByArray(Byron, false, false);
cntMarker += Byron.length;
map.addOverlays(Centerville);
centerByArray(Centerville, false, false);
cntMarker += Centerville.length;
map.addOverlays(Kathleen);
centerByArray(Kathleen, false, false);
cntMarker += Kathleen.length;
map.addOverlays(Perry);
centerByArray(Perry, false, false);
cntMarker += Perry.length;
map.addOverlays(Robins_Afb);
centerByArray(Robins_Afb, false, false);
cntMarker += Robins_Afb.length;
map.addOverlays(Warner_Robins);
centerByArray(Warner_Robins, false, false);
cntMarker += Warner_Robins.length;
centerByArray(Warner_Robins,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');
}
}