function addMarkers(){
mySelect = document.getElementById('selection');
Chicago = [];Warrenville = [];Joliet = [];La_Grange = [];Urbana = [];Des_Plaines = [];Forrest = [];Burbank = [];Wilmette = [];Aurora = [];Shorewood = [];River_Forest = [];Lake_Forest = [];mySelect.options[mySelect.options.length] = new Option("Aurora schools",'all=Aurora');
mySelect.options[mySelect.options.length] = new Option("Burbank schools",'all=Burbank');
mySelect.options[mySelect.options.length] = new Option("Chicago schools",'all=Chicago');
mySelect.options[mySelect.options.length] = new Option("Des Plaines schools",'all=Des_Plaines');
mySelect.options[mySelect.options.length] = new Option("Forrest schools",'all=Forrest');
mySelect.options[mySelect.options.length] = new Option("Joliet schools",'all=Joliet');
mySelect.options[mySelect.options.length] = new Option("La Grange schools",'all=La_Grange');
mySelect.options[mySelect.options.length] = new Option("Lake Forest schools",'all=Lake_Forest');
mySelect.options[mySelect.options.length] = new Option("River Forest schools",'all=River_Forest');
mySelect.options[mySelect.options.length] = new Option("Shorewood schools",'all=Shorewood');
mySelect.options[mySelect.options.length] = new Option("Urbana schools",'all=Urbana');
mySelect.options[mySelect.options.length] = new Option("Warrenville schools",'all=Warrenville');
mySelect.options[mySelect.options.length] = new Option("Wilmette schools",'all=Wilmette');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Chicago[Chicago.length] = createMarker(new GPoint(-87.71242400,41.99017800),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bais Yaakov High School",'Chicago=' + Chicago.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.72036700,41.99721900),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bnos Rabbeinu High School",'Chicago=' + Chicago.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.70005000,42.01555500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Chedar Lubavitch Hebrew Day School",'Chicago=' + Chicago.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.70004700,42.01554600),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cheder Lubavitch Hebrew Ds Gir",'Chicago=' + Chicago.length);
Warrenville[Warrenville.length] = createMarker(new GPoint(-88.15918400,41.80426200),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Creme De La Creme",'Warrenville=' + Warrenville.length);
Joliet[Joliet.length] = createMarker(new GPoint(-88.16057000,41.55533700),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Educare, Inc.",'Joliet=' + Joliet.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.72715000,41.99033700),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Good Counsel High School",'Chicago=' + Chicago.length);
La_Grange[La_Grange.length] = createMarker(new GPoint(-87.89284200,41.78253200),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Grand Ave Preschool - Day Care",'La_Grange=' + La_Grange.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.70521200,41.99736300),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hanna Sacks Bais Yaakov High School",'Chicago=' + Chicago.length);
Urbana[Urbana.length] = createMarker(new GPoint(-88.22411500,40.11038200),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Home Hi Middle School For Girls",'Urbana=' + Urbana.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.70876600,41.99058100),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Joan Dachs Bais Yaakov",'Chicago=' + Chicago.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.68455900,41.90870100),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Josephinum Middle And High School",'Chicago=' + Chicago.length);
Des_Plaines[Des_Plaines.length] = createMarker(new GPoint(-87.88388500,42.02416300),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kiddie Junction Educational Institute",'Des_Plaines=' + Des_Plaines.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.69887200,41.99593700),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lubavitch Girls High School",'Chicago=' + Chicago.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.69301600,41.77124400),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Maria High School",'Chicago=' + Chicago.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.71519700,41.71316300),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mother Mcauley Liberal Arts High School",'Chicago=' + Chicago.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.77018300,41.93503900),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Notre Dame High School For Girls",'Chicago=' + Chicago.length);
Forrest[Forrest.length] = createMarker(new GPoint(-88.40611900,40.75387000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Open Door Of Hope Christian Academy",'Forrest=' + Forrest.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.70175200,41.85122600),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of Tepeyac High School",'Chicago=' + Chicago.length);
Burbank[Burbank.length] = createMarker(new GPoint(-87.75822400,41.75336800),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Queen Of Peace High School",'Burbank=' + Burbank.length);
Wilmette[Wilmette.length] = createMarker(new GPoint(-87.74212200,42.07671800),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Regina Dominican High School",'Wilmette=' + Wilmette.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.81576000,41.99029200),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Resurrection High School",'Chicago=' + Chicago.length);
Aurora[Aurora.length] = createMarker(new GPoint(-88.35911500,41.77525700),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Rosary High School",'Aurora=' + Aurora.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.68444500,42.01630600),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("St. Scholastica Academy",'Chicago=' + Chicago.length);
Shorewood[Shorewood.length] = createMarker(new GPoint(-88.20538000,41.52369600),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Shorewood Early Learning",'Shorewood=' + Shorewood.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.71739300,41.97554300),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Telshe High School",'Chicago=' + Chicago.length);
River_Forest[River_Forest.length] = createMarker(new GPoint(-87.81438600,41.90153700),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Trinity High School",'River_Forest=' + River_Forest.length);
Des_Plaines[Des_Plaines.length] = createMarker(new GPoint(-87.89880300,42.03848900),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("The Willows Academy",'Des_Plaines=' + Des_Plaines.length);
Lake_Forest[Lake_Forest.length] = createMarker(new GPoint(-87.82901700,42.23253800),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Woodlands Academy Of The Sacred Heart",'Lake_Forest=' + Lake_Forest.length);
map.removeOverlays(Aurora);
map.removeOverlays(Burbank);
map.removeOverlays(Chicago);
map.removeOverlays(Des_Plaines);
map.removeOverlays(Forrest);
map.removeOverlays(Joliet);
map.removeOverlays(La_Grange);
map.removeOverlays(Lake_Forest);
map.removeOverlays(River_Forest);
map.removeOverlays(Shorewood);
map.removeOverlays(Urbana);
map.removeOverlays(Warrenville);
map.removeOverlays(Wilmette);
setTimeout(function(){map.addOverlays(Aurora)},1000);
setTimeout(function(){map.addOverlays(Burbank)},1000);
setTimeout(function(){map.addOverlays(Chicago)},1000);
setTimeout(function(){map.addOverlays(Des_Plaines)},1000);
setTimeout(function(){map.addOverlays(Forrest)},1000);
setTimeout(function(){map.addOverlays(Joliet)},1000);
setTimeout(function(){map.addOverlays(La_Grange)},1000);
setTimeout(function(){map.addOverlays(Lake_Forest)},1000);
setTimeout(function(){map.addOverlays(River_Forest)},1000);
setTimeout(function(){map.addOverlays(Shorewood)},1000);
setTimeout(function(){map.addOverlays(Urbana)},1000);
setTimeout(function(){map.addOverlays(Warrenville)},1000);
setTimeout(function(){map.addOverlays(Wilmette)},1000);
maxLng = -87.68444500;
maxLat = 42.23253800;
minLng = -88.40611900;
minLat = 40.11038200;
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(Aurora);
map.removeOverlays(Burbank);
map.removeOverlays(Chicago);
map.removeOverlays(Des_Plaines);
map.removeOverlays(Forrest);
map.removeOverlays(Joliet);
map.removeOverlays(La_Grange);
map.removeOverlays(Lake_Forest);
map.removeOverlays(River_Forest);
map.removeOverlays(Shorewood);
map.removeOverlays(Urbana);
map.removeOverlays(Warrenville);
map.removeOverlays(Wilmette);
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(Aurora);
map.removeOverlays(Burbank);
map.removeOverlays(Chicago);
map.removeOverlays(Des_Plaines);
map.removeOverlays(Forrest);
map.removeOverlays(Joliet);
map.removeOverlays(La_Grange);
map.removeOverlays(Lake_Forest);
map.removeOverlays(River_Forest);
map.removeOverlays(Shorewood);
map.removeOverlays(Urbana);
map.removeOverlays(Warrenville);
map.removeOverlays(Wilmette);
map.addOverlays(Aurora);
centerByArray(Aurora, false, false);
cntMarker += Aurora.length;
map.addOverlays(Burbank);
centerByArray(Burbank, false, false);
cntMarker += Burbank.length;
map.addOverlays(Chicago);
centerByArray(Chicago, false, false);
cntMarker += Chicago.length;
map.addOverlays(Des_Plaines);
centerByArray(Des_Plaines, false, false);
cntMarker += Des_Plaines.length;
map.addOverlays(Forrest);
centerByArray(Forrest, false, false);
cntMarker += Forrest.length;
map.addOverlays(Joliet);
centerByArray(Joliet, false, false);
cntMarker += Joliet.length;
map.addOverlays(La_Grange);
centerByArray(La_Grange, false, false);
cntMarker += La_Grange.length;
map.addOverlays(Lake_Forest);
centerByArray(Lake_Forest, false, false);
cntMarker += Lake_Forest.length;
map.addOverlays(River_Forest);
centerByArray(River_Forest, false, false);
cntMarker += River_Forest.length;
map.addOverlays(Shorewood);
centerByArray(Shorewood, false, false);
cntMarker += Shorewood.length;
map.addOverlays(Urbana);
centerByArray(Urbana, false, false);
cntMarker += Urbana.length;
map.addOverlays(Warrenville);
centerByArray(Warrenville, false, false);
cntMarker += Warrenville.length;
map.addOverlays(Wilmette);
centerByArray(Wilmette, false, false);
cntMarker += Wilmette.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///9162,9139,8420,34329,8685,8707,8806,8888,8907,9001,9048,9076,9151,9644,9669,9697,33522,9773,9708,9148,31193,8508,8797,8806,8819,9697,9813,32357,32393,35295,32355,/all');
//window.open('/map.php?type=2&schools=9162,9139,8420,34329,8685,8707,8806,8888,8907,9001,9048,9076,9151,9644,9669,9697,33522,9773,9708,9148,31193,8508,8797,8806,8819,9697,9813,32357,32393,35295,32355,&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;
}