function addMarkers(){
mySelect = document.getElementById('selection');
Chicago = [];Altamont = [];Carbondale = [];Dekalb = [];Alton = [];East_Saint_Louis = [];Lake_Villa = [];Niles = [];Assumption = [];Peoria = [];Robbins = [];Orland_Park = [];Jacksonville = [];Palatine = [];mySelect.options[mySelect.options.length] = new Option("Altamont schools",'all=Altamont');
mySelect.options[mySelect.options.length] = new Option("Alton schools",'all=Alton');
mySelect.options[mySelect.options.length] = new Option("Assumption schools",'all=Assumption');
mySelect.options[mySelect.options.length] = new Option("Carbondale schools",'all=Carbondale');
mySelect.options[mySelect.options.length] = new Option("Chicago schools",'all=Chicago');
mySelect.options[mySelect.options.length] = new Option("Dekalb schools",'all=Dekalb');
mySelect.options[mySelect.options.length] = new Option("East Saint Louis schools",'all=East_Saint_Louis');
mySelect.options[mySelect.options.length] = new Option("Jacksonville schools",'all=Jacksonville');
mySelect.options[mySelect.options.length] = new Option("Lake Villa schools",'all=Lake_Villa');
mySelect.options[mySelect.options.length] = new Option("Niles schools",'all=Niles');
mySelect.options[mySelect.options.length] = new Option("Orland Park schools",'all=Orland_Park');
mySelect.options[mySelect.options.length] = new Option("Palatine schools",'all=Palatine');
mySelect.options[mySelect.options.length] = new Option("Peoria schools",'all=Peoria');
mySelect.options[mySelect.options.length] = new Option("Robbins schools",'all=Robbins');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Chicago[Chicago.length] = createMarker(new GPoint(-87.61963300,41.68764100),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ada S Mckinley School South Care",'Chicago=' + Chicago.length);
Altamont[Altamont.length] = createMarker(new GPoint(-88.74552200,39.05961800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Altamont Lutheran Interparish School",'Altamont=' + Altamont.length);
Carbondale[Carbondale.length] = createMarker(new GPoint(-89.19336300,37.71759600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Brehm Preparatory School",'Carbondale=' + Carbondale.length);
Dekalb[Dekalb.length] = createMarker(new GPoint(-88.74725600,41.93123000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Camelot Schools-dekalb",'Dekalb=' + Dekalb.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.72668500,41.89553700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Carc/s.o.l. School",'Chicago=' + Chicago.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);
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);
Lake_Villa[Lake_Villa.length] = createMarker(new GPoint(-88.05700000,42.41170000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Comm Alternative Renewal Exper",'Lake_Villa=' + Lake_Villa.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.66858300,41.89136700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Esperanza School",'Chicago=' + Chicago.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.72000800,41.89034100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hartgrove Academy",'Chicago=' + Chicago.length);
Niles[Niles.length] = createMarker(new GPoint(-87.78782000,42.01764500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Joseph Academy",'Niles=' + Niles.length);
Assumption[Assumption.length] = createMarker(new GPoint(-89.04788400,39.52009500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kemmerer Village School",'Assumption=' + Assumption.length);
Peoria[Peoria.length] = createMarker(new GPoint(-89.59371800,40.71345700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kiefer School",'Peoria=' + Peoria.length);
Robbins[Robbins.length] = createMarker(new GPoint(-87.71000000,41.64320000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mary P Moody Christian Academy",'Robbins=' + Robbins.length);
Orland_Park[Orland_Park.length] = createMarker(new GPoint(-87.88119400,41.58454000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mary Sears Childrens Academy",'Orland_Park=' + Orland_Park.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.75446800,41.93883700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Center For Handicapped Children",'Chicago=' + Chicago.length);
Jacksonville[Jacksonville.length] = createMarker(new GPoint(-90.22880000,39.73380000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pathway School",'Jacksonville=' + Jacksonville.length);
Palatine[Palatine.length] = createMarker(new GPoint(-88.02269500,42.10447600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Campus",'Palatine=' + Palatine.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.56528300,41.75809300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Central Community Services",'Chicago=' + Chicago.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.59789700,41.74397200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Central Day Treatment",'Chicago=' + Chicago.length);
Niles[Niles.length] = createMarker(new GPoint(-87.80486000,42.01619600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Bernadette's School For Special Children",'Niles=' + Niles.length);
map.removeOverlays(Altamont);
map.removeOverlays(Alton);
map.removeOverlays(Assumption);
map.removeOverlays(Carbondale);
map.removeOverlays(Chicago);
map.removeOverlays(Dekalb);
map.removeOverlays(East_Saint_Louis);
map.removeOverlays(Jacksonville);
map.removeOverlays(Lake_Villa);
map.removeOverlays(Niles);
map.removeOverlays(Orland_Park);
map.removeOverlays(Palatine);
map.removeOverlays(Peoria);
map.removeOverlays(Robbins);
setTimeout(function(){map.addOverlays(Altamont)},1000);
setTimeout(function(){map.addOverlays(Alton)},1000);
setTimeout(function(){map.addOverlays(Assumption)},1000);
setTimeout(function(){map.addOverlays(Carbondale)},1000);
setTimeout(function(){map.addOverlays(Chicago)},1000);
setTimeout(function(){map.addOverlays(Dekalb)},1000);
setTimeout(function(){map.addOverlays(East_Saint_Louis)},1000);
setTimeout(function(){map.addOverlays(Jacksonville)},1000);
setTimeout(function(){map.addOverlays(Lake_Villa)},1000);
setTimeout(function(){map.addOverlays(Niles)},1000);
setTimeout(function(){map.addOverlays(Orland_Park)},1000);
setTimeout(function(){map.addOverlays(Palatine)},1000);
setTimeout(function(){map.addOverlays(Peoria)},1000);
setTimeout(function(){map.addOverlays(Robbins)},1000);
maxLng = -87.56528300;
maxLat = 42.41170000;
minLng = -90.22880000;
minLat = 37.71759600;
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(Altamont);
map.removeOverlays(Alton);
map.removeOverlays(Assumption);
map.removeOverlays(Carbondale);
map.removeOverlays(Chicago);
map.removeOverlays(Dekalb);
map.removeOverlays(East_Saint_Louis);
map.removeOverlays(Jacksonville);
map.removeOverlays(Lake_Villa);
map.removeOverlays(Niles);
map.removeOverlays(Orland_Park);
map.removeOverlays(Palatine);
map.removeOverlays(Peoria);
map.removeOverlays(Robbins);
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(Chicago);map.removeOverlays(Altamont);
map.removeOverlays(Alton);
map.removeOverlays(Assumption);
map.removeOverlays(Carbondale);
map.removeOverlays(Chicago);
map.removeOverlays(Dekalb);
map.removeOverlays(East_Saint_Louis);
map.removeOverlays(Jacksonville);
map.removeOverlays(Lake_Villa);
map.removeOverlays(Niles);
map.removeOverlays(Orland_Park);
map.removeOverlays(Palatine);
map.removeOverlays(Peoria);
map.removeOverlays(Robbins);
map.addOverlays(Altamont);
centerByArray(Altamont, false, false);
cntMarker += Altamont.length;
map.addOverlays(Alton);
centerByArray(Alton, false, false);
cntMarker += Alton.length;
map.addOverlays(Assumption);
centerByArray(Assumption, false, false);
cntMarker += Assumption.length;
map.addOverlays(Carbondale);
centerByArray(Carbondale, false, false);
cntMarker += Carbondale.length;
map.addOverlays(Chicago);
centerByArray(Chicago, false, false);
cntMarker += Chicago.length;
map.addOverlays(Dekalb);
centerByArray(Dekalb, false, false);
cntMarker += Dekalb.length;
map.addOverlays(East_Saint_Louis);
centerByArray(East_Saint_Louis, false, false);
cntMarker += East_Saint_Louis.length;
map.addOverlays(Jacksonville);
centerByArray(Jacksonville, false, false);
cntMarker += Jacksonville.length;
map.addOverlays(Lake_Villa);
centerByArray(Lake_Villa, false, false);
cntMarker += Lake_Villa.length;
map.addOverlays(Niles);
centerByArray(Niles, false, false);
cntMarker += Niles.length;
map.addOverlays(Orland_Park);
centerByArray(Orland_Park, false, false);
cntMarker += Orland_Park.length;
map.addOverlays(Palatine);
centerByArray(Palatine, false, false);
cntMarker += Palatine.length;
map.addOverlays(Peoria);
centerByArray(Peoria, false, false);
cntMarker += Peoria.length;
map.addOverlays(Robbins);
centerByArray(Robbins, false, false);
cntMarker += Robbins.length;
centerByArray(Chicago,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///8499,8812,8462,8383,8490,8627,8348,9026,9215,9693,8530,9104,8566,34882,35948,34904,8533,8394,8499,8627,8348,36202,9693,8530,9104,8566,34882,35948,8922,34904,8533,8918,/all');
//window.open('/map.php?type=2&schools=8499,8812,8462,8383,8490,8627,8348,9026,9215,9693,8530,9104,8566,34882,35948,34904,8533,8394,8499,8627,8348,36202,9693,8530,9104,8566,34882,35948,8922,34904,8533,8918,&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;
}