function addMarkers(){
mySelect = document.getElementById('selection');
Lisle = [];Downers_Grove = [];Warrenville = [];Lombard = [];Addison = [];Elmhurst = [];Villa_Park = [];Bloomingdale = [];Naperville = [];Wheaton = [];West_Chicago = [];mySelect.options[mySelect.options.length] = new Option("Addison schools",'all=Addison');
mySelect.options[mySelect.options.length] = new Option("Bloomingdale schools",'all=Bloomingdale');
mySelect.options[mySelect.options.length] = new Option("Downers Grove schools",'all=Downers_Grove');
mySelect.options[mySelect.options.length] = new Option("Elmhurst schools",'all=Elmhurst');
mySelect.options[mySelect.options.length] = new Option("Lisle schools",'all=Lisle');
mySelect.options[mySelect.options.length] = new Option("Lombard schools",'all=Lombard');
mySelect.options[mySelect.options.length] = new Option("Naperville schools",'all=Naperville');
mySelect.options[mySelect.options.length] = new Option("Villa Park schools",'all=Villa_Park');
mySelect.options[mySelect.options.length] = new Option("Warrenville schools",'all=Warrenville');
mySelect.options[mySelect.options.length] = new Option("West Chicago schools",'all=West_Chicago');
mySelect.options[mySelect.options.length] = new Option("Wheaton schools",'all=Wheaton');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Lisle[Lisle.length] = createMarker(new GPoint(-88.09281000,41.78231200),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Benet Academy",'Lisle=' + Lisle.length);
Downers_Grove[Downers_Grove.length] = createMarker(new GPoint(-88.04163900,41.78990400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Bridge High School",'Downers_Grove=' + Downers_Grove.length);
Warrenville[Warrenville.length] = createMarker(new GPoint(-88.20304000,41.82388100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Carmel Montessori Academy And",'Warrenville=' + Warrenville.length);
Lombard[Lombard.length] = createMarker(new GPoint(-88.02447400,41.87437900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("College Preparatory School Of America",'Lombard=' + Lombard.length);
Lombard[Lombard.length] = createMarker(new GPoint(-88.01158500,41.86011000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Delphi Academy of Chicago",'Lombard=' + Lombard.length);
Addison[Addison.length] = createMarker(new GPoint(-88.02237000,41.93671300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Driscoll Catholic High School",'Addison=' + Addison.length);
Elmhurst[Elmhurst.length] = createMarker(new GPoint(-87.94221500,41.89542600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Immaculate Conception High School",'Elmhurst=' + Elmhurst.length);
Villa_Park[Villa_Park.length] = createMarker(new GPoint(-87.98376500,41.86703200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Islamic Foundation School",'Villa_Park=' + Villa_Park.length);
Elmhurst[Elmhurst.length] = createMarker(new GPoint(-87.94957000,41.88857400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lor. Jon Montessori School",'Elmhurst=' + Elmhurst.length);
Addison[Addison.length] = createMarker(new GPoint(-87.99673000,41.93547000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lutherbrook Academy",'Addison=' + Addison.length);
Bloomingdale[Bloomingdale.length] = createMarker(new GPoint(-88.06923000,41.95321700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Marklund Day School",'Bloomingdale=' + Bloomingdale.length);
Downers_Grove[Downers_Grove.length] = createMarker(new GPoint(-87.99193900,41.75111900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Marquette Manor Baptist Academy",'Downers_Grove=' + Downers_Grove.length);
Lombard[Lombard.length] = createMarker(new GPoint(-87.99853700,41.85343700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montini Catholic H.S.",'Lombard=' + Lombard.length);
Naperville[Naperville.length] = createMarker(new GPoint(-88.18727900,41.79334000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Naperville Christian Academy",'Naperville=' + Naperville.length);
Addison[Addison.length] = createMarker(new GPoint(-88.04201500,41.92602500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northwest Academy",'Addison=' + Addison.length);
Downers_Grove[Downers_Grove.length] = createMarker(new GPoint(-87.99893300,41.76972000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Power Think Academy",'Downers_Grove=' + Downers_Grove.length);
Villa_Park[Villa_Park.length] = createMarker(new GPoint(-87.99375100,41.89581400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Seton Academy Montessori",'Villa_Park=' + Villa_Park.length);
Naperville[Naperville.length] = createMarker(new GPoint(-88.20272400,41.79379500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Skylight School",'Naperville=' + Naperville.length);
Wheaton[Wheaton.length] = createMarker(new GPoint(-88.14062400,41.85759900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Francis High School",'Wheaton=' + Wheaton.length);
Elmhurst[Elmhurst.length] = createMarker(new GPoint(-87.94363500,41.86564400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Timothy Christian High School",'Elmhurst=' + Elmhurst.length);
Elmhurst[Elmhurst.length] = createMarker(new GPoint(-87.94348600,41.86722700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Timothy Christian P-12",'Elmhurst=' + Elmhurst.length);
West_Chicago[West_Chicago.length] = createMarker(new GPoint(-88.18473900,41.90025800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wheaton Academy",'West_Chicago=' + West_Chicago.length);
} // 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/////2/' + showArray);
map.removeOverlays(Addison);
map.removeOverlays(Bloomingdale);
map.removeOverlays(Downers_Grove);
map.removeOverlays(Elmhurst);
map.removeOverlays(Lisle);
map.removeOverlays(Lombard);
map.removeOverlays(Naperville);
map.removeOverlays(Villa_Park);
map.removeOverlays(Warrenville);
map.removeOverlays(West_Chicago);
map.removeOverlays(Wheaton);
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(Lisle);map.removeOverlays(Addison);
map.removeOverlays(Bloomingdale);
map.removeOverlays(Downers_Grove);
map.removeOverlays(Elmhurst);
map.removeOverlays(Lisle);
map.removeOverlays(Lombard);
map.removeOverlays(Naperville);
map.removeOverlays(Villa_Park);
map.removeOverlays(Warrenville);
map.removeOverlays(West_Chicago);
map.removeOverlays(Wheaton);
map.addOverlays(Addison);
centerByArray(Addison, false, false);
cntMarker += Addison.length;
map.addOverlays(Bloomingdale);
centerByArray(Bloomingdale, false, false);
cntMarker += Bloomingdale.length;
map.addOverlays(Downers_Grove);
centerByArray(Downers_Grove, false, false);
cntMarker += Downers_Grove.length;
map.addOverlays(Elmhurst);
centerByArray(Elmhurst, false, false);
cntMarker += Elmhurst.length;
map.addOverlays(Lisle);
centerByArray(Lisle, false, false);
cntMarker += Lisle.length;
map.addOverlays(Lombard);
centerByArray(Lombard, false, false);
cntMarker += Lombard.length;
map.addOverlays(Naperville);
centerByArray(Naperville, false, false);
cntMarker += Naperville.length;
map.addOverlays(Villa_Park);
centerByArray(Villa_Park, false, false);
cntMarker += Villa_Park.length;
map.addOverlays(Warrenville);
centerByArray(Warrenville, false, false);
cntMarker += Warrenville.length;
map.addOverlays(West_Chicago);
centerByArray(West_Chicago, false, false);
cntMarker += West_Chicago.length;
map.addOverlays(Wheaton);
centerByArray(Wheaton, false, false);
cntMarker += Wheaton.length;
centerByArray(Lisle,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////all');
//window.open('/map.php?type=1&schools=&school_level=2&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;
}