function addMarkers(){
mySelect = document.getElementById('selection');
Barrington = [];Oak_Brook = [];Chicago = [];Lisle = [];Elmhurst = [];Wheaton = [];Elk_Grove_Village = [];Wheeling = [];Peoria = [];Bensenville = [];Lincolnwood = [];Evanston = [];Rockford = [];Clarendon_Hills = [];Skokie = [];Roselle = [];mySelect.options[mySelect.options.length] = new Option("Barrington schools",'all=Barrington');
mySelect.options[mySelect.options.length] = new Option("Bensenville schools",'all=Bensenville');
mySelect.options[mySelect.options.length] = new Option("Chicago schools",'all=Chicago');
mySelect.options[mySelect.options.length] = new Option("Clarendon Hills schools",'all=Clarendon_Hills');
mySelect.options[mySelect.options.length] = new Option("Elk Grove Village schools",'all=Elk_Grove_Village');
mySelect.options[mySelect.options.length] = new Option("Elmhurst schools",'all=Elmhurst');
mySelect.options[mySelect.options.length] = new Option("Evanston schools",'all=Evanston');
mySelect.options[mySelect.options.length] = new Option("Lincolnwood schools",'all=Lincolnwood');
mySelect.options[mySelect.options.length] = new Option("Lisle schools",'all=Lisle');
mySelect.options[mySelect.options.length] = new Option("Oak Brook schools",'all=Oak_Brook');
mySelect.options[mySelect.options.length] = new Option("Peoria schools",'all=Peoria');
mySelect.options[mySelect.options.length] = new Option("Rockford schools",'all=Rockford');
mySelect.options[mySelect.options.length] = new Option("Roselle schools",'all=Roselle');
mySelect.options[mySelect.options.length] = new Option("Skokie schools",'all=Skokie');
mySelect.options[mySelect.options.length] = new Option("Wheaton schools",'all=Wheaton');
mySelect.options[mySelect.options.length] = new Option("Wheeling schools",'all=Wheeling');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Barrington[Barrington.length] = createMarker(new GPoint(-88.13638400,42.13226900),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Barrington Montessori School",'Barrington=' + Barrington.length);
Oak_Brook[Oak_Brook.length] = createMarker(new GPoint(-87.95412500,41.84133700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bright Horizons",'Oak_Brook=' + Oak_Brook.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.64878000,41.90756500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("British School of Chicago",'Chicago=' + Chicago.length);
Lisle[Lisle.length] = createMarker(new GPoint(-88.10401200,41.78032300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Childrens Creative Corner",'Lisle=' + Lisle.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);
Elmhurst[Elmhurst.length] = createMarker(new GPoint(-87.94564500,41.91551400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Elmhurst Academy of Early Learning",'Elmhurst=' + Elmhurst.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.75408600,41.95989000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fairyland Nursery School Inc",'Chicago=' + Chicago.length);
Wheaton[Wheaton.length] = createMarker(new GPoint(-88.08994800,41.82970100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("First Care Of Wheaton",'Wheaton=' + Wheaton.length);
Elk_Grove_Village[Elk_Grove_Village.length] = createMarker(new GPoint(-87.99597800,42.00927400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Spirit Luth PreSchool/kdg",'Elk_Grove_Village=' + Elk_Grove_Village.length);
Wheeling[Wheeling.length] = createMarker(new GPoint(-87.94668400,42.13223700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Horizons Children's Center",'Wheeling=' + Wheeling.length);
Peoria[Peoria.length] = createMarker(new GPoint(-89.59371800,40.71345700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kiefer School",'Peoria=' + Peoria.length);
Wheeling[Wheeling.length] = createMarker(new GPoint(-87.94672500,42.12460500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kinder Care Learning Center",'Wheeling=' + Wheeling.length);
Bensenville[Bensenville.length] = createMarker(new GPoint(-87.93500800,41.95365000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kindercare Learning Center",'Bensenville=' + Bensenville.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.66686300,41.87337000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Laurance Armour Day School",'Chicago=' + Chicago.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.73037100,41.85866300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Les Finch's Learning Tree Day",'Chicago=' + Chicago.length);
Lincolnwood[Lincolnwood.length] = createMarker(new GPoint(-87.74584900,42.00436300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lincolnwood Presch - Kindgrtn",'Lincolnwood=' + Lincolnwood.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.58561500,41.76117900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Muhammad University",'Chicago=' + Chicago.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.72083100,41.92544200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of Grace School",'Chicago=' + Chicago.length);
Evanston[Evanston.length] = createMarker(new GPoint(-87.68785200,42.03267900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pope John Xxiii",'Evanston=' + Evanston.length);
Rockford[Rockford.length] = createMarker(new GPoint(-89.10249700,42.30096300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rockford Health System Children",'Rockford=' + Rockford.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.73039700,41.91516300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Philomena School",'Chicago=' + Chicago.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.69377800,41.80033000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Simon The Apostle",'Chicago=' + Chicago.length);
Clarendon_Hills[Clarendon_Hills.length] = createMarker(new GPoint(-87.95933100,41.78432300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Seton Montessori School",'Clarendon_Hills=' + Clarendon_Hills.length);
Skokie[Skokie.length] = createMarker(new GPoint(-87.75114800,42.03133900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Swift Child Care & Kindergarten",'Skokie=' + Skokie.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.61505200,41.74689900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tiny Tots Villa Montessori",'Chicago=' + Chicago.length);
Roselle[Roselle.length] = createMarker(new GPoint(-88.07397400,41.97539800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Lutheran School",'Roselle=' + Roselle.length);
map.removeOverlays(Barrington);
map.removeOverlays(Bensenville);
map.removeOverlays(Chicago);
map.removeOverlays(Clarendon_Hills);
map.removeOverlays(Elk_Grove_Village);
map.removeOverlays(Elmhurst);
map.removeOverlays(Evanston);
map.removeOverlays(Lincolnwood);
map.removeOverlays(Lisle);
map.removeOverlays(Oak_Brook);
map.removeOverlays(Peoria);
map.removeOverlays(Rockford);
map.removeOverlays(Roselle);
map.removeOverlays(Skokie);
map.removeOverlays(Wheaton);
map.removeOverlays(Wheeling);
setTimeout(function(){map.addOverlays(Barrington)},1000);
setTimeout(function(){map.addOverlays(Bensenville)},1000);
setTimeout(function(){map.addOverlays(Chicago)},1000);
setTimeout(function(){map.addOverlays(Clarendon_Hills)},1000);
setTimeout(function(){map.addOverlays(Elk_Grove_Village)},1000);
setTimeout(function(){map.addOverlays(Elmhurst)},1000);
setTimeout(function(){map.addOverlays(Evanston)},1000);
setTimeout(function(){map.addOverlays(Lincolnwood)},1000);
setTimeout(function(){map.addOverlays(Lisle)},1000);
setTimeout(function(){map.addOverlays(Oak_Brook)},1000);
setTimeout(function(){map.addOverlays(Peoria)},1000);
setTimeout(function(){map.addOverlays(Rockford)},1000);
setTimeout(function(){map.addOverlays(Roselle)},1000);
setTimeout(function(){map.addOverlays(Skokie)},1000);
setTimeout(function(){map.addOverlays(Wheaton)},1000);
setTimeout(function(){map.addOverlays(Wheeling)},1000);
maxLng = -87.58561500;
maxLat = 42.30096300;
minLng = -89.59371800;
minLat = 40.71345700;
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(Barrington);
map.removeOverlays(Bensenville);
map.removeOverlays(Chicago);
map.removeOverlays(Clarendon_Hills);
map.removeOverlays(Elk_Grove_Village);
map.removeOverlays(Elmhurst);
map.removeOverlays(Evanston);
map.removeOverlays(Lincolnwood);
map.removeOverlays(Lisle);
map.removeOverlays(Oak_Brook);
map.removeOverlays(Peoria);
map.removeOverlays(Rockford);
map.removeOverlays(Roselle);
map.removeOverlays(Skokie);
map.removeOverlays(Wheaton);
map.removeOverlays(Wheeling);
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(Barrington);map.removeOverlays(Barrington);
map.removeOverlays(Bensenville);
map.removeOverlays(Chicago);
map.removeOverlays(Clarendon_Hills);
map.removeOverlays(Elk_Grove_Village);
map.removeOverlays(Elmhurst);
map.removeOverlays(Evanston);
map.removeOverlays(Lincolnwood);
map.removeOverlays(Lisle);
map.removeOverlays(Oak_Brook);
map.removeOverlays(Peoria);
map.removeOverlays(Rockford);
map.removeOverlays(Roselle);
map.removeOverlays(Skokie);
map.removeOverlays(Wheaton);
map.removeOverlays(Wheeling);
map.addOverlays(Barrington);
centerByArray(Barrington, false, false);
cntMarker += Barrington.length;
map.addOverlays(Bensenville);
centerByArray(Bensenville, false, false);
cntMarker += Bensenville.length;
map.addOverlays(Chicago);
centerByArray(Chicago, false, false);
cntMarker += Chicago.length;
map.addOverlays(Clarendon_Hills);
centerByArray(Clarendon_Hills, false, false);
cntMarker += Clarendon_Hills.length;
map.addOverlays(Elk_Grove_Village);
centerByArray(Elk_Grove_Village, false, false);
cntMarker += Elk_Grove_Village.length;
map.addOverlays(Elmhurst);
centerByArray(Elmhurst, false, false);
cntMarker += Elmhurst.length;
map.addOverlays(Evanston);
centerByArray(Evanston, false, false);
cntMarker += Evanston.length;
map.addOverlays(Lincolnwood);
centerByArray(Lincolnwood, false, false);
cntMarker += Lincolnwood.length;
map.addOverlays(Lisle);
centerByArray(Lisle, false, false);
cntMarker += Lisle.length;
map.addOverlays(Oak_Brook);
centerByArray(Oak_Brook, false, false);
cntMarker += Oak_Brook.length;
map.addOverlays(Peoria);
centerByArray(Peoria, false, false);
cntMarker += Peoria.length;
map.addOverlays(Rockford);
centerByArray(Rockford, false, false);
cntMarker += Rockford.length;
map.addOverlays(Roselle);
centerByArray(Roselle, false, false);
cntMarker += Roselle.length;
map.addOverlays(Skokie);
centerByArray(Skokie, false, false);
cntMarker += Skokie.length;
map.addOverlays(Wheaton);
centerByArray(Wheaton, false, false);
cntMarker += Wheaton.length;
map.addOverlays(Wheeling);
centerByArray(Wheeling, false, false);
cntMarker += Wheeling.length;
centerByArray(Barrington,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///30648,8533,8423,9826,30648,8603,8634,8854,8858,8366,9063,9582,9598,8344,9205,8743,9823,9120,8862,9807,9819,8533,9856,9712,9666,9815,8752,8829,/all');
//window.open('/map.php?type=2&schools=30648,8533,8423,9826,30648,8603,8634,8854,8858,8366,9063,9582,9598,8344,9205,8743,9823,9120,8862,9807,9819,8533,9856,9712,9666,9815,8752,8829,&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;
}