function addMarkers(){
mySelect = document.getElementById('selection');
Appleton = [];Brookfield = [];Franklin = [];Green_Bay = [];Madison = [];Milwaukee = [];Oconomowoc = [];Oshkosh = [];Racine = [];Slinger = [];Stone_Lake = [];Sussex = [];West_Allis = [];Wisconsin_Rapids = [];mySelect.options[mySelect.options.length] = new Option("Appleton schools",'all=Appleton');
mySelect.options[mySelect.options.length] = new Option("Brookfield schools",'all=Brookfield');
mySelect.options[mySelect.options.length] = new Option("Franklin schools",'all=Franklin');
mySelect.options[mySelect.options.length] = new Option("Green Bay schools",'all=Green_Bay');
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("Oconomowoc schools",'all=Oconomowoc');
mySelect.options[mySelect.options.length] = new Option("Oshkosh schools",'all=Oshkosh');
mySelect.options[mySelect.options.length] = new Option("Racine schools",'all=Racine');
mySelect.options[mySelect.options.length] = new Option("Slinger schools",'all=Slinger');
mySelect.options[mySelect.options.length] = new Option("Stone Lake schools",'all=Stone_Lake');
mySelect.options[mySelect.options.length] = new Option("Sussex schools",'all=Sussex');
mySelect.options[mySelect.options.length] = new Option("West Allis schools",'all=West_Allis');
mySelect.options[mySelect.options.length] = new Option("Wisconsin Rapids schools",'all=Wisconsin_Rapids');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Appleton[Appleton.length] = createMarker(new GPoint(-88.41599100,44.27948200),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Creative Child",'Appleton=' + Appleton.length);
Brookfield[Brookfield.length] = createMarker(new GPoint(-88.12192100,43.06066300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Amy Montessori School",'Brookfield=' + Brookfield.length);
Brookfield[Brookfield.length] = createMarker(new GPoint(-88.15338900,43.06116300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Children's Edu Care North Ave",'Brookfield=' + Brookfield.length);
Franklin[Franklin.length] = createMarker(new GPoint(-87.95175300,42.86639600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Oakwood Discovery Elementary School",'Franklin=' + Franklin.length);
Green_Bay[Green_Bay.length] = createMarker(new GPoint(-88.06592700,44.49975900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Beth Haven Academy",'Green_Bay=' + Green_Bay.length);
Green_Bay[Green_Bay.length] = createMarker(new GPoint(-87.97831500,44.50196000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Savior Lutheran Preschool",'Green_Bay=' + Green_Bay.length);
Green_Bay[Green_Bay.length] = createMarker(new GPoint(-88.06616000,44.53227300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Mary's Hospital Early Child Center",'Green_Bay=' + Green_Bay.length);
Green_Bay[Green_Bay.length] = createMarker(new GPoint(-87.97832200,44.50193400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Saviour Lutheran Preschool & Kindergarten",'Green_Bay=' + Green_Bay.length);
Madison[Madison.length] = createMarker(new GPoint(-89.38652300,43.13902400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Countryside Montessori Prescho",'Madison=' + Madison.length);
Madison[Madison.length] = createMarker(new GPoint(-89.38621200,43.07640800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("First United Methodist Prescho",'Madison=' + Madison.length);
Madison[Madison.length] = createMarker(new GPoint(-89.51817200,43.03305700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kids Express Learning Center",'Madison=' + Madison.length);
Milwaukee[Milwaukee.length] = createMarker(new GPoint(-87.97820000,43.08590000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Harbor Cross School",'Milwaukee=' + Milwaukee.length);
Milwaukee[Milwaukee.length] = createMarker(new GPoint(-87.95408700,43.01647900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hilltop El Seeds Of Health",'Milwaukee=' + Milwaukee.length);
Milwaukee[Milwaukee.length] = createMarker(new GPoint(-87.93691100,42.99836200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Parkside Elementary School",'Milwaukee=' + Milwaukee.length);
Milwaukee[Milwaukee.length] = createMarker(new GPoint(-87.96777700,43.06807400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sherman Park Preschool",'Milwaukee=' + Milwaukee.length);
Milwaukee[Milwaukee.length] = createMarker(new GPoint(-87.91268800,43.14232600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Francis Childrens Center",'Milwaukee=' + Milwaukee.length);
Milwaukee[Milwaukee.length] = createMarker(new GPoint(-87.93265100,43.10745700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Stepping Stone Learning Center",'Milwaukee=' + Milwaukee.length);
Milwaukee[Milwaukee.length] = createMarker(new GPoint(-87.95008700,43.06503100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Helwig Family Center",'Milwaukee=' + Milwaukee.length);
Milwaukee[Milwaukee.length] = createMarker(new GPoint(-87.99091100,43.11762000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Silver Spring Day Care Center",'Milwaukee=' + Milwaukee.length);
Milwaukee[Milwaukee.length] = createMarker(new GPoint(-88.05270300,43.09935300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Aemilian Preschool",'Milwaukee=' + Milwaukee.length);
Milwaukee[Milwaukee.length] = createMarker(new GPoint(-87.91142000,43.07609600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Malaika Early Learning Center",'Milwaukee=' + Milwaukee.length);
Milwaukee[Milwaukee.length] = createMarker(new GPoint(-87.96384500,43.11276700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Howard's Learning Academy",'Milwaukee=' + Milwaukee.length);
Oconomowoc[Oconomowoc.length] = createMarker(new GPoint(-88.49912700,43.11374500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mary Linsmeier Schools",'Oconomowoc=' + Oconomowoc.length);
Oshkosh[Oshkosh.length] = createMarker(new GPoint(-88.58289000,44.01492100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wee Wisdom Day Care Center",'Oshkosh=' + Oshkosh.length);
Racine[Racine.length] = createMarker(new GPoint(-87.83791700,42.68746800),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Racine Baptist School",'Racine=' + Racine.length);
Slinger[Slinger.length] = createMarker(new GPoint(-88.27224100,43.32756900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Paul Little Learners Preschool & Kindergarten",'Slinger=' + Slinger.length);
Stone_Lake[Stone_Lake.length] = createMarker(new GPoint(-91.53786900,45.84313800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Green Eggs & Ham Montessori School",'Stone_Lake=' + Stone_Lake.length);
Sussex[Sussex.length] = createMarker(new GPoint(-88.20854900,43.13370000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Quad Care Sussex",'Sussex=' + Sussex.length);
West_Allis[West_Allis.length] = createMarker(new GPoint(-87.99731100,42.99906300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Early Childhood Center",'West_Allis=' + West_Allis.length);
Wisconsin_Rapids[Wisconsin_Rapids.length] = createMarker(new GPoint(-89.83549200,44.39962600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Lawrence Early Childhood Center",'Wisconsin_Rapids=' + Wisconsin_Rapids.length);
map.removeOverlays(Appleton);
map.removeOverlays(Brookfield);
map.removeOverlays(Franklin);
map.removeOverlays(Green_Bay);
map.removeOverlays(Madison);
map.removeOverlays(Milwaukee);
map.removeOverlays(Oconomowoc);
map.removeOverlays(Oshkosh);
map.removeOverlays(Racine);
map.removeOverlays(Slinger);
map.removeOverlays(Stone_Lake);
map.removeOverlays(Sussex);
map.removeOverlays(West_Allis);
map.removeOverlays(Wisconsin_Rapids);
setTimeout(function(){map.addOverlays(Appleton)},1000);
setTimeout(function(){map.addOverlays(Brookfield)},1000);
setTimeout(function(){map.addOverlays(Franklin)},1000);
setTimeout(function(){map.addOverlays(Green_Bay)},1000);
setTimeout(function(){map.addOverlays(Madison)},1000);
setTimeout(function(){map.addOverlays(Milwaukee)},1000);
setTimeout(function(){map.addOverlays(Oconomowoc)},1000);
setTimeout(function(){map.addOverlays(Oshkosh)},1000);
setTimeout(function(){map.addOverlays(Racine)},1000);
setTimeout(function(){map.addOverlays(Slinger)},1000);
setTimeout(function(){map.addOverlays(Stone_Lake)},1000);
setTimeout(function(){map.addOverlays(Sussex)},1000);
setTimeout(function(){map.addOverlays(West_Allis)},1000);
setTimeout(function(){map.addOverlays(Wisconsin_Rapids)},1000);
maxLng = -87.83791700;
maxLat = 45.84313800;
minLng = -91.53786900;
minLat = 42.68746800;
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(Appleton);
map.removeOverlays(Brookfield);
map.removeOverlays(Franklin);
map.removeOverlays(Green_Bay);
map.removeOverlays(Madison);
map.removeOverlays(Milwaukee);
map.removeOverlays(Oconomowoc);
map.removeOverlays(Oshkosh);
map.removeOverlays(Racine);
map.removeOverlays(Slinger);
map.removeOverlays(Stone_Lake);
map.removeOverlays(Sussex);
map.removeOverlays(West_Allis);
map.removeOverlays(Wisconsin_Rapids);
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(Appleton);map.removeOverlays(Appleton);
map.removeOverlays(Brookfield);
map.removeOverlays(Franklin);
map.removeOverlays(Green_Bay);
map.removeOverlays(Madison);
map.removeOverlays(Milwaukee);
map.removeOverlays(Oconomowoc);
map.removeOverlays(Oshkosh);
map.removeOverlays(Racine);
map.removeOverlays(Slinger);
map.removeOverlays(Stone_Lake);
map.removeOverlays(Sussex);
map.removeOverlays(West_Allis);
map.removeOverlays(Wisconsin_Rapids);
map.addOverlays(Appleton);
centerByArray(Appleton, false, false);
cntMarker += Appleton.length;
map.addOverlays(Brookfield);
centerByArray(Brookfield, false, false);
cntMarker += Brookfield.length;
map.addOverlays(Franklin);
centerByArray(Franklin, false, false);
cntMarker += Franklin.length;
map.addOverlays(Green_Bay);
centerByArray(Green_Bay, false, false);
cntMarker += Green_Bay.length;
map.addOverlays(Madison);
centerByArray(Madison, false, false);
cntMarker += Madison.length;
map.addOverlays(Milwaukee);
centerByArray(Milwaukee, false, false);
cntMarker += Milwaukee.length;
map.addOverlays(Oconomowoc);
centerByArray(Oconomowoc, false, false);
cntMarker += Oconomowoc.length;
map.addOverlays(Oshkosh);
centerByArray(Oshkosh, false, false);
cntMarker += Oshkosh.length;
map.addOverlays(Racine);
centerByArray(Racine, false, false);
cntMarker += Racine.length;
map.addOverlays(Slinger);
centerByArray(Slinger, false, false);
cntMarker += Slinger.length;
map.addOverlays(Stone_Lake);
centerByArray(Stone_Lake, false, false);
cntMarker += Stone_Lake.length;
map.addOverlays(Sussex);
centerByArray(Sussex, false, false);
cntMarker += Sussex.length;
map.addOverlays(West_Allis);
centerByArray(West_Allis, false, false);
cntMarker += West_Allis.length;
map.addOverlays(Wisconsin_Rapids);
centerByArray(Wisconsin_Rapids, false, false);
cntMarker += Wisconsin_Rapids.length;
centerByArray(Appleton,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=2&schools=&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;
}