function addMarkers(){
mySelect = document.getElementById('selection');
Dupo = [];Fairview_Heights = [];Belleville = [];East_Saint_Louis = [];Fairview_Hgts = [];Caseyville = [];Cahokia = [];Ofallon = [];East_St_Louis = [];Mascoutah = [];Fairmont_City = [];Smithton = [];Freeburg = [];New_Athens = [];Millstadt = [];mySelect.options[mySelect.options.length] = new Option("Belleville schools",'all=Belleville');
mySelect.options[mySelect.options.length] = new Option("Cahokia schools",'all=Cahokia');
mySelect.options[mySelect.options.length] = new Option("Caseyville schools",'all=Caseyville');
mySelect.options[mySelect.options.length] = new Option("Dupo schools",'all=Dupo');
mySelect.options[mySelect.options.length] = new Option("East Saint Louis schools",'all=East_Saint_Louis');
mySelect.options[mySelect.options.length] = new Option("East St Louis schools",'all=East_St_Louis');
mySelect.options[mySelect.options.length] = new Option("Fairmont City schools",'all=Fairmont_City');
mySelect.options[mySelect.options.length] = new Option("Fairview Heights schools",'all=Fairview_Heights');
mySelect.options[mySelect.options.length] = new Option("Fairview Hgts schools",'all=Fairview_Hgts');
mySelect.options[mySelect.options.length] = new Option("Freeburg schools",'all=Freeburg');
mySelect.options[mySelect.options.length] = new Option("Mascoutah schools",'all=Mascoutah');
mySelect.options[mySelect.options.length] = new Option("Millstadt schools",'all=Millstadt');
mySelect.options[mySelect.options.length] = new Option("New Athens schools",'all=New_Athens');
mySelect.options[mySelect.options.length] = new Option("Ofallon schools",'all=Ofallon');
mySelect.options[mySelect.options.length] = new Option("Smithton schools",'all=Smithton');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Dupo[Dupo.length] = createMarker(new GPoint(-90.20917300,38.51574300),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Apostolic Learning Academy",'Dupo=' + Dupo.length);
Fairview_Heights[Fairview_Heights.length] = createMarker(new GPoint(-89.98469400,38.57735900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Berean Christian School",'Fairview_Heights=' + Fairview_Heights.length);
Belleville[Belleville.length] = createMarker(new GPoint(-90.05363000,38.57210800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Blessed Sacrament Elementary School",'Belleville=' + Belleville.length);
Belleville[Belleville.length] = createMarker(new GPoint(-89.96919100,38.52313500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calvary Baptist Academy",'Belleville=' + Belleville.length);
Belleville[Belleville.length] = createMarker(new GPoint(-89.98672400,38.51156200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cathedral Grade School",'Belleville=' + Belleville.length);
East_Saint_Louis[East_Saint_Louis.length] = createMarker(new GPoint(-90.14993900,38.63021400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Catholic Daycare Center",'East_Saint_Louis=' + East_Saint_Louis.length);
East_Saint_Louis[East_Saint_Louis.length] = createMarker(new GPoint(-90.06873500,38.58438800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Childrens Center For Behavioral Development",'East_Saint_Louis=' + East_Saint_Louis.length);
Fairview_Hgts[Fairview_Hgts.length] = createMarker(new GPoint(-90.02008200,38.60939000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cornerstone Christian School",'Fairview_Hgts=' + Fairview_Hgts.length);
Caseyville[Caseyville.length] = createMarker(new GPoint(-90.02737500,38.63956400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cornerstone Christian School",'Caseyville=' + Caseyville.length);
Cahokia[Cahokia.length] = createMarker(new GPoint(-90.18834500,38.57051300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Corpus Christi Elementary School",'Cahokia=' + Cahokia.length);
East_Saint_Louis[East_Saint_Louis.length] = createMarker(new GPoint(-90.16314400,38.62622000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Crossroads Preparatory Academy",'East_Saint_Louis=' + East_Saint_Louis.length);
Ofallon[Ofallon.length] = createMarker(new GPoint(-89.92643200,38.59950100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Discovery School",'Ofallon=' + Ofallon.length);
Fairview_Hgts[Fairview_Hgts.length] = createMarker(new GPoint(-90.01611100,38.60410300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Elizabeth Ann Seton Catholic",'Fairview_Hgts=' + Fairview_Hgts.length);
Belleville[Belleville.length] = createMarker(new GPoint(-89.97880600,38.51373700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Baptist School",'Belleville=' + Belleville.length);
Ofallon[Ofallon.length] = createMarker(new GPoint(-89.89265100,38.58106900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("First Baptist Academy",'Ofallon=' + Ofallon.length);
Belleville[Belleville.length] = createMarker(new GPoint(-89.98088700,38.50260000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Governor French Academy",'Belleville=' + Belleville.length);
East_St_Louis[East_St_Louis.length] = createMarker(new GPoint(-90.12397900,38.61430700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hazel Bland Promise Center",'East_St_Louis=' + East_St_Louis.length);
Mascoutah[Mascoutah.length] = createMarker(new GPoint(-89.79147400,38.49195000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Childhood School",'Mascoutah=' + Mascoutah.length);
Fairmont_City[Fairmont_City.length] = createMarker(new GPoint(-90.10537500,38.64600000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Rosary School",'Fairmont_City=' + Fairmont_City.length);
Fairview_Heights[Fairview_Heights.length] = createMarker(new GPoint(-89.98433000,38.59293700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Trinity Catholic School",'Fairview_Heights=' + Fairview_Heights.length);
Belleville[Belleville.length] = createMarker(new GPoint(-89.86018300,38.52634100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hope Christian School",'Belleville=' + Belleville.length);
Fairview_Hgts[Fairview_Hgts.length] = createMarker(new GPoint(-89.99435200,38.58220400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Illinois Center For Autism",'Fairview_Hgts=' + Fairview_Hgts.length);
Belleville[Belleville.length] = createMarker(new GPoint(-89.96689100,38.49978600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mamie O Stookey School",'Belleville=' + Belleville.length);
Belleville[Belleville.length] = createMarker(new GPoint(-89.94482700,38.54826500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School-st. Clair",'Belleville=' + Belleville.length);
Belleville[Belleville.length] = createMarker(new GPoint(-90.03810500,38.54190100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Queen Of Peace School",'Belleville=' + Belleville.length);
Smithton[Smithton.length] = createMarker(new GPoint(-89.99412400,38.40842000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. John The Baptist School",'Smithton=' + Smithton.length);
Freeburg[Freeburg.length] = createMarker(new GPoint(-89.90984000,38.42665500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Joseph School",'Freeburg=' + Freeburg.length);
Belleville[Belleville.length] = createMarker(new GPoint(-90.00677400,38.53986300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Mary - St. Augustine Catholic School",'Belleville=' + Belleville.length);
Belleville[Belleville.length] = createMarker(new GPoint(-89.97256600,38.52800900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Teresa Catholic School",'Belleville=' + Belleville.length);
East_Saint_Louis[East_Saint_Louis.length] = createMarker(new GPoint(-90.06226000,38.60033500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sister Thea Bowman Catholic School",'East_Saint_Louis=' + East_Saint_Louis.length);
New_Athens[New_Athens.length] = createMarker(new GPoint(-89.87590100,38.32347200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Agatha Elementary School",'New_Athens=' + New_Athens.length);
Ofallon[Ofallon.length] = createMarker(new GPoint(-89.91283600,38.59036200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Clare Catholic School",'Ofallon=' + Ofallon.length);
Millstadt[Millstadt.length] = createMarker(new GPoint(-90.09608900,38.46136300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St James School",'Millstadt=' + Millstadt.length);
East_Saint_Louis[East_Saint_Louis.length] = createMarker(new GPoint(-90.10614300,38.63054400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Unity Lutheran Christian Elementary School",'East_Saint_Louis=' + East_Saint_Louis.length);
East_St_Louis[East_St_Louis.length] = createMarker(new GPoint(-90.15400000,38.62230000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Vincent Gray Alternative H School",'East_St_Louis=' + East_St_Louis.length);
East_Saint_Louis[East_Saint_Louis.length] = createMarker(new GPoint(-90.06554200,38.58605800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("White Oak Academy",'East_Saint_Louis=' + East_Saint_Louis.length);
Belleville[Belleville.length] = createMarker(new GPoint(-89.95886500,38.51419700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Zion Lutheran School",'Belleville=' + Belleville.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(Belleville);
map.removeOverlays(Cahokia);
map.removeOverlays(Caseyville);
map.removeOverlays(Dupo);
map.removeOverlays(East_Saint_Louis);
map.removeOverlays(East_St_Louis);
map.removeOverlays(Fairmont_City);
map.removeOverlays(Fairview_Heights);
map.removeOverlays(Fairview_Hgts);
map.removeOverlays(Freeburg);
map.removeOverlays(Mascoutah);
map.removeOverlays(Millstadt);
map.removeOverlays(New_Athens);
map.removeOverlays(Ofallon);
map.removeOverlays(Smithton);
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(Dupo);map.removeOverlays(Belleville);
map.removeOverlays(Cahokia);
map.removeOverlays(Caseyville);
map.removeOverlays(Dupo);
map.removeOverlays(East_Saint_Louis);
map.removeOverlays(East_St_Louis);
map.removeOverlays(Fairmont_City);
map.removeOverlays(Fairview_Heights);
map.removeOverlays(Fairview_Hgts);
map.removeOverlays(Freeburg);
map.removeOverlays(Mascoutah);
map.removeOverlays(Millstadt);
map.removeOverlays(New_Athens);
map.removeOverlays(Ofallon);
map.removeOverlays(Smithton);
map.addOverlays(Belleville);
centerByArray(Belleville, false, false);
cntMarker += Belleville.length;
map.addOverlays(Cahokia);
centerByArray(Cahokia, false, false);
cntMarker += Cahokia.length;
map.addOverlays(Caseyville);
centerByArray(Caseyville, false, false);
cntMarker += Caseyville.length;
map.addOverlays(Dupo);
centerByArray(Dupo, false, false);
cntMarker += Dupo.length;
map.addOverlays(East_Saint_Louis);
centerByArray(East_Saint_Louis, false, false);
cntMarker += East_Saint_Louis.length;
map.addOverlays(East_St_Louis);
centerByArray(East_St_Louis, false, false);
cntMarker += East_St_Louis.length;
map.addOverlays(Fairmont_City);
centerByArray(Fairmont_City, false, false);
cntMarker += Fairmont_City.length;
map.addOverlays(Fairview_Heights);
centerByArray(Fairview_Heights, false, false);
cntMarker += Fairview_Heights.length;
map.addOverlays(Fairview_Hgts);
centerByArray(Fairview_Hgts, false, false);
cntMarker += Fairview_Hgts.length;
map.addOverlays(Freeburg);
centerByArray(Freeburg, false, false);
cntMarker += Freeburg.length;
map.addOverlays(Mascoutah);
centerByArray(Mascoutah, false, false);
cntMarker += Mascoutah.length;
map.addOverlays(Millstadt);
centerByArray(Millstadt, false, false);
cntMarker += Millstadt.length;
map.addOverlays(New_Athens);
centerByArray(New_Athens, false, false);
cntMarker += New_Athens.length;
map.addOverlays(Ofallon);
centerByArray(Ofallon, false, false);
cntMarker += Ofallon.length;
map.addOverlays(Smithton);
centerByArray(Smithton, false, false);
cntMarker += Smithton.length;
centerByArray(Dupo,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;
}