function addMarkers() { mySelect = document.getElementById('selection'); Aurora = [];Lawrenceburg = [];Dillsboro = [];St_Leon = [];Moores_Hill = [];Guilford = [];West_Harrison = [];mySelect.options[mySelect.options.length] = new Option("Aurora schools",'all=Aurora'); mySelect.options[mySelect.options.length] = new Option("Dillsboro schools",'all=Dillsboro'); mySelect.options[mySelect.options.length] = new Option("Guilford schools",'all=Guilford'); mySelect.options[mySelect.options.length] = new Option("Lawrenceburg schools",'all=Lawrenceburg'); mySelect.options[mySelect.options.length] = new Option("Moores Hill schools",'all=Moores_Hill'); mySelect.options[mySelect.options.length] = new Option("St Leon schools",'all=St_Leon'); mySelect.options[mySelect.options.length] = new Option("West Harrison schools",'all=West_Harrison'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Aurora[Aurora.length] = createMarker(new GPoint(-84.90022278,39.06456375),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Aurora Elementary School",'Aurora=' + Aurora.length); Lawrenceburg[Lawrenceburg.length] = createMarker(new GPoint(-84.83417511,39.19936371),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bright Elementary School",'Lawrenceburg=' + Lawrenceburg.length); Lawrenceburg[Lawrenceburg.length] = createMarker(new GPoint(-84.85087585,39.09680176),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Lawrenceburg=' + Lawrenceburg.length); Dillsboro[Dillsboro.length] = createMarker(new GPoint(-85.06456757,39.01780701),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Dillsboro Elementary School",'Dillsboro=' + Dillsboro.length); St_Leon[St_Leon.length] = createMarker(new GPoint(-84.95921326,39.29185104),"",iconGr); mySelect.options[mySelect.options.length] = new Option("East Central High School",'St_Leon=' + St_Leon.length); Lawrenceburg[Lawrenceburg.length] = createMarker(new GPoint(-84.85414886,39.09987640),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Greendale Middle School",'Lawrenceburg=' + Lawrenceburg.length); Lawrenceburg[Lawrenceburg.length] = createMarker(new GPoint(-84.85136414,39.09989166),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Lawrenceburg High School",'Lawrenceburg=' + Lawrenceburg.length); Lawrenceburg[Lawrenceburg.length] = createMarker(new GPoint(-84.85175800,39.09995800),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lawrenceburg Primary School",'Lawrenceburg=' + Lawrenceburg.length); Aurora[Aurora.length] = createMarker(new GPoint(-84.90267944,39.05707169),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Manchester Elementary School",'Aurora=' + Aurora.length); Moores_Hill[Moores_Hill.length] = createMarker(new GPoint(-85.09326172,39.11296463),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Moores Hill Elementary School",'Moores_Hill=' + Moores_Hill.length); Guilford[Guilford.length] = createMarker(new GPoint(-84.92771149,39.24921417),"",iconRd); mySelect.options[mySelect.options.length] = new Option("North Dearborn Elementary School",'Guilford=' + Guilford.length); Aurora[Aurora.length] = createMarker(new GPoint(-84.92932129,39.06232452),"",iconGr); mySelect.options[mySelect.options.length] = new Option("South Dearborn High School",'Aurora=' + Aurora.length); Aurora[Aurora.length] = createMarker(new GPoint(-84.92313385,39.06218338),"",iconBl); mySelect.options[mySelect.options.length] = new Option("South Dearborn Middle School",'Aurora=' + Aurora.length); West_Harrison[West_Harrison.length] = createMarker(new GPoint(-84.88939667,39.32361984),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Sunman Dearborn Intermediate School",'West_Harrison=' + West_Harrison.length); St_Leon[St_Leon.length] = createMarker(new GPoint(-84.95921326,39.29185104),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Sunman-dearborn Middle School",'St_Leon=' + St_Leon.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,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) { 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(Aurora); map.removeOverlays(Dillsboro); map.removeOverlays(Guilford); map.removeOverlays(Lawrenceburg); map.removeOverlays(Moores_Hill); map.removeOverlays(St_Leon); map.removeOverlays(West_Harrison); 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(Aurora);map.removeOverlays(Aurora); map.removeOverlays(Dillsboro); map.removeOverlays(Guilford); map.removeOverlays(Lawrenceburg); map.removeOverlays(Moores_Hill); map.removeOverlays(St_Leon); map.removeOverlays(West_Harrison); map.addOverlays(Aurora); centerByArray(Aurora, false, false); cntMarker += Aurora.length; map.addOverlays(Dillsboro); centerByArray(Dillsboro, false, false); cntMarker += Dillsboro.length; map.addOverlays(Guilford); centerByArray(Guilford, false, false); cntMarker += Guilford.length; map.addOverlays(Lawrenceburg); centerByArray(Lawrenceburg, false, false); cntMarker += Lawrenceburg.length; map.addOverlays(Moores_Hill); centerByArray(Moores_Hill, false, false); cntMarker += Moores_Hill.length; map.addOverlays(St_Leon); centerByArray(St_Leon, false, false); cntMarker += St_Leon.length; map.addOverlays(West_Harrison); centerByArray(West_Harrison, false, false); cntMarker += West_Harrison.length; centerByArray(Aurora,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'); } }