function addMarkers(){
mySelect = document.getElementById('selection');
Sheboygan = [];Plymouth = [];Oostburg = [];Random_Lake = [];Howards_Grove = [];Sheboygan_Falls = [];mySelect.options[mySelect.options.length] = new Option("Howards Grove schools",'all=Howards_Grove');
mySelect.options[mySelect.options.length] = new Option("Oostburg schools",'all=Oostburg');
mySelect.options[mySelect.options.length] = new Option("Plymouth schools",'all=Plymouth');
mySelect.options[mySelect.options.length] = new Option("Random Lake schools",'all=Random_Lake');
mySelect.options[mySelect.options.length] = new Option("Sheboygan schools",'all=Sheboygan');
mySelect.options[mySelect.options.length] = new Option("Sheboygan Falls schools",'all=Sheboygan_Falls');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Sheboygan[Sheboygan.length] = createMarker(new GPoint(-87.71837000,43.73976300),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethlehem Lutheran School",'Sheboygan=' + Sheboygan.length);
Sheboygan[Sheboygan.length] = createMarker(new GPoint(-87.74138900,43.76769500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calvary Evang Lutheran School",'Sheboygan=' + Sheboygan.length);
Sheboygan[Sheboygan.length] = createMarker(new GPoint(-87.71940900,43.73910800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christ Child Academy",'Sheboygan=' + Sheboygan.length);
Sheboygan[Sheboygan.length] = createMarker(new GPoint(-87.72240100,43.72567400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christ Child Academy (middle School",'Sheboygan=' + Sheboygan.length);
Sheboygan[Sheboygan.length] = createMarker(new GPoint(-87.72579600,43.76416300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cornerstone Christian Academy",'Sheboygan=' + Sheboygan.length);
Sheboygan[Sheboygan.length] = createMarker(new GPoint(-87.73988900,43.75103500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ebenezer Christian School",'Sheboygan=' + Sheboygan.length);
Plymouth[Plymouth.length] = createMarker(new GPoint(-87.98611000,43.76102000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Christian Academy",'Plymouth=' + Plymouth.length);
Sheboygan[Sheboygan.length] = createMarker(new GPoint(-87.71329900,43.76085900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Family School",'Sheboygan=' + Sheboygan.length);
Sheboygan[Sheboygan.length] = createMarker(new GPoint(-87.72681000,43.74443700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Immanuel Lutheran School",'Sheboygan=' + Sheboygan.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);
Sheboygan[Sheboygan.length] = createMarker(new GPoint(-87.76148600,43.79496300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lake Country Academy",'Sheboygan=' + Sheboygan.length);
Sheboygan[Sheboygan.length] = createMarker(new GPoint(-87.74700900,43.75911600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Landmark Christian Academy",'Sheboygan=' + Sheboygan.length);
Sheboygan[Sheboygan.length] = createMarker(new GPoint(-87.73245500,43.76591800),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Montessori Childrens House",'Sheboygan=' + Sheboygan.length);
Sheboygan[Sheboygan.length] = createMarker(new GPoint(-87.72104600,43.70203700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New World Montessori School",'Sheboygan=' + Sheboygan.length);
Oostburg[Oostburg.length] = createMarker(new GPoint(-87.79583900,43.61901500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Oostburg Christian School",'Oostburg=' + Oostburg.length);
Random_Lake[Random_Lake.length] = createMarker(new GPoint(-87.96081000,43.55228700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of The Lakes School",'Random_Lake=' + Random_Lake.length);
Sheboygan[Sheboygan.length] = createMarker(new GPoint(-87.73408900,43.76732000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Dominic Elementary School",'Sheboygan=' + Sheboygan.length);
Random_Lake[Random_Lake.length] = createMarker(new GPoint(-87.96611000,43.58640000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. John Lutheran School",'Random_Lake=' + Random_Lake.length);
Plymouth[Plymouth.length] = createMarker(new GPoint(-87.97751600,43.74903500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. John Lutheran School",'Plymouth=' + Plymouth.length);
Howards_Grove[Howards_Grove.length] = createMarker(new GPoint(-87.81369300,43.81906300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Pauls Lutheran School",'Howards_Grove=' + Howards_Grove.length);
Sheboygan[Sheboygan.length] = createMarker(new GPoint(-87.70664100,43.76847700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sheboygan Christian School",'Sheboygan=' + Sheboygan.length);
Plymouth[Plymouth.length] = createMarker(new GPoint(-87.98388900,43.74778700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St John The Baptist Catholic School",'Plymouth=' + Plymouth.length);
Sheboygan_Falls[Sheboygan_Falls.length] = createMarker(new GPoint(-87.81535300,43.72379900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Mary S School",'Sheboygan_Falls=' + Sheboygan_Falls.length);
Sheboygan[Sheboygan.length] = createMarker(new GPoint(-87.72180900,43.76424100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Paul Lutheran School",'Sheboygan=' + Sheboygan.length);
Sheboygan[Sheboygan.length] = createMarker(new GPoint(-87.71348500,43.75323700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Lutheran School",'Sheboygan=' + Sheboygan.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/////1/' + showArray);
map.removeOverlays(Howards_Grove);
map.removeOverlays(Oostburg);
map.removeOverlays(Plymouth);
map.removeOverlays(Random_Lake);
map.removeOverlays(Sheboygan);
map.removeOverlays(Sheboygan_Falls);
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(Sheboygan);map.removeOverlays(Howards_Grove);
map.removeOverlays(Oostburg);
map.removeOverlays(Plymouth);
map.removeOverlays(Random_Lake);
map.removeOverlays(Sheboygan);
map.removeOverlays(Sheboygan_Falls);
map.addOverlays(Howards_Grove);
centerByArray(Howards_Grove, false, false);
cntMarker += Howards_Grove.length;
map.addOverlays(Oostburg);
centerByArray(Oostburg, false, false);
cntMarker += Oostburg.length;
map.addOverlays(Plymouth);
centerByArray(Plymouth, false, false);
cntMarker += Plymouth.length;
map.addOverlays(Random_Lake);
centerByArray(Random_Lake, false, false);
cntMarker += Random_Lake.length;
map.addOverlays(Sheboygan);
centerByArray(Sheboygan, false, false);
cntMarker += Sheboygan.length;
map.addOverlays(Sheboygan_Falls);
centerByArray(Sheboygan_Falls, false, false);
cntMarker += Sheboygan_Falls.length;
centerByArray(Sheboygan,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=1&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;
}