function addMarkers(){
mySelect = document.getElementById('selection');
Stockton = [];Saint_Louis = [];Mexico = [];Kansas_City = [];Kirkwood = [];Hannibal = [];Tarkio = [];Ava = [];mySelect.options[mySelect.options.length] = new Option("Ava schools",'all=Ava');
mySelect.options[mySelect.options.length] = new Option("Hannibal schools",'all=Hannibal');
mySelect.options[mySelect.options.length] = new Option("Kansas City schools",'all=Kansas_City');
mySelect.options[mySelect.options.length] = new Option("Kirkwood schools",'all=Kirkwood');
mySelect.options[mySelect.options.length] = new Option("Mexico schools",'all=Mexico');
mySelect.options[mySelect.options.length] = new Option("Saint Louis schools",'all=Saint_Louis');
mySelect.options[mySelect.options.length] = new Option("Stockton schools",'all=Stockton');
mySelect.options[mySelect.options.length] = new Option("Tarkio schools",'all=Tarkio');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Stockton[Stockton.length] = createMarker(new GPoint(-93.83749000,37.69506700),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Agape Boarding School",'Stockton=' + Stockton.length);
Saint_Louis[Saint_Louis.length] = createMarker(new GPoint(-90.39452300,38.68011300),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Block Yeshiva High School",'Saint_Louis=' + Saint_Louis.length);
Saint_Louis[Saint_Louis.length] = createMarker(new GPoint(-90.40562800,38.65073600),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Chaminade College Preparatory School",'Saint_Louis=' + Saint_Louis.length);
Saint_Louis[Saint_Louis.length] = createMarker(new GPoint(-90.44347500,38.65876400),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("De Smet Jesuit High School",'Saint_Louis=' + Saint_Louis.length);
Mexico[Mexico.length] = createMarker(new GPoint(-91.86911400,39.17205400),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Missouri Military Academy",'Mexico=' + Mexico.length);
Kansas_City[Kansas_City.length] = createMarker(new GPoint(-94.58953100,38.87876300),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("The Ozanam School",'Kansas_City=' + Kansas_City.length);
Kansas_City[Kansas_City.length] = createMarker(new GPoint(-94.60792400,38.96084000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Rockhurst High School",'Kansas_City=' + Kansas_City.length);
Kirkwood[Kirkwood.length] = createMarker(new GPoint(-90.40695900,38.56093500),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("St. John Vianney High School",'Kirkwood=' + Kirkwood.length);
Saint_Louis[Saint_Louis.length] = createMarker(new GPoint(-90.48144000,38.64411500),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Saint Louis Priory School",'Saint_Louis=' + Saint_Louis.length);
Hannibal[Hannibal.length] = createMarker(new GPoint(-91.39370000,39.70490000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("St. Thomas Aquinas Seminary",'Hannibal=' + Hannibal.length);
Tarkio[Tarkio.length] = createMarker(new GPoint(-95.39157900,40.44244000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Tarkso Academy",'Tarkio=' + Tarkio.length);
Ava[Ava.length] = createMarker(new GPoint(-92.68166300,36.93179700),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Teen Harvest",'Ava=' + Ava.length);
map.removeOverlays(Ava);
map.removeOverlays(Hannibal);
map.removeOverlays(Kansas_City);
map.removeOverlays(Kirkwood);
map.removeOverlays(Mexico);
map.removeOverlays(Saint_Louis);
map.removeOverlays(Stockton);
map.removeOverlays(Tarkio);
setTimeout(function(){map.addOverlays(Ava)},1000);
setTimeout(function(){map.addOverlays(Hannibal)},1000);
setTimeout(function(){map.addOverlays(Kansas_City)},1000);
setTimeout(function(){map.addOverlays(Kirkwood)},1000);
setTimeout(function(){map.addOverlays(Mexico)},1000);
setTimeout(function(){map.addOverlays(Saint_Louis)},1000);
setTimeout(function(){map.addOverlays(Stockton)},1000);
setTimeout(function(){map.addOverlays(Tarkio)},1000);
maxLng = -90.39452300;
maxLat = 40.44244000;
minLng = -95.39157900;
minLat = 36.93179700;
reCenterMap();
} // 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,11);
/*
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(Ava);
map.removeOverlays(Hannibal);
map.removeOverlays(Kansas_City);
map.removeOverlays(Kirkwood);
map.removeOverlays(Mexico);
map.removeOverlays(Saint_Louis);
map.removeOverlays(Stockton);
map.removeOverlays(Tarkio);
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(Stockton);map.removeOverlays(Ava);
map.removeOverlays(Hannibal);
map.removeOverlays(Kansas_City);
map.removeOverlays(Kirkwood);
map.removeOverlays(Mexico);
map.removeOverlays(Saint_Louis);
map.removeOverlays(Stockton);
map.removeOverlays(Tarkio);
map.addOverlays(Ava);
centerByArray(Ava, false, false);
cntMarker += Ava.length;
map.addOverlays(Hannibal);
centerByArray(Hannibal, false, false);
cntMarker += Hannibal.length;
map.addOverlays(Kansas_City);
centerByArray(Kansas_City, false, false);
cntMarker += Kansas_City.length;
map.addOverlays(Kirkwood);
centerByArray(Kirkwood, false, false);
cntMarker += Kirkwood.length;
map.addOverlays(Mexico);
centerByArray(Mexico, false, false);
cntMarker += Mexico.length;
map.addOverlays(Saint_Louis);
centerByArray(Saint_Louis, false, false);
cntMarker += Saint_Louis.length;
map.addOverlays(Stockton);
centerByArray(Stockton, false, false);
cntMarker += Stockton.length;
map.addOverlays(Tarkio);
centerByArray(Tarkio, false, false);
cntMarker += Tarkio.length;
centerByArray(Stockton,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///29163,16111,16139,15903,16017,15838,15638,15660,15703,16046,15613,16133,16139,15838,15660,15613,/all');
//window.open('/map.php?type=2&schools=29163,16111,16139,15903,16017,15838,15638,15660,15703,16046,15613,16133,16139,15838,15660,15613,&school_level=&radius=&zipcode=&school_type_search=&school_type_code=');
}
}
function createMarker(point, label, icon)
{
var marker = new GMarker(point, icon);
var html = label;
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}