function addMarkers()
{
mySelect = document.getElementById('selection');
Shepherdsville = [];Mount_Washington = [];Lebanon_Junction = [];Louisville = [];West_Point = [];mySelect.options[mySelect.options.length] = new Option("Lebanon Junction schools",'all=Lebanon_Junction');
mySelect.options[mySelect.options.length] = new Option("Louisville schools",'all=Louisville');
mySelect.options[mySelect.options.length] = new Option("Mount Washington schools",'all=Mount_Washington');
mySelect.options[mySelect.options.length] = new Option("Shepherdsville schools",'all=Shepherdsville');
mySelect.options[mySelect.options.length] = new Option("West Point schools",'all=West_Point');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Shepherdsville[Shepherdsville.length] = createMarker(new GPoint(-85.68569183,37.92391205),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bernheim Middle School",'Shepherdsville=' + Shepherdsville.length);
Shepherdsville[Shepherdsville.length] = createMarker(new GPoint(-85.69947815,38.05690384),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Brooks Elementary School",'Shepherdsville=' + Shepherdsville.length);
Shepherdsville[Shepherdsville.length] = createMarker(new GPoint(-85.69700623,37.99839020),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bullitt Central High School",'Shepherdsville=' + Shepherdsville.length);
Shepherdsville[Shepherdsville.length] = createMarker(new GPoint(-85.69955444,38.00214386),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bullitt County Day Treatment Ctr Alt School",'Shepherdsville=' + Shepherdsville.length);
Mount_Washington[Mount_Washington.length] = createMarker(new GPoint(-85.55570221,38.04579926),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bullitt East High School",'Mount_Washington=' + Mount_Washington.length);
Shepherdsville[Shepherdsville.length] = createMarker(new GPoint(-85.72068024,38.00031662),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bullitt Lick Middle School",'Shepherdsville=' + Shepherdsville.length);
Shepherdsville[Shepherdsville.length] = createMarker(new GPoint(-85.68602753,37.97855377),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cedar Grove Elementary School",'Shepherdsville=' + Shepherdsville.length);
Mount_Washington[Mount_Washington.length] = createMarker(new GPoint(-85.62858300,38.02126600),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Eastside Middle School",'Mount_Washington=' + Mount_Washington.length);
Shepherdsville[Shepherdsville.length] = createMarker(new GPoint(-85.67935181,38.04642487),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Freedom Elementary School",'Shepherdsville=' + Shepherdsville.length);
Shepherdsville[Shepherdsville.length] = createMarker(new GPoint(-85.67089844,38.04957199),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Hebron Middle School",'Shepherdsville=' + Shepherdsville.length);
Lebanon_Junction[Lebanon_Junction.length] = createMarker(new GPoint(-85.72870636,37.84399033),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lebanon Junction Elementary School",'Lebanon_Junction=' + Lebanon_Junction.length);
Louisville[Louisville.length] = createMarker(new GPoint(-85.68630219,38.06200790),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Maryville Elementary School",'Louisville=' + Louisville.length);
Mount_Washington[Mount_Washington.length] = createMarker(new GPoint(-85.55617523,38.03928757),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mount Washington Elementary School",'Mount_Washington=' + Mount_Washington.length);
Mount_Washington[Mount_Washington.length] = createMarker(new GPoint(-85.54304504,38.04761124),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mount Washington Middle School",'Mount_Washington=' + Mount_Washington.length);
West_Point[West_Point.length] = createMarker(new GPoint(-85.90153503,38.01602936),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Nichols Elementary School",'West_Point=' + West_Point.length);
Shepherdsville[Shepherdsville.length] = createMarker(new GPoint(-85.67089844,38.04957199),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Bullitt High School",'Shepherdsville=' + Shepherdsville.length);
Mount_Washington[Mount_Washington.length] = createMarker(new GPoint(-85.52246857,38.05855179),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Old Mill Elementary School",'Mount_Washington=' + Mount_Washington.length);
Louisville[Louisville.length] = createMarker(new GPoint(-85.67768860,38.08171844),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Overdale Elementary School",'Louisville=' + Louisville.length);
Mount_Washington[Mount_Washington.length] = createMarker(new GPoint(-85.61104584,38.02652740),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pleasant Grove Elementary School",'Mount_Washington=' + Mount_Washington.length);
Shepherdsville[Shepherdsville.length] = createMarker(new GPoint(-85.69958496,38.00211334),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Riverview High Alternative School",'Shepherdsville=' + Shepherdsville.length);
Shepherdsville[Shepherdsville.length] = createMarker(new GPoint(-85.70139313,37.99642944),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Roby Elementary School",'Shepherdsville=' + Shepherdsville.length);
Shepherdsville[Shepherdsville.length] = createMarker(new GPoint(-85.71896800,37.99815500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Shepherdsville Elementary School",'Shepherdsville=' + Shepherdsville.length);
Shepherdsville[Shepherdsville.length] = createMarker(new GPoint(-85.66599400,38.06768800),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Zoneton Middle School",'Shepherdsville=' + Shepherdsville.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(Lebanon_Junction);
map.removeOverlays(Louisville);
map.removeOverlays(Mount_Washington);
map.removeOverlays(Shepherdsville);
map.removeOverlays(West_Point);
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(Shepherdsville);map.removeOverlays(Lebanon_Junction);
map.removeOverlays(Louisville);
map.removeOverlays(Mount_Washington);
map.removeOverlays(Shepherdsville);
map.removeOverlays(West_Point);
map.addOverlays(Lebanon_Junction);
centerByArray(Lebanon_Junction, false, false);
cntMarker += Lebanon_Junction.length;
map.addOverlays(Louisville);
centerByArray(Louisville, false, false);
cntMarker += Louisville.length;
map.addOverlays(Mount_Washington);
centerByArray(Mount_Washington, false, false);
cntMarker += Mount_Washington.length;
map.addOverlays(Shepherdsville);
centerByArray(Shepherdsville, false, false);
cntMarker += Shepherdsville.length;
map.addOverlays(West_Point);
centerByArray(West_Point, false, false);
cntMarker += West_Point.length;
centerByArray(Shepherdsville,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');
}
}