function addMarkers(){
mySelect = document.getElementById('selection');
Chicago = [];Skokie = [];Aurora = [];Niles = [];Georgetown = [];Burbank = [];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("Georgetown schools",'all=Georgetown');
mySelect.options[mySelect.options.length] = new Option("Niles schools",'all=Niles');
mySelect.options[mySelect.options.length] = new Option("Skokie schools",'all=Skokie');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Chicago[Chicago.length] = createMarker(new GPoint(-87.62601400,41.89820500),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Archbishop Quigley Prep Semina",'Chicago=' + Chicago.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.70468300,41.99763700),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Brisk Academy-yeshivas Brisk",'Chicago=' + Chicago.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.72090300,41.71113700),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Brother Rice High School",'Chicago=' + Chicago.length);
Skokie[Skokie.length] = createMarker(new GPoint(-87.75760300,42.01896300),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Cheder Lubavitch Hebrew Day School",'Skokie=' + Skokie.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.62488500,41.83337100),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("De La Salle Institute",'Chicago=' + Chicago.length);
Skokie[Skokie.length] = createMarker(new GPoint(-87.76145200,42.01096300),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Fasman Yeshiva High School",'Skokie=' + Skokie.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.60664700,41.80529600),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Hales Franciscan High School",'Chicago=' + Chicago.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.64750700,41.75045300),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Leo Catholic High School",'Chicago=' + Chicago.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.69874200,42.00678100),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Lubavitch Mesivta Of Chicago",'Chicago=' + Chicago.length);
Aurora[Aurora.length] = createMarker(new GPoint(-88.29283900,41.81188600),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Marmion Academy",'Aurora=' + Aurora.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.58978300,41.77863100),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mount Carmel High School",'Chicago=' + Chicago.length);
Niles[Niles.length] = createMarker(new GPoint(-87.83423100,42.04390200),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Northridge Preparatory School",'Niles=' + Niles.length);
Georgetown[Georgetown.length] = createMarker(new GPoint(-87.64372100,39.94047100),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Notre Dame De La Salette Boys Academy",'Georgetown=' + Georgetown.length);
Niles[Niles.length] = createMarker(new GPoint(-87.81830600,42.04026300),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Notre Dame High School For Boy",'Niles=' + Niles.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.71518300,41.85239800),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("St. Gregory Episcopal School",'Chicago=' + Chicago.length);
Burbank[Burbank.length] = createMarker(new GPoint(-87.76015900,41.75263700),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("St. Laurence High School",'Burbank=' + Burbank.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.77398400,41.93863700),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("St. Patrick High School",'Chicago=' + Chicago.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.68314100,41.75294200),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("St. Rita Of Cascia High School",'Chicago=' + Chicago.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.70564000,42.01207900),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Yeshiva Meor Hatorah",'Chicago=' + Chicago.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.69547000,42.01233700),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Yeshiva Shearis Yisroel",'Chicago=' + Chicago.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.69968400,41.99284600),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Yeshiva Tiferes Tzvi",'Chicago=' + Chicago.length);
map.removeOverlays(Aurora);
map.removeOverlays(Burbank);
map.removeOverlays(Chicago);
map.removeOverlays(Georgetown);
map.removeOverlays(Niles);
map.removeOverlays(Skokie);
setTimeout(function(){map.addOverlays(Aurora)},1000);
setTimeout(function(){map.addOverlays(Burbank)},1000);
setTimeout(function(){map.addOverlays(Chicago)},1000);
setTimeout(function(){map.addOverlays(Georgetown)},1000);
setTimeout(function(){map.addOverlays(Niles)},1000);
setTimeout(function(){map.addOverlays(Skokie)},1000);
maxLng = -87.58978300;
maxLat = 42.04390200;
minLng = -88.29283900;
minLat = 39.94047100;
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(Georgetown);
map.removeOverlays(Niles);
map.removeOverlays(Skokie);
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(Georgetown);
map.removeOverlays(Niles);
map.removeOverlays(Skokie);
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(Georgetown);
centerByArray(Georgetown, false, false);
cntMarker += Georgetown.length;
map.addOverlays(Niles);
centerByArray(Niles, false, false);
cntMarker += Niles.length;
map.addOverlays(Skokie);
centerByArray(Skokie, false, false);
cntMarker += Skokie.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///8913,9437,35942,8468,8470,8600,8706,8857,8887,9004,9533,9592,31194,35376,9033,9047,8645,9351,9775,9776,9033,8328,/all');
//window.open('/map.php?type=2&schools=8913,9437,35942,8468,8470,8600,8706,8857,8887,9004,9533,9592,31194,35376,9033,9047,8645,9351,9775,9776,9033,8328,&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;
}