function addMarkers() { mySelect = document.getElementById('selection'); Bardstown = [];Bloomfield = [];Boston = [];Chaplin = [];Coxs_Creek = [];New_Haven = [];mySelect.options[mySelect.options.length] = new Option("Bardstown schools",'all=Bardstown'); mySelect.options[mySelect.options.length] = new Option("Bloomfield schools",'all=Bloomfield'); mySelect.options[mySelect.options.length] = new Option("Boston schools",'all=Boston'); mySelect.options[mySelect.options.length] = new Option("Chaplin schools",'all=Chaplin'); mySelect.options[mySelect.options.length] = new Option("Coxs Creek schools",'all=Coxs_Creek'); mySelect.options[mySelect.options.length] = new Option("New Haven schools",'all=New_Haven'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Bardstown[Bardstown.length] = createMarker(new GPoint(-85.47091400,37.80996000),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bardstown Elementary School",'Bardstown=' + Bardstown.length); Bardstown[Bardstown.length] = createMarker(new GPoint(-85.46886444,37.81412888),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Bardstown High School",'Bardstown=' + Bardstown.length); Bardstown[Bardstown.length] = createMarker(new GPoint(-85.46881866,37.81427002),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Bardstown Middle School",'Bardstown=' + Bardstown.length); Bardstown[Bardstown.length] = createMarker(new GPoint(-85.45850372,37.81090164),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bardstown Primary School",'Bardstown=' + Bardstown.length); Bloomfield[Bloomfield.length] = createMarker(new GPoint(-85.30675507,37.91276169),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Bloomfield Middle School",'Bloomfield=' + Bloomfield.length); Boston[Boston.length] = createMarker(new GPoint(-85.67808533,37.78854370),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Boston Elementary School",'Boston=' + Boston.length); Chaplin[Chaplin.length] = createMarker(new GPoint(-85.22158813,37.89636612),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Chaplin Elementary School",'Chaplin=' + Chaplin.length); Coxs_Creek[Coxs_Creek.length] = createMarker(new GPoint(-85.48576355,37.99731064),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cox's Creek Elementary School",'Coxs_Creek=' + Coxs_Creek.length); Bloomfield[Bloomfield.length] = createMarker(new GPoint(-85.32292938,37.90740585),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Eli H Brown Junior Elementary School",'Bloomfield=' + Bloomfield.length); Bardstown[Bardstown.length] = createMarker(new GPoint(-85.46585846,37.80606079),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Foster Heights Elementary School",'Bardstown=' + Bardstown.length); Bardstown[Bardstown.length] = createMarker(new GPoint(-85.42652893,37.82741547),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Nelson County High School",'Bardstown=' + Bardstown.length); New_Haven[New_Haven.length] = createMarker(new GPoint(-85.58815765,37.65697861),"",iconRd); mySelect.options[mySelect.options.length] = new Option("New Haven Elementary School",'New_Haven=' + New_Haven.length); Bardstown[Bardstown.length] = createMarker(new GPoint(-85.42652893,37.82741547),"",iconGr); mySelect.options[mySelect.options.length] = new Option("New Horizons High School",'Bardstown=' + Bardstown.length); Bardstown[Bardstown.length] = createMarker(new GPoint(-85.46569300,37.80574900),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Old Kentucky Home Intermediate",'Bardstown=' + Bardstown.length); Bardstown[Bardstown.length] = createMarker(new GPoint(-85.46569824,37.80604172),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Old Kentucky Home Middle School",'Bardstown=' + Bardstown.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(Bardstown); map.removeOverlays(Bloomfield); map.removeOverlays(Boston); map.removeOverlays(Chaplin); map.removeOverlays(Coxs_Creek); map.removeOverlays(New_Haven); 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(Bardstown);map.removeOverlays(Bardstown); map.removeOverlays(Bloomfield); map.removeOverlays(Boston); map.removeOverlays(Chaplin); map.removeOverlays(Coxs_Creek); map.removeOverlays(New_Haven); map.addOverlays(Bardstown); centerByArray(Bardstown, false, false); cntMarker += Bardstown.length; map.addOverlays(Bloomfield); centerByArray(Bloomfield, false, false); cntMarker += Bloomfield.length; map.addOverlays(Boston); centerByArray(Boston, false, false); cntMarker += Boston.length; map.addOverlays(Chaplin); centerByArray(Chaplin, false, false); cntMarker += Chaplin.length; map.addOverlays(Coxs_Creek); centerByArray(Coxs_Creek, false, false); cntMarker += Coxs_Creek.length; map.addOverlays(New_Haven); centerByArray(New_Haven, false, false); cntMarker += New_Haven.length; centerByArray(Bardstown,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'); } }