function addMarkers(){
mySelect = document.getElementById('selection');
Chicago = [];Lake_Villa = [];Blue_Island = [];Fairview_Hgts = [];Peoria = [];Joliet = [];Loves_Park = [];Wood_River = [];mySelect.options[mySelect.options.length] = new Option("Blue Island schools",'all=Blue_Island');
mySelect.options[mySelect.options.length] = new Option("Chicago schools",'all=Chicago');
mySelect.options[mySelect.options.length] = new Option("Fairview Hgts schools",'all=Fairview_Hgts');
mySelect.options[mySelect.options.length] = new Option("Joliet schools",'all=Joliet');
mySelect.options[mySelect.options.length] = new Option("Lake Villa schools",'all=Lake_Villa');
mySelect.options[mySelect.options.length] = new Option("Loves Park schools",'all=Loves_Park');
mySelect.options[mySelect.options.length] = new Option("Peoria schools",'all=Peoria');
mySelect.options[mySelect.options.length] = new Option("Wood River schools",'all=Wood_River');
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);
Lake_Villa[Lake_Villa.length] = createMarker(new GPoint(-88.05568600,42.41208100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Allendale School",'Lake_Villa=' + Lake_Villa.length);
Blue_Island[Blue_Island.length] = createMarker(new GPoint(-87.66937000,41.65083700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Blue Cap School",'Blue_Island=' + Blue_Island.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);
Chicago[Chicago.length] = createMarker(new GPoint(-87.67275300,41.86700600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chicago Lighthouse Development",'Chicago=' + Chicago.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.62531500,41.85525400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Detour 2 Discovery Day School",'Chicago=' + Chicago.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);
Peoria[Peoria.length] = createMarker(new GPoint(-89.59371800,40.71345700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kiefer School",'Peoria=' + Peoria.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.60851800,41.83106300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Joseph's Carondelet",'Chicago=' + Chicago.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.56678300,41.77266300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Step Inc School",'Chicago=' + Chicago.length);
Joliet[Joliet.length] = createMarker(new GPoint(-88.00461600,41.52605600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Srvcs Inc Trinity School",'Joliet=' + Joliet.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.64253900,41.88598800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Uhlich Academy",'Chicago=' + Chicago.length);
Loves_Park[Loves_Park.length] = createMarker(new GPoint(-89.02830200,42.34076400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Walter Lawson Childrens Home",'Loves_Park=' + Loves_Park.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);
map.removeOverlays(Blue_Island);
map.removeOverlays(Chicago);
map.removeOverlays(Fairview_Hgts);
map.removeOverlays(Joliet);
map.removeOverlays(Lake_Villa);
map.removeOverlays(Loves_Park);
map.removeOverlays(Peoria);
map.removeOverlays(Wood_River);
setTimeout(function(){map.addOverlays(Blue_Island)},1000);
setTimeout(function(){map.addOverlays(Chicago)},1000);
setTimeout(function(){map.addOverlays(Fairview_Hgts)},1000);
setTimeout(function(){map.addOverlays(Joliet)},1000);
setTimeout(function(){map.addOverlays(Lake_Villa)},1000);
setTimeout(function(){map.addOverlays(Loves_Park)},1000);
setTimeout(function(){map.addOverlays(Peoria)},1000);
setTimeout(function(){map.addOverlays(Wood_River)},1000);
maxLng = -87.56678300;
maxLat = 42.41208100;
minLng = -90.10303400;
minLat = 38.58220400;
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(Blue_Island);
map.removeOverlays(Chicago);
map.removeOverlays(Fairview_Hgts);
map.removeOverlays(Joliet);
map.removeOverlays(Lake_Villa);
map.removeOverlays(Loves_Park);
map.removeOverlays(Peoria);
map.removeOverlays(Wood_River);
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(Blue_Island);
map.removeOverlays(Chicago);
map.removeOverlays(Fairview_Hgts);
map.removeOverlays(Joliet);
map.removeOverlays(Lake_Villa);
map.removeOverlays(Loves_Park);
map.removeOverlays(Peoria);
map.removeOverlays(Wood_River);
map.addOverlays(Blue_Island);
centerByArray(Blue_Island, false, false);
cntMarker += Blue_Island.length;
map.addOverlays(Chicago);
centerByArray(Chicago, false, false);
cntMarker += Chicago.length;
map.addOverlays(Fairview_Hgts);
centerByArray(Fairview_Hgts, false, false);
cntMarker += Fairview_Hgts.length;
map.addOverlays(Joliet);
centerByArray(Joliet, false, false);
cntMarker += Joliet.length;
map.addOverlays(Lake_Villa);
centerByArray(Lake_Villa, false, false);
cntMarker += Lake_Villa.length;
map.addOverlays(Loves_Park);
centerByArray(Loves_Park, false, false);
cntMarker += Loves_Park.length;
map.addOverlays(Peoria);
centerByArray(Peoria, false, false);
cntMarker += Peoria.length;
map.addOverlays(Wood_River);
centerByArray(Wood_River, false, false);
cntMarker += Wood_River.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///8459,8383,8490,8514,9430,9650,8758,9725,8391,9752,8533,8459,8514,8603,9430,9650,9732,8758,9725,8391,9752,8533,9771,/all');
//window.open('/map.php?type=2&schools=8459,8383,8490,8514,9430,9650,8758,9725,8391,9752,8533,8459,8514,8603,9430,9650,9732,8758,9725,8391,9752,8533,9771,&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;
}