function addMarkers(){
mySelect = document.getElementById('selection');
Louisville = [];Park_Hills = [];Erlanger = [];S_Portsmouth = [];Covington = [];Ashland = [];Lexington = [];Hebron = [];Walton = [];Florence = [];Millersburg = [];Owensboro = [];Martin = [];Goshen = [];Middlesboro = [];Taylor_Mill = [];mySelect.options[mySelect.options.length] = new Option("Ashland schools",'all=Ashland');
mySelect.options[mySelect.options.length] = new Option("Covington schools",'all=Covington');
mySelect.options[mySelect.options.length] = new Option("Erlanger schools",'all=Erlanger');
mySelect.options[mySelect.options.length] = new Option("Florence schools",'all=Florence');
mySelect.options[mySelect.options.length] = new Option("Goshen schools",'all=Goshen');
mySelect.options[mySelect.options.length] = new Option("Hebron schools",'all=Hebron');
mySelect.options[mySelect.options.length] = new Option("Lexington schools",'all=Lexington');
mySelect.options[mySelect.options.length] = new Option("Louisville schools",'all=Louisville');
mySelect.options[mySelect.options.length] = new Option("Martin schools",'all=Martin');
mySelect.options[mySelect.options.length] = new Option("Middlesboro schools",'all=Middlesboro');
mySelect.options[mySelect.options.length] = new Option("Millersburg schools",'all=Millersburg');
mySelect.options[mySelect.options.length] = new Option("Owensboro schools",'all=Owensboro');
mySelect.options[mySelect.options.length] = new Option("Park Hills schools",'all=Park_Hills');
mySelect.options[mySelect.options.length] = new Option("S Portsmouth schools",'all=S_Portsmouth');
mySelect.options[mySelect.options.length] = new Option("Taylor Mill schools",'all=Taylor_Mill');
mySelect.options[mySelect.options.length] = new Option("Walton schools",'all=Walton');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Louisville[Louisville.length] = createMarker(new GPoint(-85.58677700,38.21131700),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christ Lutheran Preschool & Kindergarten",'Louisville=' + Louisville.length);
Park_Hills[Park_Hills.length] = createMarker(new GPoint(-84.53295200,39.06516200),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Covington Catholic High School",'Park_Hills=' + Park_Hills.length);
Erlanger[Erlanger.length] = createMarker(new GPoint(-84.60185900,39.01814100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grace Academy Of Creative Learning, Inc.",'Erlanger=' + Erlanger.length);
S_Portsmouth[S_Portsmouth.length] = createMarker(new GPoint(-83.02096900,38.71636000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Harvest Christian Academy",'S_Portsmouth=' + S_Portsmouth.length);
Louisville[Louisville.length] = createMarker(new GPoint(-85.75435600,38.23851200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Heuser Hearing & Language Academy",'Louisville=' + Louisville.length);
Covington[Covington.length] = createMarker(new GPoint(-84.50207600,39.04838800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Cross High School",'Covington=' + Covington.length);
Ashland[Ashland.length] = createMarker(new GPoint(-82.64707700,38.48229600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Family School",'Ashland=' + Ashland.length);
Erlanger[Erlanger.length] = createMarker(new GPoint(-84.61314400,39.04687400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Imagine Tomorrow Child Dev Center",'Erlanger=' + Erlanger.length);
Lexington[Lexington.length] = createMarker(new GPoint(-84.43107300,38.01699300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lexington Christian Academy",'Lexington=' + Lexington.length);
Hebron[Hebron.length] = createMarker(new GPoint(-84.70656100,39.07885700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Little Red School House",'Hebron=' + Hebron.length);
Walton[Walton.length] = createMarker(new GPoint(-84.63512800,38.91610700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Little Red School House",'Walton=' + Walton.length);
Erlanger[Erlanger.length] = createMarker(new GPoint(-84.60800100,39.01164300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Little Red School House Elementary I",'Erlanger=' + Erlanger.length);
Florence[Florence.length] = createMarker(new GPoint(-84.66029300,38.97586500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Little Red School House Iv",'Florence=' + Florence.length);
Louisville[Louisville.length] = createMarker(new GPoint(-85.63988700,38.17011100),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mercy Academy",'Louisville=' + Louisville.length);
Millersburg[Millersburg.length] = createMarker(new GPoint(-84.14650000,38.30280000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Millersburg Military Institute",'Millersburg=' + Millersburg.length);
Park_Hills[Park_Hills.length] = createMarker(new GPoint(-84.53202200,39.06216300),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Notre Dame Academy",'Park_Hills=' + Park_Hills.length);
Owensboro[Owensboro.length] = createMarker(new GPoint(-87.12747100,37.76005100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Owensboro Catholic High School",'Owensboro=' + Owensboro.length);
Martin[Martin.length] = createMarker(new GPoint(-82.76588700,37.55961700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Piarist School",'Martin=' + Martin.length);
Louisville[Louisville.length] = createMarker(new GPoint(-85.62229700,38.27210000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Albert The Great School",'Louisville=' + Louisville.length);
Goshen[Goshen.length] = createMarker(new GPoint(-85.56840000,38.41310000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Francis School",'Goshen=' + Goshen.length);
Middlesboro[Middlesboro.length] = createMarker(new GPoint(-83.71371200,36.60578600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Julian School",'Middlesboro=' + Middlesboro.length);
Covington[Covington.length] = createMarker(new GPoint(-84.53459400,39.08979500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Ann's Child Development Center",'Covington=' + Covington.length);
Louisville[Louisville.length] = createMarker(new GPoint(-85.75560900,38.24604400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Francis High School",'Louisville=' + Louisville.length);
Taylor_Mill[Taylor_Mill.length] = createMarker(new GPoint(-84.49781600,39.01567300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Taylor Mill Christian Academy",'Taylor_Mill=' + Taylor_Mill.length);
Louisville[Louisville.length] = createMarker(new GPoint(-85.64902200,38.22646500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Torah Academy",'Louisville=' + Louisville.length);
map.removeOverlays(Ashland);
map.removeOverlays(Covington);
map.removeOverlays(Erlanger);
map.removeOverlays(Florence);
map.removeOverlays(Goshen);
map.removeOverlays(Hebron);
map.removeOverlays(Lexington);
map.removeOverlays(Louisville);
map.removeOverlays(Martin);
map.removeOverlays(Middlesboro);
map.removeOverlays(Millersburg);
map.removeOverlays(Owensboro);
map.removeOverlays(Park_Hills);
map.removeOverlays(S_Portsmouth);
map.removeOverlays(Taylor_Mill);
map.removeOverlays(Walton);
setTimeout(function(){map.addOverlays(Ashland)},1000);
setTimeout(function(){map.addOverlays(Covington)},1000);
setTimeout(function(){map.addOverlays(Erlanger)},1000);
setTimeout(function(){map.addOverlays(Florence)},1000);
setTimeout(function(){map.addOverlays(Goshen)},1000);
setTimeout(function(){map.addOverlays(Hebron)},1000);
setTimeout(function(){map.addOverlays(Lexington)},1000);
setTimeout(function(){map.addOverlays(Louisville)},1000);
setTimeout(function(){map.addOverlays(Martin)},1000);
setTimeout(function(){map.addOverlays(Middlesboro)},1000);
setTimeout(function(){map.addOverlays(Millersburg)},1000);
setTimeout(function(){map.addOverlays(Owensboro)},1000);
setTimeout(function(){map.addOverlays(Park_Hills)},1000);
setTimeout(function(){map.addOverlays(S_Portsmouth)},1000);
setTimeout(function(){map.addOverlays(Taylor_Mill)},1000);
setTimeout(function(){map.addOverlays(Walton)},1000);
maxLng = -82.64707700;
maxLat = 39.08979500;
minLng = -87.12747100;
minLat = 36.60578600;
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(Covington);
map.removeOverlays(Erlanger);
map.removeOverlays(Florence);
map.removeOverlays(Goshen);
map.removeOverlays(Hebron);
map.removeOverlays(Lexington);
map.removeOverlays(Louisville);
map.removeOverlays(Martin);
map.removeOverlays(Middlesboro);
map.removeOverlays(Millersburg);
map.removeOverlays(Owensboro);
map.removeOverlays(Park_Hills);
map.removeOverlays(S_Portsmouth);
map.removeOverlays(Taylor_Mill);
map.removeOverlays(Walton);
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(Louisville);map.removeOverlays(Ashland);
map.removeOverlays(Covington);
map.removeOverlays(Erlanger);
map.removeOverlays(Florence);
map.removeOverlays(Goshen);
map.removeOverlays(Hebron);
map.removeOverlays(Lexington);
map.removeOverlays(Louisville);
map.removeOverlays(Martin);
map.removeOverlays(Middlesboro);
map.removeOverlays(Millersburg);
map.removeOverlays(Owensboro);
map.removeOverlays(Park_Hills);
map.removeOverlays(S_Portsmouth);
map.removeOverlays(Taylor_Mill);
map.removeOverlays(Walton);
map.addOverlays(Ashland);
centerByArray(Ashland, false, false);
cntMarker += Ashland.length;
map.addOverlays(Covington);
centerByArray(Covington, false, false);
cntMarker += Covington.length;
map.addOverlays(Erlanger);
centerByArray(Erlanger, false, false);
cntMarker += Erlanger.length;
map.addOverlays(Florence);
centerByArray(Florence, false, false);
cntMarker += Florence.length;
map.addOverlays(Goshen);
centerByArray(Goshen, false, false);
cntMarker += Goshen.length;
map.addOverlays(Hebron);
centerByArray(Hebron, false, false);
cntMarker += Hebron.length;
map.addOverlays(Lexington);
centerByArray(Lexington, false, false);
cntMarker += Lexington.length;
map.addOverlays(Louisville);
centerByArray(Louisville, false, false);
cntMarker += Louisville.length;
map.addOverlays(Martin);
centerByArray(Martin, false, false);
cntMarker += Martin.length;
map.addOverlays(Middlesboro);
centerByArray(Middlesboro, false, false);
cntMarker += Middlesboro.length;
map.addOverlays(Millersburg);
centerByArray(Millersburg, false, false);
cntMarker += Millersburg.length;
map.addOverlays(Owensboro);
centerByArray(Owensboro, false, false);
cntMarker += Owensboro.length;
map.addOverlays(Park_Hills);
centerByArray(Park_Hills, false, false);
cntMarker += Park_Hills.length;
map.addOverlays(S_Portsmouth);
centerByArray(S_Portsmouth, false, false);
cntMarker += S_Portsmouth.length;
map.addOverlays(Taylor_Mill);
centerByArray(Taylor_Mill, false, false);
cntMarker += Taylor_Mill.length;
map.addOverlays(Walton);
centerByArray(Walton, false, false);
cntMarker += Walton.length;
centerByArray(Louisville,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///11174,35964,11217,11318,11259,11222,11252,11127,11240,35965,11177,11464,35964,35963,11201,11451,11321,11448,11442,11106,11206,11294,35967,11340,35965,11129,11452,/all');
//window.open('/map.php?type=2&schools=11174,35964,11217,11318,11259,11222,11252,11127,11240,35965,11177,11464,35964,35963,11201,11451,11321,11448,11442,11106,11206,11294,35967,11340,35965,11129,11452,&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;
}