function addMarkers()
{
mySelect = document.getElementById('selection');
Alexander = [];Jacksonville = [];Franklin = [];Meredosia = [];Murrayville = [];Concord = [];Waverly = [];mySelect.options[mySelect.options.length] = new Option("Alexander schools",'all=Alexander');
mySelect.options[mySelect.options.length] = new Option("Concord schools",'all=Concord');
mySelect.options[mySelect.options.length] = new Option("Franklin schools",'all=Franklin');
mySelect.options[mySelect.options.length] = new Option("Jacksonville schools",'all=Jacksonville');
mySelect.options[mySelect.options.length] = new Option("Meredosia schools",'all=Meredosia');
mySelect.options[mySelect.options.length] = new Option("Murrayville schools",'all=Murrayville');
mySelect.options[mySelect.options.length] = new Option("Waverly schools",'all=Waverly');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Alexander[Alexander.length] = createMarker(new GPoint(-90.04029846,39.73289871),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Alexander Elementary School",'Alexander=' + Alexander.length);
Jacksonville[Jacksonville.length] = createMarker(new GPoint(-90.23114900,39.74520000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Arc",'Jacksonville=' + Jacksonville.length);
Jacksonville[Jacksonville.length] = createMarker(new GPoint(-90.23989105,39.73776245),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Arc Middle School",'Jacksonville=' + Jacksonville.length);
Jacksonville[Jacksonville.length] = createMarker(new GPoint(-90.22455597,39.74627686),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clay Court Elementary School",'Jacksonville=' + Jacksonville.length);
Jacksonville[Jacksonville.length] = createMarker(new GPoint(-90.23989105,39.73776245),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Educational Support Program High School",'Jacksonville=' + Jacksonville.length);
Jacksonville[Jacksonville.length] = createMarker(new GPoint(-90.21968079,39.74681854),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Eisenhower Elementary School",'Jacksonville=' + Jacksonville.length);
Franklin[Franklin.length] = createMarker(new GPoint(-90.07250214,39.61320114),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Franklin East Grade School",'Franklin=' + Franklin.length);
Jacksonville[Jacksonville.length] = createMarker(new GPoint(-90.22560120,39.72773743),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Franklin Elementary School",'Jacksonville=' + Jacksonville.length);
Franklin[Franklin.length] = createMarker(new GPoint(-90.07250214,39.61320114),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Franklin Jr/sr High School",'Franklin=' + Franklin.length);
Jacksonville[Jacksonville.length] = createMarker(new GPoint(-90.21735382,39.73433685),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Il Sch For Visually Impaired",'Jacksonville=' + Jacksonville.length);
Jacksonville[Jacksonville.length] = createMarker(new GPoint(-90.25080109,39.73366165),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Illinois School For Deaf",'Jacksonville=' + Jacksonville.length);
Jacksonville[Jacksonville.length] = createMarker(new GPoint(-90.24414062,39.71613693),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ivan K Garrison Center",'Jacksonville=' + Jacksonville.length);
Jacksonville[Jacksonville.length] = createMarker(new GPoint(-90.17186737,39.72333527),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jacksonville Correctional Center",'Jacksonville=' + Jacksonville.length);
Jacksonville[Jacksonville.length] = createMarker(new GPoint(-90.23877716,39.74843216),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jacksonville High School",'Jacksonville=' + Jacksonville.length);
Jacksonville[Jacksonville.length] = createMarker(new GPoint(-90.22438049,39.74041367),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jefferson School",'Jacksonville=' + Jacksonville.length);
Jacksonville[Jacksonville.length] = createMarker(new GPoint(-90.24792480,39.72725296),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Jonathan Turner Junior High School",'Jacksonville=' + Jacksonville.length);
Jacksonville[Jacksonville.length] = createMarker(new GPoint(-90.23180389,39.74173737),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Jacksonville=' + Jacksonville.length);
Meredosia[Meredosia.length] = createMarker(new GPoint(-90.55940247,39.79650116),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Meredosia-chambersburg Elementary School",'Meredosia=' + Meredosia.length);
Meredosia[Meredosia.length] = createMarker(new GPoint(-90.55940247,39.79650116),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Meredosia-chambersburg High School",'Meredosia=' + Meredosia.length);
Meredosia[Meredosia.length] = createMarker(new GPoint(-90.55940247,39.79650116),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Meredosia-chambersburg Junior High School",'Meredosia=' + Meredosia.length);
Murrayville[Murrayville.length] = createMarker(new GPoint(-90.22940063,39.57229996),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Murrayville-woodson Elementary School",'Murrayville=' + Murrayville.length);
Jacksonville[Jacksonville.length] = createMarker(new GPoint(-90.22891998,39.76475143),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("North Jacksonville School",'Jacksonville=' + Jacksonville.length);
Jacksonville[Jacksonville.length] = createMarker(new GPoint(-90.23188782,39.71008682),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South Jacksonville Elementary School",'Jacksonville=' + Jacksonville.length);
Concord[Concord.length] = createMarker(new GPoint(-90.37274170,39.81647110),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Triopia Grade School",'Concord=' + Concord.length);
Concord[Concord.length] = createMarker(new GPoint(-90.37274170,39.81647110),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Triopia Junior Senior High School",'Concord=' + Concord.length);
Jacksonville[Jacksonville.length] = createMarker(new GPoint(-90.22628021,39.74542618),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Walnut Court Early Years Program Elementary School",'Jacksonville=' + Jacksonville.length);
Jacksonville[Jacksonville.length] = createMarker(new GPoint(-90.23612213,39.73019028),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Washington Elementary School",'Jacksonville=' + Jacksonville.length);
Waverly[Waverly.length] = createMarker(new GPoint(-89.94470215,39.57949829),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Waverly Elementary School",'Waverly=' + Waverly.length);
Waverly[Waverly.length] = createMarker(new GPoint(-89.95987701,39.59284592),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Waverly High School",'Waverly=' + Waverly.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(Alexander);
map.removeOverlays(Concord);
map.removeOverlays(Franklin);
map.removeOverlays(Jacksonville);
map.removeOverlays(Meredosia);
map.removeOverlays(Murrayville);
map.removeOverlays(Waverly);
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(Alexander);map.removeOverlays(Alexander);
map.removeOverlays(Concord);
map.removeOverlays(Franklin);
map.removeOverlays(Jacksonville);
map.removeOverlays(Meredosia);
map.removeOverlays(Murrayville);
map.removeOverlays(Waverly);
map.addOverlays(Alexander);
centerByArray(Alexander, false, false);
cntMarker += Alexander.length;
map.addOverlays(Concord);
centerByArray(Concord, false, false);
cntMarker += Concord.length;
map.addOverlays(Franklin);
centerByArray(Franklin, false, false);
cntMarker += Franklin.length;
map.addOverlays(Jacksonville);
centerByArray(Jacksonville, false, false);
cntMarker += Jacksonville.length;
map.addOverlays(Meredosia);
centerByArray(Meredosia, false, false);
cntMarker += Meredosia.length;
map.addOverlays(Murrayville);
centerByArray(Murrayville, false, false);
cntMarker += Murrayville.length;
map.addOverlays(Waverly);
centerByArray(Waverly, false, false);
cntMarker += Waverly.length;
centerByArray(Alexander,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');
}
}