function addMarkers()
{
mySelect = document.getElementById('selection');
Cape_Girardeau = [];Delta = [];Jackson = [];Millersville = [];Oak_Ridge = [];mySelect.options[mySelect.options.length] = new Option("Cape Girardeau schools",'all=Cape_Girardeau');
mySelect.options[mySelect.options.length] = new Option("Delta schools",'all=Delta');
mySelect.options[mySelect.options.length] = new Option("Jackson schools",'all=Jackson');
mySelect.options[mySelect.options.length] = new Option("Millersville schools",'all=Millersville');
mySelect.options[mySelect.options.length] = new Option("Oak Ridge schools",'all=Oak_Ridge');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Cape_Girardeau[Cape_Girardeau.length] = createMarker(new GPoint(-89.55464172,37.32754517),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Alma Schrader Elementary School",'Cape_Girardeau=' + Cape_Girardeau.length);
Cape_Girardeau[Cape_Girardeau.length] = createMarker(new GPoint(-89.52321625,37.32978058),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Blanchard Elementary School",'Cape_Girardeau=' + Cape_Girardeau.length);
Cape_Girardeau[Cape_Girardeau.length] = createMarker(new GPoint(-89.56636047,37.27548981),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cape Girardeau Car. & Technical Center",'Cape_Girardeau=' + Cape_Girardeau.length);
Cape_Girardeau[Cape_Girardeau.length] = createMarker(new GPoint(-89.56655884,37.31040573),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central High School",'Cape_Girardeau=' + Cape_Girardeau.length);
Cape_Girardeau[Cape_Girardeau.length] = createMarker(new GPoint(-89.54493713,37.30796051),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Central Junior High School",'Cape_Girardeau=' + Cape_Girardeau.length);
Cape_Girardeau[Cape_Girardeau.length] = createMarker(new GPoint(-89.54452515,37.31106949),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Central Middle School",'Cape_Girardeau=' + Cape_Girardeau.length);
Cape_Girardeau[Cape_Girardeau.length] = createMarker(new GPoint(-89.57043457,37.32136917),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clippard Elementary School",'Cape_Girardeau=' + Cape_Girardeau.length);
Delta[Delta.length] = createMarker(new GPoint(-89.76689911,37.18239975),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Delta Elementary School",'Delta=' + Delta.length);
Delta[Delta.length] = createMarker(new GPoint(-89.76689911,37.18239975),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Delta High School",'Delta=' + Delta.length);
Cape_Girardeau[Cape_Girardeau.length] = createMarker(new GPoint(-89.57473755,37.28596115),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Echo Day Treatment Ctr.",'Cape_Girardeau=' + Cape_Girardeau.length);
Cape_Girardeau[Cape_Girardeau.length] = createMarker(new GPoint(-89.53818512,37.30731583),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Franklin Elementary School",'Cape_Girardeau=' + Cape_Girardeau.length);
Cape_Girardeau[Cape_Girardeau.length] = createMarker(new GPoint(-93.26392365,44.98011780),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Girardot Center For Youth",'Cape_Girardeau=' + Cape_Girardeau.length);
Cape_Girardeau[Cape_Girardeau.length] = createMarker(new GPoint(-89.67618561,37.31112289),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Gordonville Attendance Center",'Cape_Girardeau=' + Cape_Girardeau.length);
Jackson[Jackson.length] = createMarker(new GPoint(-89.68589020,37.39440536),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Jackson Middle School",'Jackson=' + Jackson.length);
Jackson[Jackson.length] = createMarker(new GPoint(-89.66938019,37.38055038),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jackson Senior High School",'Jackson=' + Jackson.length);
Cape_Girardeau[Cape_Girardeau.length] = createMarker(new GPoint(-89.54182434,37.29870987),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'Cape_Girardeau=' + Cape_Girardeau.length);
Cape_Girardeau[Cape_Girardeau.length] = createMarker(new GPoint(-89.53034210,37.30295181),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("L. J. Schultz Junior High School",'Cape_Girardeau=' + Cape_Girardeau.length);
Millersville[Millersville.length] = createMarker(new GPoint(-89.79907990,37.43289948),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Millersville Attendance Center",'Millersville=' + Millersville.length);
Cape_Girardeau[Cape_Girardeau.length] = createMarker(new GPoint(-89.47316742,37.38742065),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Nell Holcomb Elementary School",'Cape_Girardeau=' + Cape_Girardeau.length);
Jackson[Jackson.length] = createMarker(new GPoint(-93.12229919,40.19342422),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("North Elementary School",'Jackson=' + Jackson.length);
Oak_Ridge[Oak_Ridge.length] = createMarker(new GPoint(-89.73560333,37.52099991),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Oak Ridge Elementary School",'Oak_Ridge=' + Oak_Ridge.length);
Oak_Ridge[Oak_Ridge.length] = createMarker(new GPoint(-89.73560333,37.52099991),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Oak Ridge High School",'Oak_Ridge=' + Oak_Ridge.length);
Jackson[Jackson.length] = createMarker(new GPoint(-89.68607330,37.38828278),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Orchard Drive Elementary School",'Jackson=' + Jackson.length);
Cape_Girardeau[Cape_Girardeau.length] = createMarker(new GPoint(-89.53544617,37.29026031),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Parkview",'Cape_Girardeau=' + Cape_Girardeau.length);
Cape_Girardeau[Cape_Girardeau.length] = createMarker(new GPoint(-89.64366150,37.26213837),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Parkview State School",'Cape_Girardeau=' + Cape_Girardeau.length);
Jackson[Jackson.length] = createMarker(new GPoint(-89.67221832,37.38100433),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Primary Annex",'Jackson=' + Jackson.length);
Jackson[Jackson.length] = createMarker(new GPoint(-89.69243622,37.38550568),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Russell Hawkins Jr. High School",'Jackson=' + Jackson.length);
Jackson[Jackson.length] = createMarker(new GPoint(-89.66091919,37.36666107),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South Elementary School",'Jackson=' + Jackson.length);
Jackson[Jackson.length] = createMarker(new GPoint(-89.69211578,37.38771057),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("West Lane Elementary School",'Jackson=' + Jackson.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(Cape_Girardeau);
map.removeOverlays(Delta);
map.removeOverlays(Jackson);
map.removeOverlays(Millersville);
map.removeOverlays(Oak_Ridge);
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(Cape_Girardeau);map.removeOverlays(Cape_Girardeau);
map.removeOverlays(Delta);
map.removeOverlays(Jackson);
map.removeOverlays(Millersville);
map.removeOverlays(Oak_Ridge);
map.addOverlays(Cape_Girardeau);
centerByArray(Cape_Girardeau, false, false);
cntMarker += Cape_Girardeau.length;
map.addOverlays(Delta);
centerByArray(Delta, false, false);
cntMarker += Delta.length;
map.addOverlays(Jackson);
centerByArray(Jackson, false, false);
cntMarker += Jackson.length;
map.addOverlays(Millersville);
centerByArray(Millersville, false, false);
cntMarker += Millersville.length;
map.addOverlays(Oak_Ridge);
centerByArray(Oak_Ridge, false, false);
cntMarker += Oak_Ridge.length;
centerByArray(Cape_Girardeau,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');
}
}