function addMarkers(){
mySelect = document.getElementById('selection');
Ames = [];Ankeny = [];Cedar_Rapids = [];Fort_Dodge = [];Urbandale = [];Estherville = [];Fairfield = [];Muscatine = [];Forest_City = [];Des_Moines = [];Eldridge = [];Centerville = [];North_Liberty = [];West_Des_Moines = [];Bettendorf = [];Mount_Pleasant = [];Ottumwa = [];Sioux_City = [];Indianola = [];Waterloo = [];mySelect.options[mySelect.options.length] = new Option("Ames schools",'all=Ames');
mySelect.options[mySelect.options.length] = new Option("Ankeny schools",'all=Ankeny');
mySelect.options[mySelect.options.length] = new Option("Bettendorf schools",'all=Bettendorf');
mySelect.options[mySelect.options.length] = new Option("Cedar Rapids schools",'all=Cedar_Rapids');
mySelect.options[mySelect.options.length] = new Option("Centerville schools",'all=Centerville');
mySelect.options[mySelect.options.length] = new Option("Des Moines schools",'all=Des_Moines');
mySelect.options[mySelect.options.length] = new Option("Eldridge schools",'all=Eldridge');
mySelect.options[mySelect.options.length] = new Option("Estherville schools",'all=Estherville');
mySelect.options[mySelect.options.length] = new Option("Fairfield schools",'all=Fairfield');
mySelect.options[mySelect.options.length] = new Option("Forest City schools",'all=Forest_City');
mySelect.options[mySelect.options.length] = new Option("Fort Dodge schools",'all=Fort_Dodge');
mySelect.options[mySelect.options.length] = new Option("Indianola schools",'all=Indianola');
mySelect.options[mySelect.options.length] = new Option("Mount Pleasant schools",'all=Mount_Pleasant');
mySelect.options[mySelect.options.length] = new Option("Muscatine schools",'all=Muscatine');
mySelect.options[mySelect.options.length] = new Option("North Liberty schools",'all=North_Liberty');
mySelect.options[mySelect.options.length] = new Option("Ottumwa schools",'all=Ottumwa');
mySelect.options[mySelect.options.length] = new Option("Sioux City schools",'all=Sioux_City');
mySelect.options[mySelect.options.length] = new Option("Urbandale schools",'all=Urbandale');
mySelect.options[mySelect.options.length] = new Option("Waterloo schools",'all=Waterloo');
mySelect.options[mySelect.options.length] = new Option("West Des Moines schools",'all=West_Des_Moines');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Ames[Ames.length] = createMarker(new GPoint(-93.62411300,42.00850200),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ames Christian School",'Ames=' + Ames.length);
Ankeny[Ankeny.length] = createMarker(new GPoint(-93.62190600,41.73199300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ankeny Christian Academy",'Ankeny=' + Ankeny.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);
Fort_Dodge[Fort_Dodge.length] = createMarker(new GPoint(-94.15252200,42.51583700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Community Christian School",'Fort_Dodge=' + Fort_Dodge.length);
Urbandale[Urbandale.length] = createMarker(new GPoint(-93.68281200,41.61142700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Des Moines Christian School",'Urbandale=' + Urbandale.length);
Estherville[Estherville.length] = createMarker(new GPoint(-94.87599500,43.41499100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Estherville Community Christian School",'Estherville=' + Estherville.length);
Fairfield[Fairfield.length] = createMarker(new GPoint(-91.96297300,40.98606700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fairfield Christian School",'Fairfield=' + Fairfield.length);
Muscatine[Muscatine.length] = createMarker(new GPoint(-91.03889600,41.44591300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Academy",'Muscatine=' + Muscatine.length);
Forest_City[Forest_City.length] = createMarker(new GPoint(-93.63938800,43.27707200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Forest City Christian School",'Forest_City=' + Forest_City.length);
Des_Moines[Des_Moines.length] = createMarker(new GPoint(-93.55138200,41.60914700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grandview Park Baptist School",'Des_Moines=' + Des_Moines.length);
Eldridge[Eldridge.length] = createMarker(new GPoint(-90.54549700,41.69218600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Heritage Christian School",'Eldridge=' + Eldridge.length);
Centerville[Centerville.length] = createMarker(new GPoint(-92.87758000,40.74223800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Heritage Christian School",'Centerville=' + Centerville.length);
North_Liberty[North_Liberty.length] = createMarker(new GPoint(-91.57664300,41.73350400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Heritage Christian School",'North_Liberty=' + North_Liberty.length);
West_Des_Moines[West_Des_Moines.length] = createMarker(new GPoint(-93.73943900,41.57951300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Iowa Christian Academy",'West_Des_Moines=' + West_Des_Moines.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);
Bettendorf[Bettendorf.length] = createMarker(new GPoint(-90.51225900,41.56047300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Morning Star Academy",'Bettendorf=' + Bettendorf.length);
Mount_Pleasant[Mount_Pleasant.length] = createMarker(new GPoint(-91.53124100,40.96318900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mt Pleasant Christian School",'Mount_Pleasant=' + Mount_Pleasant.length);
Ottumwa[Ottumwa.length] = createMarker(new GPoint(-92.40867600,41.02442300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ottumwa Christian School",'Ottumwa=' + Ottumwa.length);
Sioux_City[Sioux_City.length] = createMarker(new GPoint(-96.32963600,42.46200800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Siouxland Community Christian School",'Sioux_City=' + Sioux_City.length);
Indianola[Indianola.length] = createMarker(new GPoint(-93.57060000,41.35360000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Victory Christian Academy",'Indianola=' + Indianola.length);
Waterloo[Waterloo.length] = createMarker(new GPoint(-92.37680300,42.46926300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Walnut Ridge Baptist Academy",'Waterloo=' + Waterloo.length);
map.removeOverlays(Ames);
map.removeOverlays(Ankeny);
map.removeOverlays(Bettendorf);
map.removeOverlays(Cedar_Rapids);
map.removeOverlays(Centerville);
map.removeOverlays(Des_Moines);
map.removeOverlays(Eldridge);
map.removeOverlays(Estherville);
map.removeOverlays(Fairfield);
map.removeOverlays(Forest_City);
map.removeOverlays(Fort_Dodge);
map.removeOverlays(Indianola);
map.removeOverlays(Mount_Pleasant);
map.removeOverlays(Muscatine);
map.removeOverlays(North_Liberty);
map.removeOverlays(Ottumwa);
map.removeOverlays(Sioux_City);
map.removeOverlays(Urbandale);
map.removeOverlays(Waterloo);
map.removeOverlays(West_Des_Moines);
setTimeout(function(){map.addOverlays(Ames)},1000);
setTimeout(function(){map.addOverlays(Ankeny)},1000);
setTimeout(function(){map.addOverlays(Bettendorf)},1000);
setTimeout(function(){map.addOverlays(Cedar_Rapids)},1000);
setTimeout(function(){map.addOverlays(Centerville)},1000);
setTimeout(function(){map.addOverlays(Des_Moines)},1000);
setTimeout(function(){map.addOverlays(Eldridge)},1000);
setTimeout(function(){map.addOverlays(Estherville)},1000);
setTimeout(function(){map.addOverlays(Fairfield)},1000);
setTimeout(function(){map.addOverlays(Forest_City)},1000);
setTimeout(function(){map.addOverlays(Fort_Dodge)},1000);
setTimeout(function(){map.addOverlays(Indianola)},1000);
setTimeout(function(){map.addOverlays(Mount_Pleasant)},1000);
setTimeout(function(){map.addOverlays(Muscatine)},1000);
setTimeout(function(){map.addOverlays(North_Liberty)},1000);
setTimeout(function(){map.addOverlays(Ottumwa)},1000);
setTimeout(function(){map.addOverlays(Sioux_City)},1000);
setTimeout(function(){map.addOverlays(Urbandale)},1000);
setTimeout(function(){map.addOverlays(Waterloo)},1000);
setTimeout(function(){map.addOverlays(West_Des_Moines)},1000);
maxLng = -90.51225900;
maxLat = 43.41499100;
minLng = -96.32963600;
minLat = 40.74223800;
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(Ames);
map.removeOverlays(Ankeny);
map.removeOverlays(Bettendorf);
map.removeOverlays(Cedar_Rapids);
map.removeOverlays(Centerville);
map.removeOverlays(Des_Moines);
map.removeOverlays(Eldridge);
map.removeOverlays(Estherville);
map.removeOverlays(Fairfield);
map.removeOverlays(Forest_City);
map.removeOverlays(Fort_Dodge);
map.removeOverlays(Indianola);
map.removeOverlays(Mount_Pleasant);
map.removeOverlays(Muscatine);
map.removeOverlays(North_Liberty);
map.removeOverlays(Ottumwa);
map.removeOverlays(Sioux_City);
map.removeOverlays(Urbandale);
map.removeOverlays(Waterloo);
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(Ames);map.removeOverlays(Ames);
map.removeOverlays(Ankeny);
map.removeOverlays(Bettendorf);
map.removeOverlays(Cedar_Rapids);
map.removeOverlays(Centerville);
map.removeOverlays(Des_Moines);
map.removeOverlays(Eldridge);
map.removeOverlays(Estherville);
map.removeOverlays(Fairfield);
map.removeOverlays(Forest_City);
map.removeOverlays(Fort_Dodge);
map.removeOverlays(Indianola);
map.removeOverlays(Mount_Pleasant);
map.removeOverlays(Muscatine);
map.removeOverlays(North_Liberty);
map.removeOverlays(Ottumwa);
map.removeOverlays(Sioux_City);
map.removeOverlays(Urbandale);
map.removeOverlays(Waterloo);
map.removeOverlays(West_Des_Moines);
map.addOverlays(Ames);
centerByArray(Ames, false, false);
cntMarker += Ames.length;
map.addOverlays(Ankeny);
centerByArray(Ankeny, false, false);
cntMarker += Ankeny.length;
map.addOverlays(Bettendorf);
centerByArray(Bettendorf, false, false);
cntMarker += Bettendorf.length;
map.addOverlays(Cedar_Rapids);
centerByArray(Cedar_Rapids, false, false);
cntMarker += Cedar_Rapids.length;
map.addOverlays(Centerville);
centerByArray(Centerville, false, false);
cntMarker += Centerville.length;
map.addOverlays(Des_Moines);
centerByArray(Des_Moines, false, false);
cntMarker += Des_Moines.length;
map.addOverlays(Eldridge);
centerByArray(Eldridge, false, false);
cntMarker += Eldridge.length;
map.addOverlays(Estherville);
centerByArray(Estherville, false, false);
cntMarker += Estherville.length;
map.addOverlays(Fairfield);
centerByArray(Fairfield, false, false);
cntMarker += Fairfield.length;
map.addOverlays(Forest_City);
centerByArray(Forest_City, false, false);
cntMarker += Forest_City.length;
map.addOverlays(Fort_Dodge);
centerByArray(Fort_Dodge, false, false);
cntMarker += Fort_Dodge.length;
map.addOverlays(Indianola);
centerByArray(Indianola, false, false);
cntMarker += Indianola.length;
map.addOverlays(Mount_Pleasant);
centerByArray(Mount_Pleasant, false, false);
cntMarker += Mount_Pleasant.length;
map.addOverlays(Muscatine);
centerByArray(Muscatine, false, false);
cntMarker += Muscatine.length;
map.addOverlays(North_Liberty);
centerByArray(North_Liberty, false, false);
cntMarker += North_Liberty.length;
map.addOverlays(Ottumwa);
centerByArray(Ottumwa, false, false);
cntMarker += Ottumwa.length;
map.addOverlays(Sioux_City);
centerByArray(Sioux_City, false, false);
cntMarker += Sioux_City.length;
map.addOverlays(Urbandale);
centerByArray(Urbandale, false, false);
cntMarker += Urbandale.length;
map.addOverlays(Waterloo);
centerByArray(Waterloo, false, false);
cntMarker += Waterloo.length;
map.addOverlays(West_Des_Moines);
centerByArray(West_Des_Moines, false, false);
cntMarker += West_Des_Moines.length;
centerByArray(Ames,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///10600,10601,8998,10620,10684,10659,10651,10660,10644,10646,10710,10726,10708,10637,10679,10600,10601,8998,10620,10684,10659,10651,10660,10856,10644,10646,10629,10847,10710,10645,10658,10726,10708,10637,10846,10679,/all');
//window.open('/map.php?type=2&schools=10600,10601,8998,10620,10684,10659,10651,10660,10644,10646,10710,10726,10708,10637,10679,10600,10601,8998,10620,10684,10659,10651,10660,10856,10644,10646,10629,10847,10710,10645,10658,10726,10708,10637,10846,10679,&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;
}