function addMarkers(){ mySelect = document.getElementById('selection'); Lyons = [];Delavan = [];Williams_Bay = [];Elkhorn = [];Lake_Geneva = [];East_Troy = [];Whitewater = [];Mukwonago = [];mySelect.options[mySelect.options.length] = new Option("Delavan schools",'all=Delavan'); mySelect.options[mySelect.options.length] = new Option("East Troy schools",'all=East_Troy'); mySelect.options[mySelect.options.length] = new Option("Elkhorn schools",'all=Elkhorn'); mySelect.options[mySelect.options.length] = new Option("Lake Geneva schools",'all=Lake_Geneva'); mySelect.options[mySelect.options.length] = new Option("Lyons schools",'all=Lyons'); mySelect.options[mySelect.options.length] = new Option("Mukwonago schools",'all=Mukwonago'); mySelect.options[mySelect.options.length] = new Option("Whitewater schools",'all=Whitewater'); mySelect.options[mySelect.options.length] = new Option("Williams Bay schools",'all=Williams_Bay'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Lyons[Lyons.length] = createMarker(new GPoint(-88.41362400,42.64396500),"
Cornerstone Christian Academy
Po Box 120
Lyons, WI 53148
Co-ed school, 5-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cornerstone Christian Academy",'Lyons=' + Lyons.length); Delavan[Delavan.length] = createMarker(new GPoint(-88.63611000,42.63653100),"
Delavan Christian School
848 Oak St
Delavan, WI 53115
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Delavan Christian School",'Delavan=' + Delavan.length); Williams_Bay[Williams_Bay.length] = createMarker(new GPoint(-88.54150400,42.57742000),"
Faith Christian School
Po Box 1230
Williams Bay, WI 53191
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Faith Christian School",'Williams_Bay=' + Williams_Bay.length); Elkhorn[Elkhorn.length] = createMarker(new GPoint(-88.55411200,42.66562600),"
First Lutheran School
415 Devendorf Street
Elkhorn, WI 53121
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("First Lutheran School",'Elkhorn=' + Elkhorn.length); Lake_Geneva[Lake_Geneva.length] = createMarker(new GPoint(-88.43914800,42.60439900),"
First Lutheran School
1101 Logan Street
Lake Geneva, WI 53147
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("First Lutheran School",'Lake_Geneva=' + Lake_Geneva.length); East_Troy[East_Troy.length] = createMarker(new GPoint(-88.42304600,42.79072300),"
Good Shepherd Lutheran School
1936 Emery Street
East Troy, WI 53120
Co-ed school, PK-6
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Good Shepherd Lutheran School",'East_Troy=' + East_Troy.length); Whitewater[Whitewater.length] = createMarker(new GPoint(-88.72752700,42.82695100),"
Kettle Moraine Baptist Academy
505 S Wisconsin St
Whitewater, WI 53190
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Kettle Moraine Baptist Academy",'Whitewater=' + Whitewater.length); Lake_Geneva[Lake_Geneva.length] = createMarker(new GPoint(-88.41398400,42.61922500),"
Mount Zion Christian School
2330 Highway 120
Lake Geneva, WI 53147
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Mount Zion Christian School",'Lake_Geneva=' + Lake_Geneva.length); Mukwonago[Mukwonago.length] = createMarker(new GPoint(-88.35115200,42.87773600),"
Nature's Classroom Montessori
Po Box 660
Mukwonago, WI 53149
Co-ed school, NS-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Nature's Classroom Montessori",'Mukwonago=' + Mukwonago.length); Delavan[Delavan.length] = createMarker(new GPoint(-88.65708100,42.62761700),"
Our Redeemer Lutheran School
416 W Geneva Street
Delavan, WI 53115
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Our Redeemer Lutheran School",'Delavan=' + Delavan.length); Delavan[Delavan.length] = createMarker(new GPoint(-88.63902200,42.63242700),"
St. Andrew Parish School
115 So 7th St
Delavan, WI 53115
Co-ed school, NS-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Andrew Parish School",'Delavan=' + Delavan.length); Lake_Geneva[Lake_Geneva.length] = createMarker(new GPoint(-88.42069000,42.59199800),"
St. Francis De Sales School
130 Main Street
Lake Geneva, WI 53147
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Francis De Sales School",'Lake_Geneva=' + Lake_Geneva.length); Elkhorn[Elkhorn.length] = createMarker(new GPoint(-88.55152100,42.68116500),"
St. Patrick Parish School
534 Sunset Drive
Elkhorn, WI 53121
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Patrick Parish School",'Elkhorn=' + Elkhorn.length); East_Troy[East_Troy.length] = createMarker(new GPoint(-88.39639500,42.79216300),"
St Pauls Lutheran School
2665 North Street
East Troy, WI 53120
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Pauls Lutheran School",'East_Troy=' + East_Troy.length); East_Troy[East_Troy.length] = createMarker(new GPoint(-88.40999800,42.78986300),"
St Peter Elementary School
3001 Elm Street
East Troy, WI 53120
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Peter Elementary School",'East_Troy=' + East_Troy.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/////1/' + showArray); map.removeOverlays(Delavan); map.removeOverlays(East_Troy); map.removeOverlays(Elkhorn); map.removeOverlays(Lake_Geneva); map.removeOverlays(Lyons); map.removeOverlays(Mukwonago); map.removeOverlays(Whitewater); map.removeOverlays(Williams_Bay); 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(Lyons);map.removeOverlays(Delavan); map.removeOverlays(East_Troy); map.removeOverlays(Elkhorn); map.removeOverlays(Lake_Geneva); map.removeOverlays(Lyons); map.removeOverlays(Mukwonago); map.removeOverlays(Whitewater); map.removeOverlays(Williams_Bay); map.addOverlays(Delavan); centerByArray(Delavan, false, false); cntMarker += Delavan.length; map.addOverlays(East_Troy); centerByArray(East_Troy, false, false); cntMarker += East_Troy.length; map.addOverlays(Elkhorn); centerByArray(Elkhorn, false, false); cntMarker += Elkhorn.length; map.addOverlays(Lake_Geneva); centerByArray(Lake_Geneva, false, false); cntMarker += Lake_Geneva.length; map.addOverlays(Lyons); centerByArray(Lyons, false, false); cntMarker += Lyons.length; map.addOverlays(Mukwonago); centerByArray(Mukwonago, false, false); cntMarker += Mukwonago.length; map.addOverlays(Whitewater); centerByArray(Whitewater, false, false); cntMarker += Whitewater.length; map.addOverlays(Williams_Bay); centerByArray(Williams_Bay, false, false); cntMarker += Williams_Bay.length; centerByArray(Lyons,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=1&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; }