function addMarkers(){
mySelect = document.getElementById('selection');
Wauwatosa = [];La_Crosse = [];Eau_Claire = [];Highbridge = [];Sheboygan = [];Dousman = [];Milwaukee = [];Oconomowoc = [];New_London = [];Waupaca = [];Madison = [];Pr_Du_Chien = [];mySelect.options[mySelect.options.length] = new Option("Dousman schools",'all=Dousman');
mySelect.options[mySelect.options.length] = new Option("Eau Claire schools",'all=Eau_Claire');
mySelect.options[mySelect.options.length] = new Option("Highbridge schools",'all=Highbridge');
mySelect.options[mySelect.options.length] = new Option("La Crosse schools",'all=La_Crosse');
mySelect.options[mySelect.options.length] = new Option("Madison schools",'all=Madison');
mySelect.options[mySelect.options.length] = new Option("Milwaukee schools",'all=Milwaukee');
mySelect.options[mySelect.options.length] = new Option("New London schools",'all=New_London');
mySelect.options[mySelect.options.length] = new Option("Oconomowoc schools",'all=Oconomowoc');
mySelect.options[mySelect.options.length] = new Option("Pr Du Chien schools",'all=Pr_Du_Chien');
mySelect.options[mySelect.options.length] = new Option("Sheboygan schools",'all=Sheboygan');
mySelect.options[mySelect.options.length] = new Option("Waupaca schools",'all=Waupaca');
mySelect.options[mySelect.options.length] = new Option("Wauwatosa schools",'all=Wauwatosa');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Wauwatosa[Wauwatosa.length] = createMarker(new GPoint(-88.01101100,43.04637000),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Carmelite Home For Boys - School",'Wauwatosa=' + Wauwatosa.length);
La_Crosse[La_Crosse.length] = createMarker(new GPoint(-91.24200300,43.80246300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chileda Institute",'La_Crosse=' + La_Crosse.length);
Eau_Claire[Eau_Claire.length] = createMarker(new GPoint(-91.49959200,44.81968600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eau Claire Academy",'Eau_Claire=' + Eau_Claire.length);
Highbridge[Highbridge.length] = createMarker(new GPoint(-90.74690000,46.38400000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("House Of The Lord Christian Academy",'Highbridge=' + Highbridge.length);
Sheboygan[Sheboygan.length] = createMarker(new GPoint(-87.75747000,43.84876500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jansen Learning Center Willowg",'Sheboygan=' + Sheboygan.length);
Dousman[Dousman.length] = createMarker(new GPoint(-88.46320000,42.98010000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Lakewood School",'Dousman=' + Dousman.length);
Milwaukee[Milwaukee.length] = createMarker(new GPoint(-88.03417700,43.09529700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lutheran Special School",'Milwaukee=' + Milwaukee.length);
Oconomowoc[Oconomowoc.length] = createMarker(new GPoint(-88.46459500,43.04746700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Oconomowoc Dvlp Training Center",'Oconomowoc=' + Oconomowoc.length);
Milwaukee[Milwaukee.length] = createMarker(new GPoint(-88.02408800,43.08946300),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("St. Aemilian-lakeside, Inc",'Milwaukee=' + Milwaukee.length);
Milwaukee[Milwaukee.length] = createMarker(new GPoint(-88.01758700,43.03046400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Charles Inc",'Milwaukee=' + Milwaukee.length);
Milwaukee[Milwaukee.length] = createMarker(new GPoint(-87.98176200,43.05347400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Coletta Day School Of Milw",'Milwaukee=' + Milwaukee.length);
Milwaukee[Milwaukee.length] = createMarker(new GPoint(-88.02274400,43.08588300),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("St. Rose Youth & Family Center School",'Milwaukee=' + Milwaukee.length);
New_London[New_London.length] = createMarker(new GPoint(-88.84828400,44.31190000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Starr Academy",'New_London=' + New_London.length);
Waupaca[Waupaca.length] = createMarker(new GPoint(-89.11600000,44.33390000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tomorrow's Children, Inc.",'Waupaca=' + Waupaca.length);
Madison[Madison.length] = createMarker(new GPoint(-89.50365400,43.07630000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Walbridge School",'Madison=' + Madison.length);
Milwaukee[Milwaukee.length] = createMarker(new GPoint(-87.96275900,43.05513200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Willowglen Academy Cornerstone",'Milwaukee=' + Milwaukee.length);
Pr_Du_Chien[Pr_Du_Chien.length] = createMarker(new GPoint(-91.14648700,43.04505300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wyalusing Academy",'Pr_Du_Chien=' + Pr_Du_Chien.length);
map.removeOverlays(Dousman);
map.removeOverlays(Eau_Claire);
map.removeOverlays(Highbridge);
map.removeOverlays(La_Crosse);
map.removeOverlays(Madison);
map.removeOverlays(Milwaukee);
map.removeOverlays(New_London);
map.removeOverlays(Oconomowoc);
map.removeOverlays(Pr_Du_Chien);
map.removeOverlays(Sheboygan);
map.removeOverlays(Waupaca);
map.removeOverlays(Wauwatosa);
setTimeout(function(){map.addOverlays(Dousman)},1000);
setTimeout(function(){map.addOverlays(Eau_Claire)},1000);
setTimeout(function(){map.addOverlays(Highbridge)},1000);
setTimeout(function(){map.addOverlays(La_Crosse)},1000);
setTimeout(function(){map.addOverlays(Madison)},1000);
setTimeout(function(){map.addOverlays(Milwaukee)},1000);
setTimeout(function(){map.addOverlays(New_London)},1000);
setTimeout(function(){map.addOverlays(Oconomowoc)},1000);
setTimeout(function(){map.addOverlays(Pr_Du_Chien)},1000);
setTimeout(function(){map.addOverlays(Sheboygan)},1000);
setTimeout(function(){map.addOverlays(Waupaca)},1000);
setTimeout(function(){map.addOverlays(Wauwatosa)},1000);
maxLng = -87.75747000;
maxLat = 46.38400000;
minLng = -91.49959200;
minLat = 42.98010000;
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(Dousman);
map.removeOverlays(Eau_Claire);
map.removeOverlays(Highbridge);
map.removeOverlays(La_Crosse);
map.removeOverlays(Madison);
map.removeOverlays(Milwaukee);
map.removeOverlays(New_London);
map.removeOverlays(Oconomowoc);
map.removeOverlays(Pr_Du_Chien);
map.removeOverlays(Sheboygan);
map.removeOverlays(Waupaca);
map.removeOverlays(Wauwatosa);
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(Wauwatosa);map.removeOverlays(Dousman);
map.removeOverlays(Eau_Claire);
map.removeOverlays(Highbridge);
map.removeOverlays(La_Crosse);
map.removeOverlays(Madison);
map.removeOverlays(Milwaukee);
map.removeOverlays(New_London);
map.removeOverlays(Oconomowoc);
map.removeOverlays(Pr_Du_Chien);
map.removeOverlays(Sheboygan);
map.removeOverlays(Waupaca);
map.removeOverlays(Wauwatosa);
map.addOverlays(Dousman);
centerByArray(Dousman, false, false);
cntMarker += Dousman.length;
map.addOverlays(Eau_Claire);
centerByArray(Eau_Claire, false, false);
cntMarker += Eau_Claire.length;
map.addOverlays(Highbridge);
centerByArray(Highbridge, false, false);
cntMarker += Highbridge.length;
map.addOverlays(La_Crosse);
centerByArray(La_Crosse, false, false);
cntMarker += La_Crosse.length;
map.addOverlays(Madison);
centerByArray(Madison, false, false);
cntMarker += Madison.length;
map.addOverlays(Milwaukee);
centerByArray(Milwaukee, false, false);
cntMarker += Milwaukee.length;
map.addOverlays(New_London);
centerByArray(New_London, false, false);
cntMarker += New_London.length;
map.addOverlays(Oconomowoc);
centerByArray(Oconomowoc, false, false);
cntMarker += Oconomowoc.length;
map.addOverlays(Pr_Du_Chien);
centerByArray(Pr_Du_Chien, false, false);
cntMarker += Pr_Du_Chien.length;
map.addOverlays(Sheboygan);
centerByArray(Sheboygan, false, false);
cntMarker += Sheboygan.length;
map.addOverlays(Waupaca);
centerByArray(Waupaca, false, false);
cntMarker += Waupaca.length;
map.addOverlays(Wauwatosa);
centerByArray(Wauwatosa, false, false);
cntMarker += Wauwatosa.length;
centerByArray(Wauwatosa,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///29659,29511,29627,29458,30287,29894,29929,30207,30222,30296,30225,29761,30310,29647,30241,29447,29659,29511,29627,29458,30287,29675,29894,29929,30207,30296,29761,30310,29647,30241,29447,/all');
//window.open('/map.php?type=2&schools=29659,29511,29627,29458,30287,29894,29929,30207,30222,30296,30225,29761,30310,29647,30241,29447,29659,29511,29627,29458,30287,29675,29894,29929,30207,30296,29761,30310,29647,30241,29447,&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;
}