function addMarkers(){
mySelect = document.getElementById('selection');
Saint_Charles = [];Saint_Peters = [];OFallon = [];Foristell = [];Lake_Saint_Louis = [];Dardenne_Prairie = [];Wentzville = [];Weldon_Spring = [];Saint_Paul = [];mySelect.options[mySelect.options.length] = new Option("Dardenne Prairie schools",'all=Dardenne_Prairie');
mySelect.options[mySelect.options.length] = new Option("Foristell schools",'all=Foristell');
mySelect.options[mySelect.options.length] = new Option("Lake Saint Louis schools",'all=Lake_Saint_Louis');
mySelect.options[mySelect.options.length] = new Option("OFallon schools",'all=OFallon');
mySelect.options[mySelect.options.length] = new Option("Saint Charles schools",'all=Saint_Charles');
mySelect.options[mySelect.options.length] = new Option("Saint Paul schools",'all=Saint_Paul');
mySelect.options[mySelect.options.length] = new Option("Saint Peters schools",'all=Saint_Peters');
mySelect.options[mySelect.options.length] = new Option("Weldon Spring schools",'all=Weldon_Spring');
mySelect.options[mySelect.options.length] = new Option("Wentzville schools",'all=Wentzville');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Saint_Charles[Saint_Charles.length] = createMarker(new GPoint(-90.48023800,38.78632100),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Academy Of The Sacred Heart",'Saint_Charles=' + Saint_Charles.length);
Saint_Peters[Saint_Peters.length] = createMarker(new GPoint(-90.62902100,38.79663400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("All Saints School",'Saint_Peters=' + Saint_Peters.length);
OFallon[OFallon.length] = createMarker(new GPoint(-90.70180400,38.81303700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Assumption School",'OFallon=' + OFallon.length);
Saint_Charles[Saint_Charles.length] = createMarker(new GPoint(-90.57059900,38.80333000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Campbell Montessori School",'Saint_Charles=' + Saint_Charles.length);
Saint_Peters[Saint_Peters.length] = createMarker(new GPoint(-90.62182400,38.77274900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Childrens Edu Care Center",'Saint_Peters=' + Saint_Peters.length);
Saint_Peters[Saint_Peters.length] = createMarker(new GPoint(-90.62230000,38.77880000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Church On The Rock Christian",'Saint_Peters=' + Saint_Peters.length);
OFallon[OFallon.length] = createMarker(new GPoint(-90.71721100,38.81356500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("First Baptist Christian",'OFallon=' + OFallon.length);
Foristell[Foristell.length] = createMarker(new GPoint(-90.94880000,38.81930000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Foristell Baptist Academy",'Foristell=' + Foristell.length);
Lake_Saint_Louis[Lake_Saint_Louis.length] = createMarker(new GPoint(-90.76072600,38.80138300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hope Montessori Academy",'Lake_Saint_Louis=' + Lake_Saint_Louis.length);
Dardenne_Prairie[Dardenne_Prairie.length] = createMarker(new GPoint(-90.75637500,38.76665100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Immaculate Conception School",'Dardenne_Prairie=' + Dardenne_Prairie.length);
Saint_Charles[Saint_Charles.length] = createMarker(new GPoint(-90.48866500,38.78331900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Immanuel Lutheran School",'Saint_Charles=' + Saint_Charles.length);
Wentzville[Wentzville.length] = createMarker(new GPoint(-90.85680300,38.81111500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Immanuel Lutheran School",'Wentzville=' + Wentzville.length);
OFallon[OFallon.length] = createMarker(new GPoint(-90.75391100,38.76586300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kid's Academy",'OFallon=' + OFallon.length);
Saint_Charles[Saint_Charles.length] = createMarker(new GPoint(-90.51395500,38.81900400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Little Guppy Child Dev Center",'Saint_Charles=' + Saint_Charles.length);
Saint_Charles[Saint_Charles.length] = createMarker(new GPoint(-90.59767300,38.74675800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Living Word Christian School - Harvester Elementary Campus",'Saint_Charles=' + Saint_Charles.length);
Saint_Peters[Saint_Peters.length] = createMarker(new GPoint(-90.62633800,38.79682500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Living Word Christian School - Mid Rivers Elementary Campus",'Saint_Peters=' + Saint_Peters.length);
OFallon[OFallon.length] = createMarker(new GPoint(-90.71721100,38.81356500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Living Word Christian Schools",'OFallon=' + OFallon.length);
Weldon_Spring[Weldon_Spring.length] = createMarker(new GPoint(-90.67421000,38.71662900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Messiah Lutheran School",'Weldon_Spring=' + Weldon_Spring.length);
Saint_Peters[Saint_Peters.length] = createMarker(new GPoint(-90.66021100,38.79096500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mid Rivers Sda School",'Saint_Peters=' + Saint_Peters.length);
Saint_Charles[Saint_Charles.length] = createMarker(new GPoint(-90.48250600,38.78782400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Charles Borromeo School",'Saint_Charles=' + Saint_Charles.length);
Saint_Charles[Saint_Charles.length] = createMarker(new GPoint(-90.53551400,38.80128100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Cletus School",'Saint_Charles=' + Saint_Charles.length);
Saint_Charles[Saint_Charles.length] = createMarker(new GPoint(-90.54194700,38.77693700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Elizabeth St. Robert Regional School",'Saint_Charles=' + Saint_Charles.length);
Saint_Charles[Saint_Charles.length] = createMarker(new GPoint(-90.65248500,38.74332500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Joseph School",'Saint_Charles=' + Saint_Charles.length);
Saint_Paul[Saint_Paul.length] = createMarker(new GPoint(-90.71630000,38.81480000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Paul Elementary School",'Saint_Paul=' + Saint_Paul.length);
Wentzville[Wentzville.length] = createMarker(new GPoint(-90.79678900,38.84374700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Joseph School-josephville",'Wentzville=' + Wentzville.length);
Wentzville[Wentzville.length] = createMarker(new GPoint(-90.85426400,38.80754400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Patrick Elementary School",'Wentzville=' + Wentzville.length);
Saint_Charles[Saint_Charles.length] = createMarker(new GPoint(-90.48417900,38.77932400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Peter Catholic School",'Saint_Charles=' + Saint_Charles.length);
Wentzville[Wentzville.length] = createMarker(new GPoint(-90.86353600,38.85476300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Theodore School",'Wentzville=' + Wentzville.length);
Saint_Charles[Saint_Charles.length] = createMarker(new GPoint(-90.59858900,38.75626900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sts Joachim & Ann School",'Saint_Charles=' + Saint_Charles.length);
Saint_Charles[Saint_Charles.length] = createMarker(new GPoint(-90.44912200,38.86471600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Lutheran School",'Saint_Charles=' + Saint_Charles.length);
OFallon[OFallon.length] = createMarker(new GPoint(-90.70002300,38.76222000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tutor Time",'OFallon=' + OFallon.length);
Saint_Peters[Saint_Peters.length] = createMarker(new GPoint(-90.66489700,38.80261100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Westgate Christian Academy",'Saint_Peters=' + Saint_Peters.length);
Saint_Peters[Saint_Peters.length] = createMarker(new GPoint(-90.59472300,38.77588600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Willott Road Christian Academy",'Saint_Peters=' + Saint_Peters.length);
Saint_Charles[Saint_Charles.length] = createMarker(new GPoint(-90.58449400,38.74303900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Zion Lutheran School",'Saint_Charles=' + Saint_Charles.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,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/////1/' + showArray);
map.removeOverlays(Dardenne_Prairie);
map.removeOverlays(Foristell);
map.removeOverlays(Lake_Saint_Louis);
map.removeOverlays(OFallon);
map.removeOverlays(Saint_Charles);
map.removeOverlays(Saint_Paul);
map.removeOverlays(Saint_Peters);
map.removeOverlays(Weldon_Spring);
map.removeOverlays(Wentzville);
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(Saint_Charles);map.removeOverlays(Dardenne_Prairie);
map.removeOverlays(Foristell);
map.removeOverlays(Lake_Saint_Louis);
map.removeOverlays(OFallon);
map.removeOverlays(Saint_Charles);
map.removeOverlays(Saint_Paul);
map.removeOverlays(Saint_Peters);
map.removeOverlays(Weldon_Spring);
map.removeOverlays(Wentzville);
map.addOverlays(Dardenne_Prairie);
centerByArray(Dardenne_Prairie, false, false);
cntMarker += Dardenne_Prairie.length;
map.addOverlays(Foristell);
centerByArray(Foristell, false, false);
cntMarker += Foristell.length;
map.addOverlays(Lake_Saint_Louis);
centerByArray(Lake_Saint_Louis, false, false);
cntMarker += Lake_Saint_Louis.length;
map.addOverlays(OFallon);
centerByArray(OFallon, false, false);
cntMarker += OFallon.length;
map.addOverlays(Saint_Charles);
centerByArray(Saint_Charles, false, false);
cntMarker += Saint_Charles.length;
map.addOverlays(Saint_Paul);
centerByArray(Saint_Paul, false, false);
cntMarker += Saint_Paul.length;
map.addOverlays(Saint_Peters);
centerByArray(Saint_Peters, false, false);
cntMarker += Saint_Peters.length;
map.addOverlays(Weldon_Spring);
centerByArray(Weldon_Spring, false, false);
cntMarker += Weldon_Spring.length;
map.addOverlays(Wentzville);
centerByArray(Wentzville, false, false);
cntMarker += Wentzville.length;
centerByArray(Saint_Charles,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');
//window.open('/map.php?type=1&schools=&school_level=1&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;
}