function addMarkers(){ mySelect = document.getElementById('selection'); Cedar_Falls = [];Dubuque = [];Hiawatha = [];West_Des_Moines = [];Council_Bluffs = [];Coralville = [];Des_Moines = [];Davenport = [];mySelect.options[mySelect.options.length] = new Option("Cedar Falls schools",'all=Cedar_Falls'); 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("Des Moines schools",'all=Des_Moines'); mySelect.options[mySelect.options.length] = new Option("Dubuque schools",'all=Dubuque'); mySelect.options[mySelect.options.length] = new Option("Hiawatha schools",'all=Hiawatha'); mySelect.options[mySelect.options.length] = new Option("West Des Moines schools",'all=West_Des_Moines'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Cedar_Falls[Cedar_Falls.length] = createMarker(new GPoint(-92.44387200,42.53050000),"
Casa Montessori School
215 Ninth Street
Cedar Falls, IA 50613
Co-ed school, PK-1
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Casa Montessori School",'Cedar_Falls=' + Cedar_Falls.length); Dubuque[Dubuque.length] = createMarker(new GPoint(-90.70312700,42.50036200),"
Dubuque Montessori School
2605 Pennsylvania Avenue
Dubuque, IA 52001
Co-ed school, NS-PK
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Dubuque Montessori School",'Dubuque=' + Dubuque.length); Hiawatha[Hiawatha.length] = createMarker(new GPoint(-91.68926700,42.03498100),"
Essential Montessori
1350 Blairs Ferry Road Suite A
Hiawatha, IA 52233
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Essential Montessori",'Hiawatha=' + Hiawatha.length); West_Des_Moines[West_Des_Moines.length] = createMarker(new GPoint(-93.76137400,41.59317300),"
Montessori Children's House
1505 42nd Street
West Des Moines, IA 50266
Co-ed school, PK-3
[ View School Profile ]
",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),"
Montessori Childrens House
400 Cloverdale Drive
Council Bluffs, IA 51503
Co-ed school, PK-K
[ View School Profile ]
",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),"
Montessori School-iowa City
374 Holiday Road
Coralville, IA 52241
Co-ed school, PK-3
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Montessori School-iowa City",'Coralville=' + Coralville.length); Des_Moines[Des_Moines.length] = createMarker(new GPoint(-93.70266500,41.61131900),"
New Horizons Academy
6201 Franklin Avenue
Des Moines, IA 50322
Co-ed school, K-3
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("New Horizons Academy",'Des_Moines=' + Des_Moines.length); Davenport[Davenport.length] = createMarker(new GPoint(-90.54141600,41.56763700),"
Quad City Montessori School
2400 East 46th Street
Davenport, IA 52807
Co-ed school, PK-6
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Quad City Montessori School",'Davenport=' + Davenport.length); West_Des_Moines[West_Des_Moines.length] = createMarker(new GPoint(-93.72739700,41.57716300),"
Sayre Montessori School
1700 28th Street
West Des Moines, IA 50266
Co-ed school, PK-6
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Sayre Montessori School",'West_Des_Moines=' + West_Des_Moines.length); map.removeOverlays(Cedar_Falls); map.removeOverlays(Coralville); map.removeOverlays(Council_Bluffs); map.removeOverlays(Davenport); map.removeOverlays(Des_Moines); map.removeOverlays(Dubuque); map.removeOverlays(Hiawatha); map.removeOverlays(West_Des_Moines); setTimeout(function(){map.addOverlays(Cedar_Falls)},1000); setTimeout(function(){map.addOverlays(Coralville)},1000); setTimeout(function(){map.addOverlays(Council_Bluffs)},1000); setTimeout(function(){map.addOverlays(Davenport)},1000); setTimeout(function(){map.addOverlays(Des_Moines)},1000); setTimeout(function(){map.addOverlays(Dubuque)},1000); setTimeout(function(){map.addOverlays(Hiawatha)},1000); setTimeout(function(){map.addOverlays(West_Des_Moines)},1000); maxLng = -90.54141600; maxLat = 42.53050000; minLng = -95.80110200; minLat = 41.25662500; 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(Cedar_Falls); map.removeOverlays(Coralville); map.removeOverlays(Council_Bluffs); map.removeOverlays(Davenport); map.removeOverlays(Des_Moines); map.removeOverlays(Dubuque); map.removeOverlays(Hiawatha); 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(Cedar_Falls);map.removeOverlays(Cedar_Falls); map.removeOverlays(Coralville); map.removeOverlays(Council_Bluffs); map.removeOverlays(Davenport); map.removeOverlays(Des_Moines); map.removeOverlays(Dubuque); map.removeOverlays(Hiawatha); map.removeOverlays(West_Des_Moines); map.addOverlays(Cedar_Falls); centerByArray(Cedar_Falls, false, false); cntMarker += Cedar_Falls.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(Des_Moines); centerByArray(Des_Moines, false, false); cntMarker += Des_Moines.length; map.addOverlays(Dubuque); centerByArray(Dubuque, false, false); cntMarker += Dubuque.length; map.addOverlays(Hiawatha); centerByArray(Hiawatha, false, false); cntMarker += Hiawatha.length; map.addOverlays(West_Des_Moines); centerByArray(West_Des_Moines, false, false); cntMarker += West_Des_Moines.length; centerByArray(Cedar_Falls,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///10619,10706,10863,30578,33973,10642,34760,10705,10751,/all'); //window.open('/map.php?type=2&schools=10619,10706,10863,30578,33973,10642,34760,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; }