function addMarkers(){
mySelect = document.getElementById('selection');
Cedar_Rapids = [];Walker = [];Hiawatha = [];Marion = [];mySelect.options[mySelect.options.length] = new Option("Cedar Rapids schools",'all=Cedar_Rapids');
mySelect.options[mySelect.options.length] = new Option("Hiawatha schools",'all=Hiawatha');
mySelect.options[mySelect.options.length] = new Option("Marion schools",'all=Marion');
mySelect.options[mySelect.options.length] = new Option("Walker schools",'all=Walker');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Cedar_Rapids[Cedar_Rapids.length] = createMarker(new GPoint(-91.62557500,41.97856300),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("All Saints School",'Cedar_Rapids=' + Cedar_Rapids.length);
Cedar_Rapids[Cedar_Rapids.length] = createMarker(new GPoint(-91.61524100,41.99526800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cedar Valley Christian School",'Cedar_Rapids=' + Cedar_Rapids.length);
Walker[Walker.length] = createMarker(new GPoint(-91.77397200,42.31642500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cono Christian School",'Walker=' + Walker.length);
Hiawatha[Hiawatha.length] = createMarker(new GPoint(-91.68926700,42.03498100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Essential Montessori",'Hiawatha=' + Hiawatha.length);
Cedar_Rapids[Cedar_Rapids.length] = createMarker(new GPoint(-91.68405100,42.02183700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Good Shepherd Lutheran School",'Cedar_Rapids=' + Cedar_Rapids.length);
Marion[Marion.length] = createMarker(new GPoint(-91.59923100,42.01571900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grace Baptist Academy",'Marion=' + Marion.length);
Cedar_Rapids[Cedar_Rapids.length] = createMarker(new GPoint(-91.65196200,42.02276300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holloway House",'Cedar_Rapids=' + Cedar_Rapids.length);
Cedar_Rapids[Cedar_Rapids.length] = createMarker(new GPoint(-91.66521100,41.95766300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Family School St Ludmila Center",'Cedar_Rapids=' + Cedar_Rapids.length);
Cedar_Rapids[Cedar_Rapids.length] = createMarker(new GPoint(-91.67210900,42.00562200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Isaac Newton Christian Academy",'Cedar_Rapids=' + Cedar_Rapids.length);
Cedar_Rapids[Cedar_Rapids.length] = createMarker(new GPoint(-91.70661000,42.06393100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jn Andrews Christian Academy",'Cedar_Rapids=' + Cedar_Rapids.length);
Cedar_Rapids[Cedar_Rapids.length] = createMarker(new GPoint(-91.72011700,41.96759900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("LaSalle Middle School",'Cedar_Rapids=' + Cedar_Rapids.length);
Cedar_Rapids[Cedar_Rapids.length] = createMarker(new GPoint(-91.64702700,42.00245000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Regis Middle School",'Cedar_Rapids=' + Cedar_Rapids.length);
Marion[Marion.length] = createMarker(new GPoint(-91.59487700,42.03955500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Joseph School",'Marion=' + Marion.length);
Cedar_Rapids[Cedar_Rapids.length] = createMarker(new GPoint(-91.72013800,41.96763700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Jude Elementary School",'Cedar_Rapids=' + Cedar_Rapids.length);
Cedar_Rapids[Cedar_Rapids.length] = createMarker(new GPoint(-91.63648500,42.00030700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Matthew School",'Cedar_Rapids=' + Cedar_Rapids.length);
Cedar_Rapids[Cedar_Rapids.length] = createMarker(new GPoint(-91.67891400,41.97561100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Patrick Middle School",'Cedar_Rapids=' + Cedar_Rapids.length);
Cedar_Rapids[Cedar_Rapids.length] = createMarker(new GPoint(-91.67908400,41.97585500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Patricks Child Care Center",'Cedar_Rapids=' + Cedar_Rapids.length);
Cedar_Rapids[Cedar_Rapids.length] = createMarker(new GPoint(-91.65848400,42.02763800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Pius X Elementary School",'Cedar_Rapids=' + Cedar_Rapids.length);
Cedar_Rapids[Cedar_Rapids.length] = createMarker(new GPoint(-91.64838000,42.02422200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Summit Schools Inc",'Cedar_Rapids=' + Cedar_Rapids.length);
Cedar_Rapids[Cedar_Rapids.length] = createMarker(new GPoint(-91.69013700,41.96976300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Lutheran School",'Cedar_Rapids=' + Cedar_Rapids.length);
Cedar_Rapids[Cedar_Rapids.length] = createMarker(new GPoint(-91.72330900,42.02289200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Xavier High School",'Cedar_Rapids=' + Cedar_Rapids.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(Cedar_Rapids);
map.removeOverlays(Hiawatha);
map.removeOverlays(Marion);
map.removeOverlays(Walker);
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(Cedar_Rapids);map.removeOverlays(Cedar_Rapids);
map.removeOverlays(Hiawatha);
map.removeOverlays(Marion);
map.removeOverlays(Walker);
map.addOverlays(Cedar_Rapids);
centerByArray(Cedar_Rapids, false, false);
cntMarker += Cedar_Rapids.length;
map.addOverlays(Hiawatha);
centerByArray(Hiawatha, false, false);
cntMarker += Hiawatha.length;
map.addOverlays(Marion);
centerByArray(Marion, false, false);
cntMarker += Marion.length;
map.addOverlays(Walker);
centerByArray(Walker, false, false);
cntMarker += Walker.length;
centerByArray(Cedar_Rapids,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;
}