function addMarkers(){
mySelect = document.getElementById('selection');
Bettendorf = [];Sioux_City = [];Cedar_Falls = [];Maquoketa = [];Clive = [];Dubuque = [];West_Des_Moines = [];Hiawatha = [];Fairfield = [];Keokuk = [];Council_Bluffs = [];Coralville = [];Newell = [];Davenport = [];Cedar_Rapids = [];Iowa_City = [];mySelect.options[mySelect.options.length] = new Option("Bettendorf schools",'all=Bettendorf');
mySelect.options[mySelect.options.length] = new Option("Cedar Falls schools",'all=Cedar_Falls');
mySelect.options[mySelect.options.length] = new Option("Cedar Rapids schools",'all=Cedar_Rapids');
mySelect.options[mySelect.options.length] = new Option("Clive schools",'all=Clive');
mySelect.options[mySelect.options.length] = new Option("Coralville schools",'all=Coralville');
mySelect.options[mySelect.options.length] = new Option("Council Bluffs schools",'all=Council_Bluffs');
mySelect.options[mySelect.options.length] = new Option("Davenport schools",'all=Davenport');
mySelect.options[mySelect.options.length] = new Option("Dubuque schools",'all=Dubuque');
mySelect.options[mySelect.options.length] = new Option("Fairfield schools",'all=Fairfield');
mySelect.options[mySelect.options.length] = new Option("Hiawatha schools",'all=Hiawatha');
mySelect.options[mySelect.options.length] = new Option("Iowa City schools",'all=Iowa_City');
mySelect.options[mySelect.options.length] = new Option("Keokuk schools",'all=Keokuk');
mySelect.options[mySelect.options.length] = new Option("Maquoketa schools",'all=Maquoketa');
mySelect.options[mySelect.options.length] = new Option("Newell schools",'all=Newell');
mySelect.options[mySelect.options.length] = new Option("Sioux City schools",'all=Sioux_City');
mySelect.options[mySelect.options.length] = new Option("West Des Moines schools",'all=West_Des_Moines');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Bettendorf[Bettendorf.length] = createMarker(new GPoint(-90.48820000,41.55290000),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Bettendorf Kindergar",'Bettendorf=' + Bettendorf.length);
Sioux_City[Sioux_City.length] = createMarker(new GPoint(-96.39610500,42.51210500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Boys & Girls Home & Family Services",'Sioux_City=' + Sioux_City.length);
Cedar_Falls[Cedar_Falls.length] = createMarker(new GPoint(-92.44387200,42.53050000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Casa Montessori School",'Cedar_Falls=' + Cedar_Falls.length);
Maquoketa[Maquoketa.length] = createMarker(new GPoint(-90.67837800,42.06913400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Child Development, Inc.",'Maquoketa=' + Maquoketa.length);
Clive[Clive.length] = createMarker(new GPoint(-93.73383100,41.61106300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Child Time",'Clive=' + Clive.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);
West_Des_Moines[West_Des_Moines.length] = createMarker(new GPoint(-93.73683100,41.60696200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Early Education Center",'West_Des_Moines=' + West_Des_Moines.length);
Hiawatha[Hiawatha.length] = createMarker(new GPoint(-91.68926700,42.03498100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Essential Montessori",'Hiawatha=' + Hiawatha.length);
Bettendorf[Bettendorf.length] = createMarker(new GPoint(-90.49722500,41.55348800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kids Choice",'Bettendorf=' + Bettendorf.length);
Fairfield[Fairfield.length] = createMarker(new GPoint(-91.96627900,41.01479000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Maharishi School Of Enlightenment",'Fairfield=' + Fairfield.length);
Keokuk[Keokuk.length] = createMarker(new GPoint(-91.44742700,40.46521700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Midwest Academy",'Keokuk=' + Keokuk.length);
West_Des_Moines[West_Des_Moines.length] = createMarker(new GPoint(-93.76137400,41.59317300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Children's House",'West_Des_Moines=' + West_Des_Moines.length);
Council_Bluffs[Council_Bluffs.length] = createMarker(new GPoint(-95.80110200,41.25662500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Childrens House",'Council_Bluffs=' + Council_Bluffs.length);
Coralville[Coralville.length] = createMarker(new GPoint(-91.57250200,41.69336300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School-iowa City",'Coralville=' + Coralville.length);
Newell[Newell.length] = createMarker(new GPoint(-94.99383400,42.61690000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Newell Pride & Joy",'Newell=' + Newell.length);
Davenport[Davenport.length] = createMarker(new GPoint(-90.54141600,41.56763700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Quad City Montessori School",'Davenport=' + Davenport.length);
Bettendorf[Bettendorf.length] = createMarker(new GPoint(-90.50686200,41.53015000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rivermont Collegiate",'Bettendorf=' + Bettendorf.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);
West_Des_Moines[West_Des_Moines.length] = createMarker(new GPoint(-93.72739700,41.57716300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sayre Montessori School",'West_Des_Moines=' + West_Des_Moines.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);
Iowa_City[Iowa_City.length] = createMarker(new GPoint(-91.49427100,41.65045500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Willowwind School",'Iowa_City=' + Iowa_City.length);
map.removeOverlays(Bettendorf);
map.removeOverlays(Cedar_Falls);
map.removeOverlays(Cedar_Rapids);
map.removeOverlays(Clive);
map.removeOverlays(Coralville);
map.removeOverlays(Council_Bluffs);
map.removeOverlays(Davenport);
map.removeOverlays(Dubuque);
map.removeOverlays(Fairfield);
map.removeOverlays(Hiawatha);
map.removeOverlays(Iowa_City);
map.removeOverlays(Keokuk);
map.removeOverlays(Maquoketa);
map.removeOverlays(Newell);
map.removeOverlays(Sioux_City);
map.removeOverlays(West_Des_Moines);
setTimeout(function(){map.addOverlays(Bettendorf)},1000);
setTimeout(function(){map.addOverlays(Cedar_Falls)},1000);
setTimeout(function(){map.addOverlays(Cedar_Rapids)},1000);
setTimeout(function(){map.addOverlays(Clive)},1000);
setTimeout(function(){map.addOverlays(Coralville)},1000);
setTimeout(function(){map.addOverlays(Council_Bluffs)},1000);
setTimeout(function(){map.addOverlays(Davenport)},1000);
setTimeout(function(){map.addOverlays(Dubuque)},1000);
setTimeout(function(){map.addOverlays(Fairfield)},1000);
setTimeout(function(){map.addOverlays(Hiawatha)},1000);
setTimeout(function(){map.addOverlays(Iowa_City)},1000);
setTimeout(function(){map.addOverlays(Keokuk)},1000);
setTimeout(function(){map.addOverlays(Maquoketa)},1000);
setTimeout(function(){map.addOverlays(Newell)},1000);
setTimeout(function(){map.addOverlays(Sioux_City)},1000);
setTimeout(function(){map.addOverlays(West_Des_Moines)},1000);
maxLng = -90.48820000;
maxLat = 42.61690000;
minLng = -96.39610500;
minLat = 40.46521700;
reCenterMap();
} // 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//////' + showArray);
map.removeOverlays(Bettendorf);
map.removeOverlays(Cedar_Falls);
map.removeOverlays(Cedar_Rapids);
map.removeOverlays(Clive);
map.removeOverlays(Coralville);
map.removeOverlays(Council_Bluffs);
map.removeOverlays(Davenport);
map.removeOverlays(Dubuque);
map.removeOverlays(Fairfield);
map.removeOverlays(Hiawatha);
map.removeOverlays(Iowa_City);
map.removeOverlays(Keokuk);
map.removeOverlays(Maquoketa);
map.removeOverlays(Newell);
map.removeOverlays(Sioux_City);
map.removeOverlays(West_Des_Moines);
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(Bettendorf);map.removeOverlays(Bettendorf);
map.removeOverlays(Cedar_Falls);
map.removeOverlays(Cedar_Rapids);
map.removeOverlays(Clive);
map.removeOverlays(Coralville);
map.removeOverlays(Council_Bluffs);
map.removeOverlays(Davenport);
map.removeOverlays(Dubuque);
map.removeOverlays(Fairfield);
map.removeOverlays(Hiawatha);
map.removeOverlays(Iowa_City);
map.removeOverlays(Keokuk);
map.removeOverlays(Maquoketa);
map.removeOverlays(Newell);
map.removeOverlays(Sioux_City);
map.removeOverlays(West_Des_Moines);
map.addOverlays(Bettendorf);
centerByArray(Bettendorf, false, false);
cntMarker += Bettendorf.length;
map.addOverlays(Cedar_Falls);
centerByArray(Cedar_Falls, false, false);
cntMarker += Cedar_Falls.length;
map.addOverlays(Cedar_Rapids);
centerByArray(Cedar_Rapids, false, false);
cntMarker += Cedar_Rapids.length;
map.addOverlays(Clive);
centerByArray(Clive, false, false);
cntMarker += Clive.length;
map.addOverlays(Coralville);
centerByArray(Coralville, false, false);
cntMarker += Coralville.length;
map.addOverlays(Council_Bluffs);
centerByArray(Council_Bluffs, false, false);
cntMarker += Council_Bluffs.length;
map.addOverlays(Davenport);
centerByArray(Davenport, false, false);
cntMarker += Davenport.length;
map.addOverlays(Dubuque);
centerByArray(Dubuque, false, false);
cntMarker += Dubuque.length;
map.addOverlays(Fairfield);
centerByArray(Fairfield, false, false);
cntMarker += Fairfield.length;
map.addOverlays(Hiawatha);
centerByArray(Hiawatha, false, false);
cntMarker += Hiawatha.length;
map.addOverlays(Iowa_City);
centerByArray(Iowa_City, false, false);
cntMarker += Iowa_City.length;
map.addOverlays(Keokuk);
centerByArray(Keokuk, false, false);
cntMarker += Keokuk.length;
map.addOverlays(Maquoketa);
centerByArray(Maquoketa, false, false);
cntMarker += Maquoketa.length;
map.addOverlays(Newell);
centerByArray(Newell, false, false);
cntMarker += Newell.length;
map.addOverlays(Sioux_City);
centerByArray(Sioux_City, false, false);
cntMarker += Sioux_City.length;
map.addOverlays(West_Des_Moines);
centerByArray(West_Des_Moines, false, false);
cntMarker += West_Des_Moines.length;
centerByArray(Bettendorf,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///10795,10695,35401,35402,10865,10861,10795,10619,10864,32429,10855,10706,10863,30578,10642,10695,34760,10849,10854,32431,35402,10832,10705,10751,/all');
//window.open('/map.php?type=2&schools=10795,10695,35401,35402,10865,10861,10795,10619,10864,32429,10855,10706,10863,30578,10642,10695,34760,10849,10854,32431,35402,10832,10705,10751,&school_level=&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;
}