function addMarkers(){
mySelect = document.getElementById('selection');
Lake_Villa = [];Mundelein = [];North_Chicago = [];Lake_Bluff = [];Waukegan = [];Lake_Forest = [];Zion = [];Grayslake = [];mySelect.options[mySelect.options.length] = new Option("Grayslake schools",'all=Grayslake');
mySelect.options[mySelect.options.length] = new Option("Lake Bluff schools",'all=Lake_Bluff');
mySelect.options[mySelect.options.length] = new Option("Lake Forest schools",'all=Lake_Forest');
mySelect.options[mySelect.options.length] = new Option("Lake Villa schools",'all=Lake_Villa');
mySelect.options[mySelect.options.length] = new Option("Mundelein schools",'all=Mundelein');
mySelect.options[mySelect.options.length] = new Option("North Chicago schools",'all=North_Chicago');
mySelect.options[mySelect.options.length] = new Option("Waukegan schools",'all=Waukegan');
mySelect.options[mySelect.options.length] = new Option("Zion schools",'all=Zion');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
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);
Mundelein[Mundelein.length] = createMarker(new GPoint(-87.98694300,42.27323500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Carmel Catholic High School",'Mundelein=' + Mundelein.length);
Lake_Villa[Lake_Villa.length] = createMarker(new GPoint(-88.05700000,42.41170000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Comm Alternative Renewal Exper",'Lake_Villa=' + Lake_Villa.length);
North_Chicago[North_Chicago.length] = createMarker(new GPoint(-87.86199000,42.32451300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Daisys Resource Optional School",'North_Chicago=' + North_Chicago.length);
Lake_Bluff[Lake_Bluff.length] = createMarker(new GPoint(-87.84849500,42.27980700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Forest Bluff School",'Lake_Bluff=' + Lake_Bluff.length);
Waukegan[Waukegan.length] = createMarker(new GPoint(-87.85029100,42.41022900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lake County Baptist School",'Waukegan=' + Waukegan.length);
Lake_Forest[Lake_Forest.length] = createMarker(new GPoint(-87.89004900,42.24806300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lake Forest Academy",'Lake_Forest=' + Lake_Forest.length);
Lake_Forest[Lake_Forest.length] = createMarker(new GPoint(-87.90046100,42.27033700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School Of Lake Forest",'Lake_Forest=' + Lake_Forest.length);
Zion[Zion.length] = createMarker(new GPoint(-87.87303300,42.47248200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Spirit Of Life Christian Ed Un",'Zion=' + Zion.length);
Grayslake[Grayslake.length] = createMarker(new GPoint(-88.04351300,42.33875300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Westlake Christian Academy",'Grayslake=' + Grayslake.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);
Zion[Zion.length] = createMarker(new GPoint(-80.70762200,41.06356800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Zion Christian School",'Zion=' + Zion.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(Grayslake);
map.removeOverlays(Lake_Bluff);
map.removeOverlays(Lake_Forest);
map.removeOverlays(Lake_Villa);
map.removeOverlays(Mundelein);
map.removeOverlays(North_Chicago);
map.removeOverlays(Waukegan);
map.removeOverlays(Zion);
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(Lake_Villa);map.removeOverlays(Grayslake);
map.removeOverlays(Lake_Bluff);
map.removeOverlays(Lake_Forest);
map.removeOverlays(Lake_Villa);
map.removeOverlays(Mundelein);
map.removeOverlays(North_Chicago);
map.removeOverlays(Waukegan);
map.removeOverlays(Zion);
map.addOverlays(Grayslake);
centerByArray(Grayslake, false, false);
cntMarker += Grayslake.length;
map.addOverlays(Lake_Bluff);
centerByArray(Lake_Bluff, false, false);
cntMarker += Lake_Bluff.length;
map.addOverlays(Lake_Forest);
centerByArray(Lake_Forest, false, false);
cntMarker += Lake_Forest.length;
map.addOverlays(Lake_Villa);
centerByArray(Lake_Villa, false, false);
cntMarker += Lake_Villa.length;
map.addOverlays(Mundelein);
centerByArray(Mundelein, false, false);
cntMarker += Mundelein.length;
map.addOverlays(North_Chicago);
centerByArray(North_Chicago, false, false);
cntMarker += North_Chicago.length;
map.addOverlays(Waukegan);
centerByArray(Waukegan, false, false);
cntMarker += Waukegan.length;
map.addOverlays(Zion);
centerByArray(Zion, false, false);
cntMarker += Zion.length;
centerByArray(Lake_Villa,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;
}