function addMarkers(){
mySelect = document.getElementById('selection');
Manitowoc = [];Two_Rivers = [];Mishicot = [];Reedsville = [];Francis_Creek = [];Kiel = [];Saint_Nazianz = [];Maribel = [];Cato = [];Whitelaw = [];mySelect.options[mySelect.options.length] = new Option("Cato schools",'all=Cato');
mySelect.options[mySelect.options.length] = new Option("Francis Creek schools",'all=Francis_Creek');
mySelect.options[mySelect.options.length] = new Option("Kiel schools",'all=Kiel');
mySelect.options[mySelect.options.length] = new Option("Manitowoc schools",'all=Manitowoc');
mySelect.options[mySelect.options.length] = new Option("Maribel schools",'all=Maribel');
mySelect.options[mySelect.options.length] = new Option("Mishicot schools",'all=Mishicot');
mySelect.options[mySelect.options.length] = new Option("Reedsville schools",'all=Reedsville');
mySelect.options[mySelect.options.length] = new Option("Saint Nazianz schools",'all=Saint_Nazianz');
mySelect.options[mySelect.options.length] = new Option("Two Rivers schools",'all=Two_Rivers');
mySelect.options[mySelect.options.length] = new Option("Whitelaw schools",'all=Whitelaw');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Manitowoc[Manitowoc.length] = createMarker(new GPoint(-87.65500800,44.11585700),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ashling Montessori School Inc",'Manitowoc=' + Manitowoc.length);
Manitowoc[Manitowoc.length] = createMarker(new GPoint(-87.68781600,44.09530000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethany Ev Lutheran School",'Manitowoc=' + Manitowoc.length);
Two_Rivers[Two_Rivers.length] = createMarker(new GPoint(-87.60923800,44.12858100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Childrens House Of Manitowoc",'Two_Rivers=' + Two_Rivers.length);
Mishicot[Mishicot.length] = createMarker(new GPoint(-87.63997400,44.24063700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("East Twin Lutheran School",'Mishicot=' + Mishicot.length);
Manitowoc[Manitowoc.length] = createMarker(new GPoint(-87.65760800,44.08783800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("First German Evangelical Lutheran School",'Manitowoc=' + Manitowoc.length);
Mishicot[Mishicot.length] = createMarker(new GPoint(-87.63961600,44.23333700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Cross Elementary School",'Mishicot=' + Mishicot.length);
Reedsville[Reedsville.length] = createMarker(new GPoint(-87.96057400,44.15443700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Family School",'Reedsville=' + Reedsville.length);
Manitowoc[Manitowoc.length] = createMarker(new GPoint(-87.65943800,44.10702700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Immanuel Evang Lutheran School",'Manitowoc=' + Manitowoc.length);
Francis_Creek[Francis_Creek.length] = createMarker(new GPoint(-87.72130000,44.20300000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Anne Elementary School",'Francis_Creek=' + Francis_Creek.length);
Manitowoc[Manitowoc.length] = createMarker(new GPoint(-87.67505500,44.08706300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Frances Cabrini Middle School",'Manitowoc=' + Manitowoc.length);
Manitowoc[Manitowoc.length] = createMarker(new GPoint(-87.66594700,44.10843700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Francis De Sales Elementary School",'Manitowoc=' + Manitowoc.length);
Manitowoc[Manitowoc.length] = createMarker(new GPoint(-87.66667600,44.07693700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Francis Xavier School",'Manitowoc=' + Manitowoc.length);
Two_Rivers[Two_Rivers.length] = createMarker(new GPoint(-87.59525700,44.17496300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Johns Lutheran School",'Two_Rivers=' + Two_Rivers.length);
Two_Rivers[Two_Rivers.length] = createMarker(new GPoint(-87.57871400,44.14406300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Peter The Fisherman School",'Two_Rivers=' + Two_Rivers.length);
Kiel[Kiel.length] = createMarker(new GPoint(-88.03478800,43.91229600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ss Peter & Paul Elementary School",'Kiel=' + Kiel.length);
Saint_Nazianz[Saint_Nazianz.length] = createMarker(new GPoint(-87.92300000,44.00520000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Gregory School",'Saint_Nazianz=' + Saint_Nazianz.length);
Maribel[Maribel.length] = createMarker(new GPoint(-87.80687800,44.27125900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St John Lutheran School",'Maribel=' + Maribel.length);
Reedsville[Reedsville.length] = createMarker(new GPoint(-87.94885200,44.15316300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St John-st James Lutheran School",'Reedsville=' + Reedsville.length);
Manitowoc[Manitowoc.length] = createMarker(new GPoint(-87.69310000,44.10060000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Johns Lutheran School",'Manitowoc=' + Manitowoc.length);
Cato[Cato.length] = createMarker(new GPoint(-87.86224400,44.09488600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Mary Elementary School",'Cato=' + Cato.length);
Whitelaw[Whitelaw.length] = createMarker(new GPoint(-87.79110000,44.18720000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Mary's & St Michael's Elementary School",'Whitelaw=' + Whitelaw.length);
Manitowoc[Manitowoc.length] = createMarker(new GPoint(-87.69310000,44.10060000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Christian School",'Manitowoc=' + Manitowoc.length);
Kiel[Kiel.length] = createMarker(new GPoint(-88.03292300,43.91253700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Lutheran School",'Kiel=' + Kiel.length);
Manitowoc[Manitowoc.length] = createMarker(new GPoint(-87.81998100,44.03678000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Lutheran School",'Manitowoc=' + Manitowoc.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(Cato);
map.removeOverlays(Francis_Creek);
map.removeOverlays(Kiel);
map.removeOverlays(Manitowoc);
map.removeOverlays(Maribel);
map.removeOverlays(Mishicot);
map.removeOverlays(Reedsville);
map.removeOverlays(Saint_Nazianz);
map.removeOverlays(Two_Rivers);
map.removeOverlays(Whitelaw);
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(Manitowoc);map.removeOverlays(Cato);
map.removeOverlays(Francis_Creek);
map.removeOverlays(Kiel);
map.removeOverlays(Manitowoc);
map.removeOverlays(Maribel);
map.removeOverlays(Mishicot);
map.removeOverlays(Reedsville);
map.removeOverlays(Saint_Nazianz);
map.removeOverlays(Two_Rivers);
map.removeOverlays(Whitelaw);
map.addOverlays(Cato);
centerByArray(Cato, false, false);
cntMarker += Cato.length;
map.addOverlays(Francis_Creek);
centerByArray(Francis_Creek, false, false);
cntMarker += Francis_Creek.length;
map.addOverlays(Kiel);
centerByArray(Kiel, false, false);
cntMarker += Kiel.length;
map.addOverlays(Manitowoc);
centerByArray(Manitowoc, false, false);
cntMarker += Manitowoc.length;
map.addOverlays(Maribel);
centerByArray(Maribel, false, false);
cntMarker += Maribel.length;
map.addOverlays(Mishicot);
centerByArray(Mishicot, false, false);
cntMarker += Mishicot.length;
map.addOverlays(Reedsville);
centerByArray(Reedsville, false, false);
cntMarker += Reedsville.length;
map.addOverlays(Saint_Nazianz);
centerByArray(Saint_Nazianz, false, false);
cntMarker += Saint_Nazianz.length;
map.addOverlays(Two_Rivers);
centerByArray(Two_Rivers, false, false);
cntMarker += Two_Rivers.length;
map.addOverlays(Whitelaw);
centerByArray(Whitelaw, false, false);
cntMarker += Whitelaw.length;
centerByArray(Manitowoc,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;
}