function addMarkers(){
mySelect = document.getElementById('selection');
Cascade = [];Sherrill = [];Dyersville = [];Dubuque = [];New_Vienna = [];Luxemburg = [];Holy_Cross = [];Epworth = [];Farley = [];Peosta = [];Worthington = [];mySelect.options[mySelect.options.length] = new Option("Cascade schools",'all=Cascade');
mySelect.options[mySelect.options.length] = new Option("Dubuque schools",'all=Dubuque');
mySelect.options[mySelect.options.length] = new Option("Dyersville schools",'all=Dyersville');
mySelect.options[mySelect.options.length] = new Option("Epworth schools",'all=Epworth');
mySelect.options[mySelect.options.length] = new Option("Farley schools",'all=Farley');
mySelect.options[mySelect.options.length] = new Option("Holy Cross schools",'all=Holy_Cross');
mySelect.options[mySelect.options.length] = new Option("Luxemburg schools",'all=Luxemburg');
mySelect.options[mySelect.options.length] = new Option("New Vienna schools",'all=New_Vienna');
mySelect.options[mySelect.options.length] = new Option("Peosta schools",'all=Peosta');
mySelect.options[mySelect.options.length] = new Option("Sherrill schools",'all=Sherrill');
mySelect.options[mySelect.options.length] = new Option("Worthington schools",'all=Worthington');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Cascade[Cascade.length] = createMarker(new GPoint(-91.02046900,42.29913700),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Aquin Catholic Elementary School",'Cascade=' + Cascade.length);
Sherrill[Sherrill.length] = createMarker(new GPoint(-90.82750000,42.62540000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Balltown-sherrill Catholic School",'Sherrill=' + Sherrill.length);
Dyersville[Dyersville.length] = createMarker(new GPoint(-91.11411300,42.47286600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Beckman Jr Sr High School",'Dyersville=' + Dyersville.length);
Dubuque[Dubuque.length] = createMarker(new GPoint(-90.72063500,42.50925700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Dubuque Lutheran School",'Dubuque=' + Dubuque.length);
Dubuque[Dubuque.length] = createMarker(new GPoint(-90.70312700,42.50036200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Dubuque Montessori School",'Dubuque=' + Dubuque.length);
Dubuque[Dubuque.length] = createMarker(new GPoint(-90.73008900,42.52889000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grand View Preschool & Child Development Center",'Dubuque=' + Dubuque.length);
Dyersville[Dyersville.length] = createMarker(new GPoint(-91.21341500,42.55601800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hennessey Catholic School Pete",'Dyersville=' + Dyersville.length);
New_Vienna[New_Vienna.length] = createMarker(new GPoint(-91.10670000,42.56310000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hennessy Catholic School",'New_Vienna=' + New_Vienna.length);
Dubuque[Dubuque.length] = createMarker(new GPoint(-90.68027200,42.52444800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Ghost Elementary School",'Dubuque=' + Dubuque.length);
Luxemburg[Luxemburg.length] = createMarker(new GPoint(-91.07450000,42.60310000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lasalle Catholic",'Luxemburg=' + Luxemburg.length);
Holy_Cross[Holy_Cross.length] = createMarker(new GPoint(-90.99670400,42.60032500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lasalle Catholic School",'Holy_Cross=' + Holy_Cross.length);
Dubuque[Dubuque.length] = createMarker(new GPoint(-90.67884500,42.49917900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Nativity Grade School",'Dubuque=' + Dubuque.length);
Dubuque[Dubuque.length] = createMarker(new GPoint(-90.73510600,42.51515600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Resurrection School",'Dubuque=' + Dubuque.length);
Dubuque[Dubuque.length] = createMarker(new GPoint(-90.69732300,42.50410400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Anthony School",'Dubuque=' + Dubuque.length);
Dubuque[Dubuque.length] = createMarker(new GPoint(-90.66678000,42.51635800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Francis Primary",'Dubuque=' + Dubuque.length);
Dubuque[Dubuque.length] = createMarker(new GPoint(-90.69323400,42.49093600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Joseph The Worker School",'Dubuque=' + Dubuque.length);
Dubuque[Dubuque.length] = createMarker(new GPoint(-90.66990300,42.50649100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Mary-st. Patrick School",'Dubuque=' + Dubuque.length);
Epworth[Epworth.length] = createMarker(new GPoint(-90.93230000,42.44770000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Seton Catholic Elem. School",'Epworth=' + Epworth.length);
Epworth[Epworth.length] = createMarker(new GPoint(-90.93337600,42.44684900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Seton Catholic Elementary School Epworth Center",'Epworth=' + Epworth.length);
Farley[Farley.length] = createMarker(new GPoint(-91.00462900,42.44166300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Seton Catholic School",'Farley=' + Farley.length);
Peosta[Peosta.length] = createMarker(new GPoint(-90.85058500,42.44059000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Seton Catholic-st John",'Peosta=' + Peosta.length);
Dubuque[Dubuque.length] = createMarker(new GPoint(-90.67514800,42.48642500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Columbkille School",'Dubuque=' + Dubuque.length);
Dyersville[Dyersville.length] = createMarker(new GPoint(-91.12561300,42.48344700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Francis Xavier Elementary School",'Dyersville=' + Dyersville.length);
Dubuque[Dubuque.length] = createMarker(new GPoint(-90.68484000,42.44252600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Joseph School-key West",'Dubuque=' + Dubuque.length);
Worthington[Worthington.length] = createMarker(new GPoint(-91.12087300,42.39512400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Paul School",'Worthington=' + Worthington.length);
Dubuque[Dubuque.length] = createMarker(new GPoint(-90.70053800,42.51888500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wahlert High School",'Dubuque=' + Dubuque.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(Cascade);
map.removeOverlays(Dubuque);
map.removeOverlays(Dyersville);
map.removeOverlays(Epworth);
map.removeOverlays(Farley);
map.removeOverlays(Holy_Cross);
map.removeOverlays(Luxemburg);
map.removeOverlays(New_Vienna);
map.removeOverlays(Peosta);
map.removeOverlays(Sherrill);
map.removeOverlays(Worthington);
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(Cascade);map.removeOverlays(Cascade);
map.removeOverlays(Dubuque);
map.removeOverlays(Dyersville);
map.removeOverlays(Epworth);
map.removeOverlays(Farley);
map.removeOverlays(Holy_Cross);
map.removeOverlays(Luxemburg);
map.removeOverlays(New_Vienna);
map.removeOverlays(Peosta);
map.removeOverlays(Sherrill);
map.removeOverlays(Worthington);
map.addOverlays(Cascade);
centerByArray(Cascade, false, false);
cntMarker += Cascade.length;
map.addOverlays(Dubuque);
centerByArray(Dubuque, false, false);
cntMarker += Dubuque.length;
map.addOverlays(Dyersville);
centerByArray(Dyersville, false, false);
cntMarker += Dyersville.length;
map.addOverlays(Epworth);
centerByArray(Epworth, false, false);
cntMarker += Epworth.length;
map.addOverlays(Farley);
centerByArray(Farley, false, false);
cntMarker += Farley.length;
map.addOverlays(Holy_Cross);
centerByArray(Holy_Cross, false, false);
cntMarker += Holy_Cross.length;
map.addOverlays(Luxemburg);
centerByArray(Luxemburg, false, false);
cntMarker += Luxemburg.length;
map.addOverlays(New_Vienna);
centerByArray(New_Vienna, false, false);
cntMarker += New_Vienna.length;
map.addOverlays(Peosta);
centerByArray(Peosta, false, false);
cntMarker += Peosta.length;
map.addOverlays(Sherrill);
centerByArray(Sherrill, false, false);
cntMarker += Sherrill.length;
map.addOverlays(Worthington);
centerByArray(Worthington, false, false);
cntMarker += Worthington.length;
centerByArray(Cascade,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;
}