function addMarkers(){
mySelect = document.getElementById('selection');
Des_Moines = [];Ankeny = [];Davenport = [];Iowa_Falls = [];Urbandale = [];Cedar_Rapids = [];Mason_City = [];Waterloo = [];Ottumwa = [];Fort_Dodge = [];Estherville = [];Council_Bluffs = [];Marshalltown = [];Calmar = [];Sheldon = [];West_Burlington = [];Creston = [];Sioux_City = [];mySelect.options[mySelect.options.length] = new Option("Ankeny Schools",'all=Ankeny');
mySelect.options[mySelect.options.length] = new Option("Calmar Schools",'all=Calmar');
mySelect.options[mySelect.options.length] = new Option("Cedar Rapids Schools",'all=Cedar_Rapids');
mySelect.options[mySelect.options.length] = new Option("Council Bluffs Schools",'all=Council_Bluffs');
mySelect.options[mySelect.options.length] = new Option("Creston Schools",'all=Creston');
mySelect.options[mySelect.options.length] = new Option("Davenport Schools",'all=Davenport');
mySelect.options[mySelect.options.length] = new Option("Des Moines Schools",'all=Des_Moines');
mySelect.options[mySelect.options.length] = new Option("Estherville Schools",'all=Estherville');
mySelect.options[mySelect.options.length] = new Option("Fort Dodge Schools",'all=Fort_Dodge');
mySelect.options[mySelect.options.length] = new Option("Iowa Falls Schools",'all=Iowa_Falls');
mySelect.options[mySelect.options.length] = new Option("Marshalltown Schools",'all=Marshalltown');
mySelect.options[mySelect.options.length] = new Option("Mason City Schools",'all=Mason_City');
mySelect.options[mySelect.options.length] = new Option("Ottumwa Schools",'all=Ottumwa');
mySelect.options[mySelect.options.length] = new Option("Sheldon Schools",'all=Sheldon');
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 Burlington Schools",'all=West_Burlington');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
var tmpLatLng=0;
var tmpLen=0;
tmpLatLng=new GLatLng(41.56258900000000267,-93.6450179999999932);
tmpLen=Des_Moines.length;
Des_Moines[tmpLen] = createMarker(tmpLatLng,"
",iconRd);
Des_Moines[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Aib College Of Business",'Des_Moines=' + Des_Moines.length);
tmpLatLng=new GLatLng(41.71053599999999761,-93.6006820000000061);
tmpLen=Ankeny.length;
Ankeny[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Ankeny[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Des Moines Area Community College",'Ankeny=' + Ankeny.length);
tmpLatLng=new GLatLng(41.52003200000000049,-90.5773219999999952);
tmpLen=Davenport.length;
Davenport[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Davenport[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Eastern Iowa Community College District",'Davenport=' + Davenport.length);
tmpLatLng=new GLatLng(42.527818,-93.266727);
tmpLen=Iowa_Falls.length;
Iowa_Falls[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Iowa_Falls[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Ellsworth Community College",'Iowa_Falls=' + Iowa_Falls.length);
tmpLatLng=new GLatLng(41.64476400000000211,-93.7793560000000070);
tmpLen=Urbandale.length;
Urbandale[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Urbandale[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Hamilton College",'Urbandale=' + Urbandale.length);
tmpLatLng=new GLatLng(41.94732599999999678,-91.7160460000000057);
tmpLen=Cedar_Rapids.length;
Cedar_Rapids[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Cedar_Rapids[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Hamilton College-main Campus",'Cedar_Rapids=' + Cedar_Rapids.length);
tmpLatLng=new GLatLng(43.15261999999999886,-93.2026979999999980);
tmpLen=Mason_City.length;
Mason_City[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Mason_City[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Hamilton College-mason City Branch",'Mason_City=' + Mason_City.length);
tmpLatLng=new GLatLng(42.42851000000000283,-92.3276610000000061);
tmpLen=Waterloo.length;
Waterloo[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Waterloo[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Hawkeye Community College",'Waterloo=' + Waterloo.length);
tmpLatLng=new GLatLng(41.04372299999999995,-92.3971829999999982);
tmpLen=Ottumwa.length;
Ottumwa[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Ottumwa[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Indian Hills Community College",'Ottumwa=' + Ottumwa.length);
tmpLatLng=new GLatLng(42.48873700000000042,-94.2031410000000022);
tmpLen=Fort_Dodge.length;
Fort_Dodge[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Fort_Dodge[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Iowa Central Community College",'Fort_Dodge=' + Fort_Dodge.length);
tmpLatLng=new GLatLng(43.40170100000000275,-94.8353659999999933);
tmpLen=Estherville.length;
Estherville[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Estherville[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Iowa Lakes Community College",'Estherville=' + Estherville.length);
tmpLatLng=new GLatLng(41.27958199999999777,-95.7941239999999964);
tmpLen=Council_Bluffs.length;
Council_Bluffs[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Council_Bluffs[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Iowa Western Community College",'Council_Bluffs=' + Council_Bluffs.length);
tmpLatLng=new GLatLng(41.55663200000000046,-90.5491190000000045);
tmpLen=Davenport.length;
Davenport[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Davenport[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Kaplan University",'Davenport=' + Davenport.length);
tmpLatLng=new GLatLng(41.91725100000000026,-91.6566619999999971);
tmpLen=Cedar_Rapids.length;
Cedar_Rapids[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Cedar_Rapids[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Kirkwood Community College",'Cedar_Rapids=' + Cedar_Rapids.length);
tmpLatLng=new GLatLng(42.00283900000000159,-92.9125800000000054);
tmpLen=Marshalltown.length;
Marshalltown[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Marshalltown[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Marshalltown Community College",'Marshalltown=' + Marshalltown.length);
tmpLatLng=new GLatLng(43.16271900000000272,-93.1302129999999976);
tmpLen=Mason_City.length;
Mason_City[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Mason_City[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("North Iowa Area Community College",'Mason_City=' + Mason_City.length);
tmpLatLng=new GLatLng(43.17080200000000189,-91.8645870000000002);
tmpLen=Calmar.length;
Calmar[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Calmar[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Northeast Iowa Community College-calmar",'Calmar=' + Calmar.length);
tmpLatLng=new GLatLng(43.18603099999999983,-95.8800399999999939);
tmpLen=Sheldon.length;
Sheldon[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Sheldon[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Northwest Iowa Community College",'Sheldon=' + Sheldon.length);
tmpLatLng=new GLatLng(40.81162400000000189,-91.1742189999999936);
tmpLen=West_Burlington.length;
West_Burlington[tmpLen] = createMarker(tmpLatLng,"",iconGr);
West_Burlington[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Southeastern Community College",'West_Burlington=' + West_Burlington.length);
tmpLatLng=new GLatLng(41.07109400000000221,-94.3806060000000002);
tmpLen=Creston.length;
Creston[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Creston[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Southwestern Community College",'Creston=' + Creston.length);
tmpLatLng=new GLatLng(42.51801499999999833,-96.4053140000000041);
tmpLen=Sioux_City.length;
Sioux_City[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Sioux_City[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("St Luke's College",'Sioux_City=' + Sioux_City.length);
tmpLatLng=new GLatLng(42.47919300000000220,-96.3467509999999975);
tmpLen=Sioux_City.length;
Sioux_City[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Sioux_City[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Western Iowa Tech Community College",'Sioux_City=' + Sioux_City.length);
map.removeOverlays(Ankeny);
map.removeOverlays(Calmar);
map.removeOverlays(Cedar_Rapids);
map.removeOverlays(Council_Bluffs);
map.removeOverlays(Creston);
map.removeOverlays(Davenport);
map.removeOverlays(Des_Moines);
map.removeOverlays(Estherville);
map.removeOverlays(Fort_Dodge);
map.removeOverlays(Iowa_Falls);
map.removeOverlays(Marshalltown);
map.removeOverlays(Mason_City);
map.removeOverlays(Ottumwa);
map.removeOverlays(Sheldon);
map.removeOverlays(Sioux_City);
map.removeOverlays(Urbandale);
map.removeOverlays(Waterloo);
map.removeOverlays(West_Burlington);
setTimeout(function(){map.addOverlays(Ankeny)},1000);
setTimeout(function(){map.addOverlays(Calmar)},1000);
setTimeout(function(){map.addOverlays(Cedar_Rapids)},1000);
setTimeout(function(){map.addOverlays(Council_Bluffs)},1000);
setTimeout(function(){map.addOverlays(Creston)},1000);
setTimeout(function(){map.addOverlays(Davenport)},1000);
setTimeout(function(){map.addOverlays(Des_Moines)},1000);
setTimeout(function(){map.addOverlays(Estherville)},1000);
setTimeout(function(){map.addOverlays(Fort_Dodge)},1000);
setTimeout(function(){map.addOverlays(Iowa_Falls)},1000);
setTimeout(function(){map.addOverlays(Marshalltown)},1000);
setTimeout(function(){map.addOverlays(Mason_City)},1000);
setTimeout(function(){map.addOverlays(Ottumwa)},1000);
setTimeout(function(){map.addOverlays(Sheldon)},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_Burlington)},1000);
getPoly("","state","","IA");}
// End addStateMarkers JavaScript Function
//open all when map is defined
function openAll() {
if (map) {
selectChange("all");
} else {
setTimeout("openAll()",200);
}
}
// 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].point.x;
var markLat = myArray[i].point.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].point.x;
maxLat = myArray[0].point.y;
minLng = myArray[0].point.x;
minLat = myArray[0].point.y;
}
// Recenter map based on global max/mins
function reCenterMap(){
//alert('#' + minLat + '#' + minLng + '#' + maxLat + '#' + maxLng);
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,10);
/*
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) {
if (selection.options) {
var _openNewWindow=true;
var myVal = selection.options[selection.selectedIndex].value;
} else {
var _openNewWindow=false;
var myVal=selection;
}
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('schools-by-distance') == -1)
window.open(location.href + '/map/all');
else
window.open('/search////all');
map.removeOverlays(Ankeny);
map.removeOverlays(Calmar);
map.removeOverlays(Cedar_Rapids);
map.removeOverlays(Council_Bluffs);
map.removeOverlays(Creston);
map.removeOverlays(Davenport);
map.removeOverlays(Des_Moines);
map.removeOverlays(Estherville);
map.removeOverlays(Fort_Dodge);
map.removeOverlays(Iowa_Falls);
map.removeOverlays(Marshalltown);
map.removeOverlays(Mason_City);
map.removeOverlays(Ottumwa);
map.removeOverlays(Sheldon);
map.removeOverlays(Sioux_City);
map.removeOverlays(Urbandale);
map.removeOverlays(Waterloo);
map.removeOverlays(West_Burlington);
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(Des_Moines);map.removeOverlays(Ankeny);
map.removeOverlays(Calmar);
map.removeOverlays(Cedar_Rapids);
map.removeOverlays(Council_Bluffs);
map.removeOverlays(Creston);
map.removeOverlays(Davenport);
map.removeOverlays(Des_Moines);
map.removeOverlays(Estherville);
map.removeOverlays(Fort_Dodge);
map.removeOverlays(Iowa_Falls);
map.removeOverlays(Marshalltown);
map.removeOverlays(Mason_City);
map.removeOverlays(Ottumwa);
map.removeOverlays(Sheldon);
map.removeOverlays(Sioux_City);
map.removeOverlays(Urbandale);
map.removeOverlays(Waterloo);
map.removeOverlays(West_Burlington);
map.addOverlays(Ankeny);
centerByArray(Ankeny, false, false);
cntMarker += Ankeny.length;
map.addOverlays(Calmar);
centerByArray(Calmar, false, false);
cntMarker += Calmar.length;
map.addOverlays(Cedar_Rapids);
centerByArray(Cedar_Rapids, false, false);
cntMarker += Cedar_Rapids.length;
map.addOverlays(Council_Bluffs);
centerByArray(Council_Bluffs, false, false);
cntMarker += Council_Bluffs.length;
map.addOverlays(Creston);
centerByArray(Creston, false, false);
cntMarker += Creston.length;
map.addOverlays(Davenport);
centerByArray(Davenport, false, false);
cntMarker += Davenport.length;
map.addOverlays(Des_Moines);
centerByArray(Des_Moines, false, false);
cntMarker += Des_Moines.length;
map.addOverlays(Estherville);
centerByArray(Estherville, false, false);
cntMarker += Estherville.length;
map.addOverlays(Fort_Dodge);
centerByArray(Fort_Dodge, false, false);
cntMarker += Fort_Dodge.length;
map.addOverlays(Iowa_Falls);
centerByArray(Iowa_Falls, false, false);
cntMarker += Iowa_Falls.length;
map.addOverlays(Marshalltown);
centerByArray(Marshalltown, false, false);
cntMarker += Marshalltown.length;
map.addOverlays(Mason_City);
centerByArray(Mason_City, false, false);
cntMarker += Mason_City.length;
map.addOverlays(Ottumwa);
centerByArray(Ottumwa, false, false);
cntMarker += Ottumwa.length;
map.addOverlays(Sheldon);
centerByArray(Sheldon, false, false);
cntMarker += Sheldon.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_Burlington);
centerByArray(West_Burlington, false, false);
cntMarker += West_Burlington.length;
reCenterMap();
//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');
}
}
function createMarker(point, label, icon){
var marker = new GMarker(point, icon);
var html = label;
GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); });
return marker;
}