function addMarkers(){
mySelect = document.getElementById('selection');
Wausau = [];Marshfield = [];Rothschild = [];Mosinee = [];Schofield = [];Athens = [];Hatley = [];Edgar = [];Stratford = [];Marathon = [];mySelect.options[mySelect.options.length] = new Option("Athens schools",'all=Athens');
mySelect.options[mySelect.options.length] = new Option("Edgar schools",'all=Edgar');
mySelect.options[mySelect.options.length] = new Option("Hatley schools",'all=Hatley');
mySelect.options[mySelect.options.length] = new Option("Marathon schools",'all=Marathon');
mySelect.options[mySelect.options.length] = new Option("Marshfield schools",'all=Marshfield');
mySelect.options[mySelect.options.length] = new Option("Mosinee schools",'all=Mosinee');
mySelect.options[mySelect.options.length] = new Option("Rothschild schools",'all=Rothschild');
mySelect.options[mySelect.options.length] = new Option("Schofield schools",'all=Schofield');
mySelect.options[mySelect.options.length] = new Option("Stratford schools",'all=Stratford');
mySelect.options[mySelect.options.length] = new Option("Wausau schools",'all=Wausau');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Wausau[Wausau.length] = createMarker(new GPoint(-89.57310000,44.90340000),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Christian Academy",'Wausau=' + Wausau.length);
Wausau[Wausau.length] = createMarker(new GPoint(-89.67001500,44.89984600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hillside Christian School",'Wausau=' + Wausau.length);
Wausau[Wausau.length] = createMarker(new GPoint(-89.64679300,44.94796800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Name Of Jesus Catholic School",'Wausau=' + Wausau.length);
Marshfield[Marshfield.length] = createMarker(new GPoint(-90.20676600,44.69240400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Marshfield Christian School",'Marshfield=' + Marshfield.length);
Wausau[Wausau.length] = createMarker(new GPoint(-89.63881600,44.95213700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Childrens Village",'Wausau=' + Wausau.length);
Wausau[Wausau.length] = createMarker(new GPoint(-89.65978700,44.95716300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School Of Wausau",'Wausau=' + Wausau.length);
Rothschild[Rothschild.length] = createMarker(new GPoint(-89.61812300,44.88023700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Newman Catholic Elementary School At St. Mark",'Rothschild=' + Rothschild.length);
Wausau[Wausau.length] = createMarker(new GPoint(-89.62286300,44.96753700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Newman Catholic School At St Michael",'Wausau=' + Wausau.length);
Wausau[Wausau.length] = createMarker(new GPoint(-89.67065800,44.96162700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Norman Catholic Middle School At St Matthew",'Wausau=' + Wausau.length);
Mosinee[Mosinee.length] = createMarker(new GPoint(-89.62939300,44.84417700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northland Lutheran High School",'Mosinee=' + Mosinee.length);
Wausau[Wausau.length] = createMarker(new GPoint(-89.64408600,44.94136300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Saviors Lutheran School",'Wausau=' + Wausau.length);
Wausau[Wausau.length] = createMarker(new GPoint(-89.64863000,44.90984000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rib Mountain Montessori",'Wausau=' + Wausau.length);
Wausau[Wausau.length] = createMarker(new GPoint(-89.64289300,44.97017500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Anne School",'Wausau=' + Wausau.length);
Mosinee[Mosinee.length] = createMarker(new GPoint(-89.70561200,44.79121700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Paul Catholic Grade School",'Mosinee=' + Mosinee.length);
Schofield[Schofield.length] = createMarker(new GPoint(-89.61468300,44.90183700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Therese School",'Schofield=' + Schofield.length);
Athens[Athens.length] = createMarker(new GPoint(-90.03860000,45.03970000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Anthony School",'Athens=' + Athens.length);
Hatley[Hatley.length] = createMarker(new GPoint(-89.37700000,44.82650000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Florian Elementary School",'Hatley=' + Hatley.length);
Edgar[Edgar.length] = createMarker(new GPoint(-89.96539900,44.92310500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St John The Baptist Catholic School",'Edgar=' + Edgar.length);
Wausau[Wausau.length] = createMarker(new GPoint(-89.48736800,44.98866000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St John Lutheran School",'Wausau=' + Wausau.length);
Stratford[Stratford.length] = createMarker(new GPoint(-90.07370000,44.80413700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Joseph School",'Stratford=' + Stratford.length);
Marathon[Marathon.length] = createMarker(new GPoint(-89.83630000,44.93670000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Mary Elementary School",'Marathon=' + Marathon.length);
Schofield[Schofield.length] = createMarker(new GPoint(-89.61164800,44.91158500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Peter Lutheran School",'Schofield=' + Schofield.length);
Athens[Athens.length] = createMarker(new GPoint(-90.03860000,45.03970000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Lutheran School",'Athens=' + Athens.length);
Wausau[Wausau.length] = createMarker(new GPoint(-89.64189400,44.95906300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Lutheran School",'Wausau=' + Wausau.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(Athens);
map.removeOverlays(Edgar);
map.removeOverlays(Hatley);
map.removeOverlays(Marathon);
map.removeOverlays(Marshfield);
map.removeOverlays(Mosinee);
map.removeOverlays(Rothschild);
map.removeOverlays(Schofield);
map.removeOverlays(Stratford);
map.removeOverlays(Wausau);
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(Wausau);map.removeOverlays(Athens);
map.removeOverlays(Edgar);
map.removeOverlays(Hatley);
map.removeOverlays(Marathon);
map.removeOverlays(Marshfield);
map.removeOverlays(Mosinee);
map.removeOverlays(Rothschild);
map.removeOverlays(Schofield);
map.removeOverlays(Stratford);
map.removeOverlays(Wausau);
map.addOverlays(Athens);
centerByArray(Athens, false, false);
cntMarker += Athens.length;
map.addOverlays(Edgar);
centerByArray(Edgar, false, false);
cntMarker += Edgar.length;
map.addOverlays(Hatley);
centerByArray(Hatley, false, false);
cntMarker += Hatley.length;
map.addOverlays(Marathon);
centerByArray(Marathon, false, false);
cntMarker += Marathon.length;
map.addOverlays(Marshfield);
centerByArray(Marshfield, false, false);
cntMarker += Marshfield.length;
map.addOverlays(Mosinee);
centerByArray(Mosinee, false, false);
cntMarker += Mosinee.length;
map.addOverlays(Rothschild);
centerByArray(Rothschild, false, false);
cntMarker += Rothschild.length;
map.addOverlays(Schofield);
centerByArray(Schofield, false, false);
cntMarker += Schofield.length;
map.addOverlays(Stratford);
centerByArray(Stratford, false, false);
cntMarker += Stratford.length;
map.addOverlays(Wausau);
centerByArray(Wausau, false, false);
cntMarker += Wausau.length;
centerByArray(Wausau,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;
}