function addMarkers() { mySelect = document.getElementById('selection'); Fort_Riley = [];Junction_City = [];Ft_Riley = [];Milford = [];mySelect.options[mySelect.options.length] = new Option("Fort Riley schools",'all=Fort_Riley'); mySelect.options[mySelect.options.length] = new Option("Ft Riley schools",'all=Ft_Riley'); mySelect.options[mySelect.options.length] = new Option("Junction City schools",'all=Junction_City'); mySelect.options[mySelect.options.length] = new Option("Milford schools",'all=Milford'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Fort_Riley[Fort_Riley.length] = createMarker(new GPoint(-96.81369781,39.08791351),"
Custer Hill Elementary School
6344 Hampton Place
Fort Riley, KS 66442

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Custer Hill Elementary School",'Fort_Riley=' + Fort_Riley.length); Junction_City[Junction_City.length] = createMarker(new GPoint(-96.85205841,39.01037979),"
Eisenhower Elementary School
1625 St Marys Rd
Junction City, KS 66441

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Eisenhower Elementary School",'Junction_City=' + Junction_City.length); Fort_Riley[Fort_Riley.length] = createMarker(new GPoint(-96.78588104,39.06848145),"
Fort Riley Elementary School
104 Morris Avenue
Fort Riley, KS 66442

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Fort Riley Elementary School",'Fort_Riley=' + Fort_Riley.length); Fort_Riley[Fort_Riley.length] = createMarker(new GPoint(-96.78432465,39.06980133),"
Fort Riley Middle School
4020 First Division Rd
Fort Riley, KS 66442

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Fort Riley Middle School",'Fort_Riley=' + Fort_Riley.length); Junction_City[Junction_City.length] = createMarker(new GPoint(-96.83047900,39.02824000),"
Franklin Elementary School
410 W 2nd
Junction City, KS 66441

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Franklin Elementary School",'Junction_City=' + Junction_City.length); Junction_City[Junction_City.length] = createMarker(new GPoint(-96.79611206,39.03097153),"
Grandview Elementary School
109 E Grandview Dr
Junction City, KS 66441

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Grandview Elementary School",'Junction_City=' + Junction_City.length); Ft_Riley[Ft_Riley.length] = createMarker(new GPoint(-96.80794525,39.09641647),"
Jefferson Elementary School
4720 Jackson Avenue
Ft Riley, KS 66442

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'Ft_Riley=' + Ft_Riley.length); Junction_City[Junction_City.length] = createMarker(new GPoint(-96.83357239,39.03153610),"
Junction City Middle School
300 W 9th
Junction City, KS 66441

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Junction City Middle School",'Junction_City=' + Junction_City.length); Junction_City[Junction_City.length] = createMarker(new GPoint(-96.84937286,39.03173828),"
Junction City Senior High School
900 N Eisenhower
Junction City, KS 66441

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Junction City Senior High School",'Junction_City=' + Junction_City.length); Junction_City[Junction_City.length] = createMarker(new GPoint(-96.83367157,39.02890015),"
Lincoln Elementary School
300 N Lincoln
Junction City, KS 66441

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Junction_City=' + Junction_City.length); Milford[Milford.length] = createMarker(new GPoint(-96.91449738,39.17570114),"
Milford Elementary School
12th Lakeview
Milford, KS 66514

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Milford Elementary School",'Milford=' + Milford.length); Fort_Riley[Fort_Riley.length] = createMarker(new GPoint(-96.78582001,39.07107544),"
Morris Hill Elementary School
4400 First Division Rd
Fort Riley, KS 66442

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Morris Hill Elementary School",'Fort_Riley=' + Fort_Riley.length); Junction_City[Junction_City.length] = createMarker(new GPoint(-96.83583069,39.01556396),"
Sheridan Elementary School
429 W Ash
Junction City, KS 66441

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Sheridan Elementary School",'Junction_City=' + Junction_City.length); Fort_Riley[Fort_Riley.length] = createMarker(new GPoint(-96.81798553,39.08628082),"
Ware Elementary School
6795 Thomas Avenue
Fort Riley, KS 66442

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Ware Elementary School",'Fort_Riley=' + Fort_Riley.length); Junction_City[Junction_City.length] = createMarker(new GPoint(-96.82967377,39.03773880),"
Washington Elementary School
1500 N Washington
Junction City, KS 66441

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Washington Elementary School",'Junction_City=' + Junction_City.length); Junction_City[Junction_City.length] = createMarker(new GPoint(-96.84927368,39.03971481),"
Westwood Elementary School
1600 N Eisenhower Dr
Junction City, KS 66441

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Westwood Elementary School",'Junction_City=' + Junction_City.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(Fort_Riley); map.removeOverlays(Ft_Riley); map.removeOverlays(Junction_City); map.removeOverlays(Milford); 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(Fort_Riley);map.removeOverlays(Fort_Riley); map.removeOverlays(Ft_Riley); map.removeOverlays(Junction_City); map.removeOverlays(Milford); map.addOverlays(Fort_Riley); centerByArray(Fort_Riley, false, false); cntMarker += Fort_Riley.length; map.addOverlays(Ft_Riley); centerByArray(Ft_Riley, false, false); cntMarker += Ft_Riley.length; map.addOverlays(Junction_City); centerByArray(Junction_City, false, false); cntMarker += Junction_City.length; map.addOverlays(Milford); centerByArray(Milford, false, false); cntMarker += Milford.length; centerByArray(Fort_Riley,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'); } }