function addMarkers(){
mySelect = document.getElementById('selection');
South_Roxana = [];Alton = [];Granite_City = [];Collinsville = [];Godfrey = [];Glen_Carbon = [];Bethalto = [];Wood_River = [];Maryville = [];Edwardsville = [];Highland = [];Troy = [];Dorsey = [];East_Alton = [];Worden = [];mySelect.options[mySelect.options.length] = new Option("Alton schools",'all=Alton');
mySelect.options[mySelect.options.length] = new Option("Bethalto schools",'all=Bethalto');
mySelect.options[mySelect.options.length] = new Option("Collinsville schools",'all=Collinsville');
mySelect.options[mySelect.options.length] = new Option("Dorsey schools",'all=Dorsey');
mySelect.options[mySelect.options.length] = new Option("East Alton schools",'all=East_Alton');
mySelect.options[mySelect.options.length] = new Option("Edwardsville schools",'all=Edwardsville');
mySelect.options[mySelect.options.length] = new Option("Glen Carbon schools",'all=Glen_Carbon');
mySelect.options[mySelect.options.length] = new Option("Godfrey schools",'all=Godfrey');
mySelect.options[mySelect.options.length] = new Option("Granite City schools",'all=Granite_City');
mySelect.options[mySelect.options.length] = new Option("Highland schools",'all=Highland');
mySelect.options[mySelect.options.length] = new Option("Maryville schools",'all=Maryville');
mySelect.options[mySelect.options.length] = new Option("South Roxana schools",'all=South_Roxana');
mySelect.options[mySelect.options.length] = new Option("Troy schools",'all=Troy');
mySelect.options[mySelect.options.length] = new Option("Wood River schools",'all=Wood_River');
mySelect.options[mySelect.options.length] = new Option("Worden schools",'all=Worden');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
South_Roxana[South_Roxana.length] = createMarker(new GPoint(-90.05870000,38.82810000),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethel Christian Academy",'South_Roxana=' + South_Roxana.length);
Alton[Alton.length] = createMarker(new GPoint(-90.19393000,38.90427300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Catholic Childrens Home",'Alton=' + Alton.length);
Granite_City[Granite_City.length] = createMarker(new GPoint(-90.07070300,38.72975400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central Baptist School",'Granite_City=' + Granite_City.length);
Collinsville[Collinsville.length] = createMarker(new GPoint(-89.97793600,38.68248700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Collinsville Christian Academy",'Collinsville=' + Collinsville.length);
Granite_City[Granite_City.length] = createMarker(new GPoint(-90.14603100,38.69978200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Coordinated Youth & Human Services",'Granite_City=' + Granite_City.length);
Godfrey[Godfrey.length] = createMarker(new GPoint(-90.21476100,38.94824800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Evangelical School",'Godfrey=' + Godfrey.length);
Glen_Carbon[Glen_Carbon.length] = createMarker(new GPoint(-89.97077400,38.76467700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Baptist Academy",'Glen_Carbon=' + Glen_Carbon.length);
Godfrey[Godfrey.length] = createMarker(new GPoint(-90.19341200,38.96906800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Lutheran School",'Godfrey=' + Godfrey.length);
Collinsville[Collinsville.length] = createMarker(new GPoint(-89.99198000,38.69125200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Good Shepherd Lutheran School",'Collinsville=' + Collinsville.length);
Collinsville[Collinsville.length] = createMarker(new GPoint(-89.98827500,38.66561500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Cross Lutheran School",'Collinsville=' + Collinsville.length);
Granite_City[Granite_City.length] = createMarker(new GPoint(-90.11732300,38.71686300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Family",'Granite_City=' + Granite_City.length);
South_Roxana[South_Roxana.length] = createMarker(new GPoint(-90.05970000,38.82620000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hope Christian Academy",'South_Roxana=' + South_Roxana.length);
Glen_Carbon[Glen_Carbon.length] = createMarker(new GPoint(-89.97099600,38.76185300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lahr-well Academy",'Glen_Carbon=' + Glen_Carbon.length);
Alton[Alton.length] = createMarker(new GPoint(-90.14527700,38.90721700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mississippi Valley Christian School",'Alton=' + Alton.length);
Godfrey[Godfrey.length] = createMarker(new GPoint(-90.19097500,38.95113900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Children's House",'Godfrey=' + Godfrey.length);
Granite_City[Granite_City.length] = createMarker(new GPoint(-90.06122800,38.72554100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School",'Granite_City=' + Granite_City.length);
Bethalto[Bethalto.length] = createMarker(new GPoint(-90.04081800,38.91290100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Queen-peace School",'Bethalto=' + Bethalto.length);
Granite_City[Granite_City.length] = createMarker(new GPoint(-90.12175000,38.76197400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rivers of Life Christian School",'Granite_City=' + Granite_City.length);
Wood_River[Wood_River.length] = createMarker(new GPoint(-90.08997500,38.86294000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Bernard School",'Wood_River=' + Wood_River.length);
Maryville[Maryville.length] = createMarker(new GPoint(-89.95904900,38.71047200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. John Neumann Catholic School",'Maryville=' + Maryville.length);
Edwardsville[Edwardsville.length] = createMarker(new GPoint(-89.94742200,38.79284600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Mary Elementary School",'Edwardsville=' + Edwardsville.length);
Alton[Alton.length] = createMarker(new GPoint(-90.17824800,38.89060000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Mary School",'Alton=' + Alton.length);
Highland[Highland.length] = createMarker(new GPoint(-89.67357000,38.74036300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Paul Catholic School",'Highland=' + Highland.length);
Troy[Troy.length] = createMarker(new GPoint(-89.88518000,38.73045700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Paul Lutheran School",'Troy=' + Troy.length);
Dorsey[Dorsey.length] = createMarker(new GPoint(-89.92588300,38.96626200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Peters Lutheran School",'Dorsey=' + Dorsey.length);
Alton[Alton.length] = createMarker(new GPoint(-90.19049300,38.89559700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ss Peter & Paul Elementary School",'Alton=' + Alton.length);
Collinsville[Collinsville.length] = createMarker(new GPoint(-89.98529900,38.67168700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ss Peter & Paul School",'Collinsville=' + Collinsville.length);
Godfrey[Godfrey.length] = createMarker(new GPoint(-90.19470000,38.92488500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Ambrose School",'Godfrey=' + Godfrey.length);
Edwardsville[Edwardsville.length] = createMarker(new GPoint(-89.95308200,38.81245200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Boniface Catholic School",'Edwardsville=' + Edwardsville.length);
Granite_City[Granite_City.length] = createMarker(new GPoint(-90.10802300,38.73146300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Elizabeth Elementary School",'Granite_City=' + Granite_City.length);
East_Alton[East_Alton.length] = createMarker(new GPoint(-90.09793300,38.87778800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Toddle Towne Learning Center",'East_Alton=' + East_Alton.length);
Alton[Alton.length] = createMarker(new GPoint(-90.15172700,38.93000100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Toddle Towne Learning Center",'Alton=' + Alton.length);
Edwardsville[Edwardsville.length] = createMarker(new GPoint(-89.95284900,38.81676300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Lutheran School",'Edwardsville=' + Edwardsville.length);
Worden[Worden.length] = createMarker(new GPoint(-89.82488800,38.90787700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity St Paul Lutheran School",'Worden=' + Worden.length);
Alton[Alton.length] = createMarker(new GPoint(-90.09859000,38.86543000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Westminster Christian Academy-river Bend",'Alton=' + Alton.length);
Wood_River[Wood_River.length] = createMarker(new GPoint(-90.10303400,38.85593700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wm Bedell Achiev/resource Center",'Wood_River=' + Wood_River.length);
Bethalto[Bethalto.length] = createMarker(new GPoint(-90.03188000,38.90011700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Zion Lutheran School",'Bethalto=' + Bethalto.length);
Bethalto[Bethalto.length] = createMarker(new GPoint(-90.03184100,38.90014700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Zion Lutheran School And Preschool",'Bethalto=' + Bethalto.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(Alton);
map.removeOverlays(Bethalto);
map.removeOverlays(Collinsville);
map.removeOverlays(Dorsey);
map.removeOverlays(East_Alton);
map.removeOverlays(Edwardsville);
map.removeOverlays(Glen_Carbon);
map.removeOverlays(Godfrey);
map.removeOverlays(Granite_City);
map.removeOverlays(Highland);
map.removeOverlays(Maryville);
map.removeOverlays(South_Roxana);
map.removeOverlays(Troy);
map.removeOverlays(Wood_River);
map.removeOverlays(Worden);
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(South_Roxana);map.removeOverlays(Alton);
map.removeOverlays(Bethalto);
map.removeOverlays(Collinsville);
map.removeOverlays(Dorsey);
map.removeOverlays(East_Alton);
map.removeOverlays(Edwardsville);
map.removeOverlays(Glen_Carbon);
map.removeOverlays(Godfrey);
map.removeOverlays(Granite_City);
map.removeOverlays(Highland);
map.removeOverlays(Maryville);
map.removeOverlays(South_Roxana);
map.removeOverlays(Troy);
map.removeOverlays(Wood_River);
map.removeOverlays(Worden);
map.addOverlays(Alton);
centerByArray(Alton, false, false);
cntMarker += Alton.length;
map.addOverlays(Bethalto);
centerByArray(Bethalto, false, false);
cntMarker += Bethalto.length;
map.addOverlays(Collinsville);
centerByArray(Collinsville, false, false);
cntMarker += Collinsville.length;
map.addOverlays(Dorsey);
centerByArray(Dorsey, false, false);
cntMarker += Dorsey.length;
map.addOverlays(East_Alton);
centerByArray(East_Alton, false, false);
cntMarker += East_Alton.length;
map.addOverlays(Edwardsville);
centerByArray(Edwardsville, false, false);
cntMarker += Edwardsville.length;
map.addOverlays(Glen_Carbon);
centerByArray(Glen_Carbon, false, false);
cntMarker += Glen_Carbon.length;
map.addOverlays(Godfrey);
centerByArray(Godfrey, false, false);
cntMarker += Godfrey.length;
map.addOverlays(Granite_City);
centerByArray(Granite_City, false, false);
cntMarker += Granite_City.length;
map.addOverlays(Highland);
centerByArray(Highland, false, false);
cntMarker += Highland.length;
map.addOverlays(Maryville);
centerByArray(Maryville, false, false);
cntMarker += Maryville.length;
map.addOverlays(South_Roxana);
centerByArray(South_Roxana, false, false);
cntMarker += South_Roxana.length;
map.addOverlays(Troy);
centerByArray(Troy, false, false);
cntMarker += Troy.length;
map.addOverlays(Wood_River);
centerByArray(Wood_River, false, false);
cntMarker += Wood_River.length;
map.addOverlays(Worden);
centerByArray(Worden, false, false);
cntMarker += Worden.length;
centerByArray(South_Roxana,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;
}