function addMarkers(){
mySelect = document.getElementById('selection');
Mc_Daniels = [];Letcher = [];Independence = [];Corbin = [];Louisville = [];Fonde = [];Garrett = [];Radcliff = [];Lawrenceburg = [];Hodgenville = [];Hawesville = [];Ledbetter = [];London = [];Marion = [];Midway = [];Shepherdsville = [];Somerset = [];Ashland = [];Bardstown = [];Fordsville = [];Nicholasville = [];mySelect.options[mySelect.options.length] = new Option("Ashland schools",'all=Ashland');
mySelect.options[mySelect.options.length] = new Option("Bardstown schools",'all=Bardstown');
mySelect.options[mySelect.options.length] = new Option("Corbin schools",'all=Corbin');
mySelect.options[mySelect.options.length] = new Option("Fonde schools",'all=Fonde');
mySelect.options[mySelect.options.length] = new Option("Fordsville schools",'all=Fordsville');
mySelect.options[mySelect.options.length] = new Option("Garrett schools",'all=Garrett');
mySelect.options[mySelect.options.length] = new Option("Hawesville schools",'all=Hawesville');
mySelect.options[mySelect.options.length] = new Option("Hodgenville schools",'all=Hodgenville');
mySelect.options[mySelect.options.length] = new Option("Independence schools",'all=Independence');
mySelect.options[mySelect.options.length] = new Option("Lawrenceburg schools",'all=Lawrenceburg');
mySelect.options[mySelect.options.length] = new Option("Ledbetter schools",'all=Ledbetter');
mySelect.options[mySelect.options.length] = new Option("Letcher schools",'all=Letcher');
mySelect.options[mySelect.options.length] = new Option("London schools",'all=London');
mySelect.options[mySelect.options.length] = new Option("Louisville schools",'all=Louisville');
mySelect.options[mySelect.options.length] = new Option("Marion schools",'all=Marion');
mySelect.options[mySelect.options.length] = new Option("Mc Daniels schools",'all=Mc_Daniels');
mySelect.options[mySelect.options.length] = new Option("Midway schools",'all=Midway');
mySelect.options[mySelect.options.length] = new Option("Nicholasville schools",'all=Nicholasville');
mySelect.options[mySelect.options.length] = new Option("Radcliff schools",'all=Radcliff');
mySelect.options[mySelect.options.length] = new Option("Shepherdsville schools",'all=Shepherdsville');
mySelect.options[mySelect.options.length] = new Option("Somerset schools",'all=Somerset');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Mc_Daniels[Mc_Daniels.length] = createMarker(new GPoint(-86.44850000,37.61940000),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethel Christian School",'Mc_Daniels=' + Mc_Daniels.length);
Letcher[Letcher.length] = createMarker(new GPoint(-82.98340000,37.15820000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calvary Christian Academy",'Letcher=' + Letcher.length);
Independence[Independence.length] = createMarker(new GPoint(-84.53084200,38.90967700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Community Christian Academy",'Independence=' + Independence.length);
Corbin[Corbin.length] = createMarker(new GPoint(-84.07586800,36.95980700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Corbin Christian Academy",'Corbin=' + Corbin.length);
Louisville[Louisville.length] = createMarker(new GPoint(-85.75117400,38.21366300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Families For Christ Chr Academy",'Louisville=' + Louisville.length);
Fonde[Fonde.length] = createMarker(new GPoint(-83.92480000,36.62750000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fonde Christian Academy",'Fonde=' + Fonde.length);
Garrett[Garrett.length] = createMarker(new GPoint(-82.85046100,37.47370700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Garrett Christian Academy",'Garrett=' + Garrett.length);
Radcliff[Radcliff.length] = createMarker(new GPoint(-85.92131600,37.81324900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hardin Christian Academy",'Radcliff=' + Radcliff.length);
Lawrenceburg[Lawrenceburg.length] = createMarker(new GPoint(-84.92616100,38.02040900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Harvest Christian School",'Lawrenceburg=' + Lawrenceburg.length);
Hodgenville[Hodgenville.length] = createMarker(new GPoint(-85.73655400,37.53210900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Larue Baptist School",'Hodgenville=' + Hodgenville.length);
Hawesville[Hawesville.length] = createMarker(new GPoint(-86.72891300,37.80875800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Liberty Christian School",'Hawesville=' + Hawesville.length);
Ledbetter[Ledbetter.length] = createMarker(new GPoint(-88.48470000,37.04960000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lighthouse Christian Academy",'Ledbetter=' + Ledbetter.length);
London[London.length] = createMarker(new GPoint(-84.07567200,37.11368800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("London Christian Academy",'London=' + London.length);
Marion[Marion.length] = createMarker(new GPoint(-88.07913500,37.34426100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Marion Church Of God Christian School",'Marion=' + Marion.length);
Midway[Midway.length] = createMarker(new GPoint(-84.68224800,38.15985600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Hope Christian Academy",'Midway=' + Midway.length);
Shepherdsville[Shepherdsville.length] = createMarker(new GPoint(-85.68133900,38.04357400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rolling Hills Christian Schools",'Shepherdsville=' + Shepherdsville.length);
Louisville[Louisville.length] = createMarker(new GPoint(-85.76458900,38.17815400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. John Vianney Elementary School",'Louisville=' + Louisville.length);
Somerset[Somerset.length] = createMarker(new GPoint(-84.66102800,37.08629300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Saline Christian Academy",'Somerset=' + Somerset.length);
Ashland[Ashland.length] = createMarker(new GPoint(-82.64570000,38.48010000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Solid Rock Christian Academy",'Ashland=' + Ashland.length);
Louisville[Louisville.length] = createMarker(new GPoint(-85.75117400,38.21366300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Song Of David Day Care Center",'Louisville=' + Louisville.length);
Bardstown[Bardstown.length] = createMarker(new GPoint(-85.47071100,37.81004000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Joseph School",'Bardstown=' + Bardstown.length);
Fordsville[Fordsville.length] = createMarker(new GPoint(-86.79450900,37.60812800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sugar Grove Christian Academy",'Fordsville=' + Fordsville.length);
Nicholasville[Nicholasville.length] = createMarker(new GPoint(-84.54894600,37.93162800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tabernacle Christian Academy",'Nicholasville=' + Nicholasville.length);
Louisville[Louisville.length] = createMarker(new GPoint(-85.70154000,38.16379600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Thomas Merton Academy",'Louisville=' + Louisville.length);
map.removeOverlays(Ashland);
map.removeOverlays(Bardstown);
map.removeOverlays(Corbin);
map.removeOverlays(Fonde);
map.removeOverlays(Fordsville);
map.removeOverlays(Garrett);
map.removeOverlays(Hawesville);
map.removeOverlays(Hodgenville);
map.removeOverlays(Independence);
map.removeOverlays(Lawrenceburg);
map.removeOverlays(Ledbetter);
map.removeOverlays(Letcher);
map.removeOverlays(London);
map.removeOverlays(Louisville);
map.removeOverlays(Marion);
map.removeOverlays(Mc_Daniels);
map.removeOverlays(Midway);
map.removeOverlays(Nicholasville);
map.removeOverlays(Radcliff);
map.removeOverlays(Shepherdsville);
map.removeOverlays(Somerset);
setTimeout(function(){map.addOverlays(Ashland)},1000);
setTimeout(function(){map.addOverlays(Bardstown)},1000);
setTimeout(function(){map.addOverlays(Corbin)},1000);
setTimeout(function(){map.addOverlays(Fonde)},1000);
setTimeout(function(){map.addOverlays(Fordsville)},1000);
setTimeout(function(){map.addOverlays(Garrett)},1000);
setTimeout(function(){map.addOverlays(Hawesville)},1000);
setTimeout(function(){map.addOverlays(Hodgenville)},1000);
setTimeout(function(){map.addOverlays(Independence)},1000);
setTimeout(function(){map.addOverlays(Lawrenceburg)},1000);
setTimeout(function(){map.addOverlays(Ledbetter)},1000);
setTimeout(function(){map.addOverlays(Letcher)},1000);
setTimeout(function(){map.addOverlays(London)},1000);
setTimeout(function(){map.addOverlays(Louisville)},1000);
setTimeout(function(){map.addOverlays(Marion)},1000);
setTimeout(function(){map.addOverlays(Mc_Daniels)},1000);
setTimeout(function(){map.addOverlays(Midway)},1000);
setTimeout(function(){map.addOverlays(Nicholasville)},1000);
setTimeout(function(){map.addOverlays(Radcliff)},1000);
setTimeout(function(){map.addOverlays(Shepherdsville)},1000);
setTimeout(function(){map.addOverlays(Somerset)},1000);
maxLng = -82.64570000;
maxLat = 38.90967700;
minLng = -88.48470000;
minLat = 36.62750000;
reCenterMap();
} // 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,11);
/*
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(Ashland);
map.removeOverlays(Bardstown);
map.removeOverlays(Corbin);
map.removeOverlays(Fonde);
map.removeOverlays(Fordsville);
map.removeOverlays(Garrett);
map.removeOverlays(Hawesville);
map.removeOverlays(Hodgenville);
map.removeOverlays(Independence);
map.removeOverlays(Lawrenceburg);
map.removeOverlays(Ledbetter);
map.removeOverlays(Letcher);
map.removeOverlays(London);
map.removeOverlays(Louisville);
map.removeOverlays(Marion);
map.removeOverlays(Mc_Daniels);
map.removeOverlays(Midway);
map.removeOverlays(Nicholasville);
map.removeOverlays(Radcliff);
map.removeOverlays(Shepherdsville);
map.removeOverlays(Somerset);
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(Mc_Daniels);map.removeOverlays(Ashland);
map.removeOverlays(Bardstown);
map.removeOverlays(Corbin);
map.removeOverlays(Fonde);
map.removeOverlays(Fordsville);
map.removeOverlays(Garrett);
map.removeOverlays(Hawesville);
map.removeOverlays(Hodgenville);
map.removeOverlays(Independence);
map.removeOverlays(Lawrenceburg);
map.removeOverlays(Ledbetter);
map.removeOverlays(Letcher);
map.removeOverlays(London);
map.removeOverlays(Louisville);
map.removeOverlays(Marion);
map.removeOverlays(Mc_Daniels);
map.removeOverlays(Midway);
map.removeOverlays(Nicholasville);
map.removeOverlays(Radcliff);
map.removeOverlays(Shepherdsville);
map.removeOverlays(Somerset);
map.addOverlays(Ashland);
centerByArray(Ashland, false, false);
cntMarker += Ashland.length;
map.addOverlays(Bardstown);
centerByArray(Bardstown, false, false);
cntMarker += Bardstown.length;
map.addOverlays(Corbin);
centerByArray(Corbin, false, false);
cntMarker += Corbin.length;
map.addOverlays(Fonde);
centerByArray(Fonde, false, false);
cntMarker += Fonde.length;
map.addOverlays(Fordsville);
centerByArray(Fordsville, false, false);
cntMarker += Fordsville.length;
map.addOverlays(Garrett);
centerByArray(Garrett, false, false);
cntMarker += Garrett.length;
map.addOverlays(Hawesville);
centerByArray(Hawesville, false, false);
cntMarker += Hawesville.length;
map.addOverlays(Hodgenville);
centerByArray(Hodgenville, false, false);
cntMarker += Hodgenville.length;
map.addOverlays(Independence);
centerByArray(Independence, false, false);
cntMarker += Independence.length;
map.addOverlays(Lawrenceburg);
centerByArray(Lawrenceburg, false, false);
cntMarker += Lawrenceburg.length;
map.addOverlays(Ledbetter);
centerByArray(Ledbetter, false, false);
cntMarker += Ledbetter.length;
map.addOverlays(Letcher);
centerByArray(Letcher, false, false);
cntMarker += Letcher.length;
map.addOverlays(London);
centerByArray(London, false, false);
cntMarker += London.length;
map.addOverlays(Louisville);
centerByArray(Louisville, false, false);
cntMarker += Louisville.length;
map.addOverlays(Marion);
centerByArray(Marion, false, false);
cntMarker += Marion.length;
map.addOverlays(Mc_Daniels);
centerByArray(Mc_Daniels, false, false);
cntMarker += Mc_Daniels.length;
map.addOverlays(Midway);
centerByArray(Midway, false, false);
cntMarker += Midway.length;
map.addOverlays(Nicholasville);
centerByArray(Nicholasville, false, false);
cntMarker += Nicholasville.length;
map.addOverlays(Radcliff);
centerByArray(Radcliff, false, false);
cntMarker += Radcliff.length;
map.addOverlays(Shepherdsville);
centerByArray(Shepherdsville, false, false);
cntMarker += Shepherdsville.length;
map.addOverlays(Somerset);
centerByArray(Somerset, false, false);
cntMarker += Somerset.length;
centerByArray(Mc_Daniels,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///11270,11123,11148,33160,11255,11194,11120,33544,11198,11090,11204,11146,11212,11081,11233,11162,11271,11280,11270,11335,11123,11148,11373,33160,11255,11194,11120,33544,11198,11090,11204,11146,11332,11462,11382,11212,11081,11233,11375,11162,11271,11280,/all');
//window.open('/map.php?type=2&schools=11270,11123,11148,33160,11255,11194,11120,33544,11198,11090,11204,11146,11212,11081,11233,11162,11271,11280,11270,11335,11123,11148,11373,33160,11255,11194,11120,33544,11198,11090,11204,11146,11332,11462,11382,11212,11081,11233,11375,11162,11271,11280,&school_level=&radius=&zipcode=&school_type_search=&school_type_code=');
}
}
function createMarker(point, label, icon)
{
var marker = new GMarker(point, icon);
var html = label;
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}