function addMarkers(){
mySelect = document.getElementById('selection');
Bowling_Green = [];Georgetown = [];Louisville = [];Lexington = [];Dayton = [];Highland_Heights = [];Erlanger = [];Nicholasville = [];Danville = [];Flatwoods = [];Glasgow = [];Covington = [];Elizabethtown = [];Frankfort = [];Morehead = [];Maysville = [];Crescent_Springs = [];Nazareth = [];Paducah = [];Newport = [];Versailles = [];Villa_Hills = [];mySelect.options[mySelect.options.length] = new Option("Bowling Green schools",'all=Bowling_Green');
mySelect.options[mySelect.options.length] = new Option("Covington schools",'all=Covington');
mySelect.options[mySelect.options.length] = new Option("Crescent Springs schools",'all=Crescent_Springs');
mySelect.options[mySelect.options.length] = new Option("Danville schools",'all=Danville');
mySelect.options[mySelect.options.length] = new Option("Dayton schools",'all=Dayton');
mySelect.options[mySelect.options.length] = new Option("Elizabethtown schools",'all=Elizabethtown');
mySelect.options[mySelect.options.length] = new Option("Erlanger schools",'all=Erlanger');
mySelect.options[mySelect.options.length] = new Option("Flatwoods schools",'all=Flatwoods');
mySelect.options[mySelect.options.length] = new Option("Frankfort schools",'all=Frankfort');
mySelect.options[mySelect.options.length] = new Option("Georgetown schools",'all=Georgetown');
mySelect.options[mySelect.options.length] = new Option("Glasgow schools",'all=Glasgow');
mySelect.options[mySelect.options.length] = new Option("Highland Heights schools",'all=Highland_Heights');
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("Maysville schools",'all=Maysville');
mySelect.options[mySelect.options.length] = new Option("Morehead schools",'all=Morehead');
mySelect.options[mySelect.options.length] = new Option("Nazareth schools",'all=Nazareth');
mySelect.options[mySelect.options.length] = new Option("Newport schools",'all=Newport');
mySelect.options[mySelect.options.length] = new Option("Nicholasville schools",'all=Nicholasville');
mySelect.options[mySelect.options.length] = new Option("Paducah schools",'all=Paducah');
mySelect.options[mySelect.options.length] = new Option("Versailles schools",'all=Versailles');
mySelect.options[mySelect.options.length] = new Option("Villa Hills schools",'all=Villa_Hills');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Bowling_Green[Bowling_Green.length] = createMarker(new GPoint(-86.47774800,36.94903700),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Children's House Montessori",'Bowling_Green=' + Bowling_Green.length);
Georgetown[Georgetown.length] = createMarker(new GPoint(-84.55802400,38.20868300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Childrens Montessori School",'Georgetown=' + Georgetown.length);
Louisville[Louisville.length] = createMarker(new GPoint(-85.82527600,38.24948700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christ The King Learning Center",'Louisville=' + Louisville.length);
Lexington[Lexington.length] = createMarker(new GPoint(-84.51325500,38.00909000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Community Montessori School",'Lexington=' + Lexington.length);
Dayton[Dayton.length] = createMarker(new GPoint(-84.47222700,39.11494700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cornerstone Montessori School",'Dayton=' + Dayton.length);
Highland_Heights[Highland_Heights.length] = createMarker(new GPoint(-84.44628900,39.04465400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cornerstone Montessori School",'Highland_Heights=' + Highland_Heights.length);
Erlanger[Erlanger.length] = createMarker(new GPoint(-84.61439500,39.03054800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Country Hills Montessori-erlanger",'Erlanger=' + Erlanger.length);
Nicholasville[Nicholasville.length] = createMarker(new GPoint(-84.35726000,38.14126000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Creative Montessori School",'Nicholasville=' + Nicholasville.length);
Danville[Danville.length] = createMarker(new GPoint(-84.76547600,37.64553700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Danville Montessori School",'Danville=' + Danville.length);
Louisville[Louisville.length] = createMarker(new GPoint(-85.68335400,38.21412400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hayfield Montessori School",'Louisville=' + Louisville.length);
Louisville[Louisville.length] = createMarker(new GPoint(-85.75396300,38.22927300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kenwood Montessori School",'Louisville=' + Louisville.length);
Lexington[Lexington.length] = createMarker(new GPoint(-84.51236900,38.03789200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lexington Montessori",'Lexington=' + Lexington.length);
Flatwoods[Flatwoods.length] = createMarker(new GPoint(-82.71454700,38.52049900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lisa's Learning Center",'Flatwoods=' + Flatwoods.length);
Louisville[Louisville.length] = createMarker(new GPoint(-85.67814800,38.21754700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mercy Montessori School",'Louisville=' + Louisville.length);
Glasgow[Glasgow.length] = createMarker(new GPoint(-85.93153800,36.98945100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Academy Of Glasgow",'Glasgow=' + Glasgow.length);
Covington[Covington.length] = createMarker(new GPoint(-84.51144200,39.08588600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori At 5th St.",'Covington=' + Covington.length);
Elizabethtown[Elizabethtown.length] = createMarker(new GPoint(-85.86639600,37.69987500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Children's Center",'Elizabethtown=' + Elizabethtown.length);
Lexington[Lexington.length] = createMarker(new GPoint(-84.51207100,38.02762000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Middle School Of Kentucky",'Lexington=' + Lexington.length);
Frankfort[Frankfort.length] = createMarker(new GPoint(-84.85092900,38.21799300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School Of Frankfort",'Frankfort=' + Frankfort.length);
Morehead[Morehead.length] = createMarker(new GPoint(-83.42894100,38.18186100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Morehead Montessori",'Morehead=' + Morehead.length);
Maysville[Maysville.length] = createMarker(new GPoint(-83.76486400,38.64689700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Nativity Montessori School",'Maysville=' + Maysville.length);
Crescent_Springs[Crescent_Springs.length] = createMarker(new GPoint(-84.58249600,39.04895500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northern Ky Montessori Center",'Crescent_Springs=' + Crescent_Springs.length);
Lexington[Lexington.length] = createMarker(new GPoint(-84.52038400,38.05976800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Providence Montessori School",'Lexington=' + Lexington.length);
Nazareth[Nazareth.length] = createMarker(new GPoint(-85.47410300,37.84716200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Joseph Montessori Children's Center",'Nazareth=' + Nazareth.length);
Lexington[Lexington.length] = createMarker(new GPoint(-84.54352800,38.02065000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Southern Hills Montessori School",'Lexington=' + Lexington.length);
Paducah[Paducah.length] = createMarker(new GPoint(-88.59732300,37.06367100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Speedwell Montessori",'Paducah=' + Paducah.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);
Newport[Newport.length] = createMarker(new GPoint(-84.49110400,39.09679700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trent Montessori Preschool",'Newport=' + Newport.length);
Louisville[Louisville.length] = createMarker(new GPoint(-85.67729600,38.24883700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ursuline Montessori School",'Louisville=' + Louisville.length);
Versailles[Versailles.length] = createMarker(new GPoint(-84.71488100,38.00430300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Versailles Montessori School",'Versailles=' + Versailles.length);
Villa_Hills[Villa_Hills.length] = createMarker(new GPoint(-84.58580200,39.06624800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Villa Madonna Montessori",'Villa_Hills=' + Villa_Hills.length);
map.removeOverlays(Bowling_Green);
map.removeOverlays(Covington);
map.removeOverlays(Crescent_Springs);
map.removeOverlays(Danville);
map.removeOverlays(Dayton);
map.removeOverlays(Elizabethtown);
map.removeOverlays(Erlanger);
map.removeOverlays(Flatwoods);
map.removeOverlays(Frankfort);
map.removeOverlays(Georgetown);
map.removeOverlays(Glasgow);
map.removeOverlays(Highland_Heights);
map.removeOverlays(Lexington);
map.removeOverlays(Louisville);
map.removeOverlays(Maysville);
map.removeOverlays(Morehead);
map.removeOverlays(Nazareth);
map.removeOverlays(Newport);
map.removeOverlays(Nicholasville);
map.removeOverlays(Paducah);
map.removeOverlays(Versailles);
map.removeOverlays(Villa_Hills);
setTimeout(function(){map.addOverlays(Bowling_Green)},1000);
setTimeout(function(){map.addOverlays(Covington)},1000);
setTimeout(function(){map.addOverlays(Crescent_Springs)},1000);
setTimeout(function(){map.addOverlays(Danville)},1000);
setTimeout(function(){map.addOverlays(Dayton)},1000);
setTimeout(function(){map.addOverlays(Elizabethtown)},1000);
setTimeout(function(){map.addOverlays(Erlanger)},1000);
setTimeout(function(){map.addOverlays(Flatwoods)},1000);
setTimeout(function(){map.addOverlays(Frankfort)},1000);
setTimeout(function(){map.addOverlays(Georgetown)},1000);
setTimeout(function(){map.addOverlays(Glasgow)},1000);
setTimeout(function(){map.addOverlays(Highland_Heights)},1000);
setTimeout(function(){map.addOverlays(Lexington)},1000);
setTimeout(function(){map.addOverlays(Louisville)},1000);
setTimeout(function(){map.addOverlays(Maysville)},1000);
setTimeout(function(){map.addOverlays(Morehead)},1000);
setTimeout(function(){map.addOverlays(Nazareth)},1000);
setTimeout(function(){map.addOverlays(Newport)},1000);
setTimeout(function(){map.addOverlays(Nicholasville)},1000);
setTimeout(function(){map.addOverlays(Paducah)},1000);
setTimeout(function(){map.addOverlays(Versailles)},1000);
setTimeout(function(){map.addOverlays(Villa_Hills)},1000);
maxLng = -82.71454700;
maxLat = 39.11494700;
minLng = -88.59732300;
minLat = 36.94903700;
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(Bowling_Green);
map.removeOverlays(Covington);
map.removeOverlays(Crescent_Springs);
map.removeOverlays(Danville);
map.removeOverlays(Dayton);
map.removeOverlays(Elizabethtown);
map.removeOverlays(Erlanger);
map.removeOverlays(Flatwoods);
map.removeOverlays(Frankfort);
map.removeOverlays(Georgetown);
map.removeOverlays(Glasgow);
map.removeOverlays(Highland_Heights);
map.removeOverlays(Lexington);
map.removeOverlays(Louisville);
map.removeOverlays(Maysville);
map.removeOverlays(Morehead);
map.removeOverlays(Nazareth);
map.removeOverlays(Newport);
map.removeOverlays(Nicholasville);
map.removeOverlays(Paducah);
map.removeOverlays(Versailles);
map.removeOverlays(Villa_Hills);
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(Bowling_Green);map.removeOverlays(Bowling_Green);
map.removeOverlays(Covington);
map.removeOverlays(Crescent_Springs);
map.removeOverlays(Danville);
map.removeOverlays(Dayton);
map.removeOverlays(Elizabethtown);
map.removeOverlays(Erlanger);
map.removeOverlays(Flatwoods);
map.removeOverlays(Frankfort);
map.removeOverlays(Georgetown);
map.removeOverlays(Glasgow);
map.removeOverlays(Highland_Heights);
map.removeOverlays(Lexington);
map.removeOverlays(Louisville);
map.removeOverlays(Maysville);
map.removeOverlays(Morehead);
map.removeOverlays(Nazareth);
map.removeOverlays(Newport);
map.removeOverlays(Nicholasville);
map.removeOverlays(Paducah);
map.removeOverlays(Versailles);
map.removeOverlays(Villa_Hills);
map.addOverlays(Bowling_Green);
centerByArray(Bowling_Green, false, false);
cntMarker += Bowling_Green.length;
map.addOverlays(Covington);
centerByArray(Covington, false, false);
cntMarker += Covington.length;
map.addOverlays(Crescent_Springs);
centerByArray(Crescent_Springs, false, false);
cntMarker += Crescent_Springs.length;
map.addOverlays(Danville);
centerByArray(Danville, false, false);
cntMarker += Danville.length;
map.addOverlays(Dayton);
centerByArray(Dayton, false, false);
cntMarker += Dayton.length;
map.addOverlays(Elizabethtown);
centerByArray(Elizabethtown, false, false);
cntMarker += Elizabethtown.length;
map.addOverlays(Erlanger);
centerByArray(Erlanger, false, false);
cntMarker += Erlanger.length;
map.addOverlays(Flatwoods);
centerByArray(Flatwoods, false, false);
cntMarker += Flatwoods.length;
map.addOverlays(Frankfort);
centerByArray(Frankfort, false, false);
cntMarker += Frankfort.length;
map.addOverlays(Georgetown);
centerByArray(Georgetown, false, false);
cntMarker += Georgetown.length;
map.addOverlays(Glasgow);
centerByArray(Glasgow, false, false);
cntMarker += Glasgow.length;
map.addOverlays(Highland_Heights);
centerByArray(Highland_Heights, false, false);
cntMarker += Highland_Heights.length;
map.addOverlays(Lexington);
centerByArray(Lexington, false, false);
cntMarker += Lexington.length;
map.addOverlays(Louisville);
centerByArray(Louisville, false, false);
cntMarker += Louisville.length;
map.addOverlays(Maysville);
centerByArray(Maysville, false, false);
cntMarker += Maysville.length;
map.addOverlays(Morehead);
centerByArray(Morehead, false, false);
cntMarker += Morehead.length;
map.addOverlays(Nazareth);
centerByArray(Nazareth, false, false);
cntMarker += Nazareth.length;
map.addOverlays(Newport);
centerByArray(Newport, false, false);
cntMarker += Newport.length;
map.addOverlays(Nicholasville);
centerByArray(Nicholasville, false, false);
cntMarker += Nicholasville.length;
map.addOverlays(Paducah);
centerByArray(Paducah, false, false);
cntMarker += Paducah.length;
map.addOverlays(Versailles);
centerByArray(Versailles, false, false);
cntMarker += Versailles.length;
map.addOverlays(Villa_Hills);
centerByArray(Villa_Hills, false, false);
cntMarker += Villa_Hills.length;
centerByArray(Bowling_Green,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///11413,11455,11464,11237,11133,34762,11225,11420,11443,11226,11101,34761,11419,11122,11197,34763,11266,11285,11475,11164,11192,11218,11389,11141,11456,34582,11383,11421,11287,11390,11394,/all');
//window.open('/map.php?type=2&schools=11413,11455,11464,11237,11133,34762,11225,11420,11443,11226,11101,34761,11419,11122,11197,34763,11266,11285,11475,11164,11192,11218,11389,11141,11456,34582,11383,11421,11287,11390,11394,&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;
}