function addMarkers() { mySelect = document.getElementById('selection'); Batesville = [];Osgood = [];Milan = [];Sunman = [];Versailles = [];mySelect.options[mySelect.options.length] = new Option("Batesville schools",'all=Batesville'); mySelect.options[mySelect.options.length] = new Option("Milan schools",'all=Milan'); mySelect.options[mySelect.options.length] = new Option("Osgood schools",'all=Osgood'); mySelect.options[mySelect.options.length] = new Option("Sunman schools",'all=Sunman'); mySelect.options[mySelect.options.length] = new Option("Versailles schools",'all=Versailles'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Batesville[Batesville.length] = createMarker(new GPoint(-85.22806549,39.30326462),"
",iconBl); mySelect.options[mySelect.options.length] = new Option("Batesville Intermediate School",'Batesville=' + Batesville.length); Batesville[Batesville.length] = createMarker(new GPoint(-85.22677612,39.30202103),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Batesville Middle School",'Batesville=' + Batesville.length); Batesville[Batesville.length] = createMarker(new GPoint(-85.22326660,39.30022049),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Batesville Primary School",'Batesville=' + Batesville.length); Osgood[Osgood.length] = createMarker(new GPoint(-85.29546356,39.14139175),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jac-cen-del Elementary School",'Osgood=' + Osgood.length); Osgood[Osgood.length] = createMarker(new GPoint(-85.29573059,39.14169312),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Jac-cen-del Junior Senior High School",'Osgood=' + Osgood.length); Milan[Milan.length] = createMarker(new GPoint(-85.12663269,39.12104797),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Milan Elementary School",'Milan=' + Milan.length); Milan[Milan.length] = createMarker(new GPoint(-85.12982178,39.12838364),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Milan High School",'Milan=' + Milan.length); Milan[Milan.length] = createMarker(new GPoint(-85.12982178,39.12838364),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Milan Middle School",'Milan=' + Milan.length); Sunman[Sunman.length] = createMarker(new GPoint(-85.08560181,39.23949814),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Ripley-ohio-dearborn Center",'Sunman=' + Sunman.length); Versailles[Versailles.length] = createMarker(new GPoint(-85.25000763,39.05258942),"",iconRd); mySelect.options[mySelect.options.length] = new Option("South Ripley Elementary School",'Versailles=' + Versailles.length); Versailles[Versailles.length] = createMarker(new GPoint(-85.25036621,39.05215073),"",iconGr); mySelect.options[mySelect.options.length] = new Option("South Ripley Junior & Senior High School",'Versailles=' + Versailles.length); Versailles[Versailles.length] = createMarker(new GPoint(-85.24770355,39.03929901),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Southeastern Career Center",'Versailles=' + Versailles.length); Sunman[Sunman.length] = createMarker(new GPoint(-85.09467316,39.24549484),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sunman Elementary School",'Sunman=' + Sunman.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(Batesville); map.removeOverlays(Milan); map.removeOverlays(Osgood); map.removeOverlays(Sunman); map.removeOverlays(Versailles); 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(Batesville);map.removeOverlays(Batesville); map.removeOverlays(Milan); map.removeOverlays(Osgood); map.removeOverlays(Sunman); map.removeOverlays(Versailles); map.addOverlays(Batesville); centerByArray(Batesville, false, false); cntMarker += Batesville.length; map.addOverlays(Milan); centerByArray(Milan, false, false); cntMarker += Milan.length; map.addOverlays(Osgood); centerByArray(Osgood, false, false); cntMarker += Osgood.length; map.addOverlays(Sunman); centerByArray(Sunman, false, false); cntMarker += Sunman.length; map.addOverlays(Versailles); centerByArray(Versailles, false, false); cntMarker += Versailles.length; centerByArray(Batesville,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'); } }