function addMarkers(){
mySelect = document.getElementById('selection');
Chanhassen = [];Watertown = [];Hamburg = [];Chaska = [];Belle_Plaine = [];Victoria = [];Mayer = [];Norwood_Young_America = [];Waconia = [];Cologne = [];New_Germany = [];mySelect.options[mySelect.options.length] = new Option("Belle Plaine schools",'all=Belle_Plaine');
mySelect.options[mySelect.options.length] = new Option("Chanhassen schools",'all=Chanhassen');
mySelect.options[mySelect.options.length] = new Option("Chaska schools",'all=Chaska');
mySelect.options[mySelect.options.length] = new Option("Cologne schools",'all=Cologne');
mySelect.options[mySelect.options.length] = new Option("Hamburg schools",'all=Hamburg');
mySelect.options[mySelect.options.length] = new Option("Mayer schools",'all=Mayer');
mySelect.options[mySelect.options.length] = new Option("New Germany schools",'all=New_Germany');
mySelect.options[mySelect.options.length] = new Option("Norwood Young America schools",'all=Norwood_Young_America');
mySelect.options[mySelect.options.length] = new Option("Victoria schools",'all=Victoria');
mySelect.options[mySelect.options.length] = new Option("Waconia schools",'all=Waconia');
mySelect.options[mySelect.options.length] = new Option("Watertown schools",'all=Watertown');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Chanhassen[Chanhassen.length] = createMarker(new GPoint(-93.52943700,44.86223300),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chapel Hill Academy",'Chanhassen=' + Chanhassen.length);
Chanhassen[Chanhassen.length] = createMarker(new GPoint(-93.55841400,44.85269000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Children Of Tomorrow",'Chanhassen=' + Chanhassen.length);
Watertown[Watertown.length] = createMarker(new GPoint(-93.84940500,44.97070000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christ Community Lutheran School",'Watertown=' + Watertown.length);
Hamburg[Hamburg.length] = createMarker(new GPoint(-93.98570000,44.73176300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Emanuel Lutheran School",'Hamburg=' + Hamburg.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.60206100,44.78485400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Guardian Angels Elementary School",'Chaska=' + Chaska.length);
Belle_Plaine[Belle_Plaine.length] = createMarker(new GPoint(-93.79524200,44.67337900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Family Academy",'Belle_Plaine=' + Belle_Plaine.length);
Victoria[Victoria.length] = createMarker(new GPoint(-93.64657600,44.85829700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Family Catholic High School",'Victoria=' + Victoria.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.60612700,44.81955600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jonathan Montessori",'Chaska=' + Chaska.length);
Mayer[Mayer.length] = createMarker(new GPoint(-93.88500700,44.88906100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mayer Lutheran High School",'Mayer=' + Mayer.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.68360600,44.77686700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Minnesota Valley Baptist School",'Chaska=' + Chaska.length);
Chanhassen[Chanhassen.length] = createMarker(new GPoint(-93.53305900,44.85420300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Hubert Elementary School",'Chanhassen=' + Chanhassen.length);
Norwood_Young_America[Norwood_Young_America.length] = createMarker(new GPoint(-93.91519600,44.78339400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. John's Lutheran School",'Norwood_Young_America=' + Norwood_Young_America.length);
Waconia[Waconia.length] = createMarker(new GPoint(-93.78542200,44.84917700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Joseph Catholic School",'Waconia=' + Waconia.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.59521100,44.84166900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Southwest Christian High School",'Chaska=' + Chaska.length);
Cologne[Cologne.length] = createMarker(new GPoint(-93.78027400,44.77364500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Bernard Elementary School",'Cologne=' + Cologne.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.59807100,44.78779300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St John's Lutheran School",'Chaska=' + Chaska.length);
New_Germany[New_Germany.length] = createMarker(new GPoint(-93.96548500,44.88386900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Mark Lutheran School",'New_Germany=' + New_Germany.length);
Chaska[Chaska.length] = createMarker(new GPoint(-93.60906600,44.82564800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Step By Step Montessori/chaska",'Chaska=' + Chaska.length);
Waconia[Waconia.length] = createMarker(new GPoint(-93.77681600,44.84804200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Lutheran School",'Waconia=' + Waconia.length);
Mayer[Mayer.length] = createMarker(new GPoint(-93.88959300,44.88619600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Zion Lutheran School",'Mayer=' + Mayer.length);
Cologne[Cologne.length] = createMarker(new GPoint(-93.82890600,44.73633900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Zion Lutheran School",'Cologne=' + Cologne.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/////3/' + showArray);
map.removeOverlays(Belle_Plaine);
map.removeOverlays(Chanhassen);
map.removeOverlays(Chaska);
map.removeOverlays(Cologne);
map.removeOverlays(Hamburg);
map.removeOverlays(Mayer);
map.removeOverlays(New_Germany);
map.removeOverlays(Norwood_Young_America);
map.removeOverlays(Victoria);
map.removeOverlays(Waconia);
map.removeOverlays(Watertown);
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(Chanhassen);map.removeOverlays(Belle_Plaine);
map.removeOverlays(Chanhassen);
map.removeOverlays(Chaska);
map.removeOverlays(Cologne);
map.removeOverlays(Hamburg);
map.removeOverlays(Mayer);
map.removeOverlays(New_Germany);
map.removeOverlays(Norwood_Young_America);
map.removeOverlays(Victoria);
map.removeOverlays(Waconia);
map.removeOverlays(Watertown);
map.addOverlays(Belle_Plaine);
centerByArray(Belle_Plaine, false, false);
cntMarker += Belle_Plaine.length;
map.addOverlays(Chanhassen);
centerByArray(Chanhassen, false, false);
cntMarker += Chanhassen.length;
map.addOverlays(Chaska);
centerByArray(Chaska, false, false);
cntMarker += Chaska.length;
map.addOverlays(Cologne);
centerByArray(Cologne, false, false);
cntMarker += Cologne.length;
map.addOverlays(Hamburg);
centerByArray(Hamburg, false, false);
cntMarker += Hamburg.length;
map.addOverlays(Mayer);
centerByArray(Mayer, false, false);
cntMarker += Mayer.length;
map.addOverlays(New_Germany);
centerByArray(New_Germany, false, false);
cntMarker += New_Germany.length;
map.addOverlays(Norwood_Young_America);
centerByArray(Norwood_Young_America, false, false);
cntMarker += Norwood_Young_America.length;
map.addOverlays(Victoria);
centerByArray(Victoria, false, false);
cntMarker += Victoria.length;
map.addOverlays(Waconia);
centerByArray(Waconia, false, false);
cntMarker += Waconia.length;
map.addOverlays(Watertown);
centerByArray(Watertown, false, false);
cntMarker += Watertown.length;
centerByArray(Chanhassen,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=3&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;
}