function addMarkers(){
mySelect = document.getElementById('selection');
Saint_Louis = [];Kansas_City = [];Saint_Charles = [];Chesterfield = [];Bridgeton = [];Saint_Peters = [];Columbia = [];Liberty = [];Eldon = [];Lake_Saint_Louis = [];Ellisville = [];Jefferson_City = [];Kirkwood = [];Lees_Summit = [];Ballwin = [];Washington = [];mySelect.options[mySelect.options.length] = new Option("Ballwin schools",'all=Ballwin');
mySelect.options[mySelect.options.length] = new Option("Bridgeton schools",'all=Bridgeton');
mySelect.options[mySelect.options.length] = new Option("Chesterfield schools",'all=Chesterfield');
mySelect.options[mySelect.options.length] = new Option("Columbia schools",'all=Columbia');
mySelect.options[mySelect.options.length] = new Option("Eldon schools",'all=Eldon');
mySelect.options[mySelect.options.length] = new Option("Ellisville schools",'all=Ellisville');
mySelect.options[mySelect.options.length] = new Option("Jefferson City schools",'all=Jefferson_City');
mySelect.options[mySelect.options.length] = new Option("Kansas City schools",'all=Kansas_City');
mySelect.options[mySelect.options.length] = new Option("Kirkwood schools",'all=Kirkwood');
mySelect.options[mySelect.options.length] = new Option("Lake Saint Louis schools",'all=Lake_Saint_Louis');
mySelect.options[mySelect.options.length] = new Option("Lees Summit schools",'all=Lees_Summit');
mySelect.options[mySelect.options.length] = new Option("Liberty schools",'all=Liberty');
mySelect.options[mySelect.options.length] = new Option("Saint Charles schools",'all=Saint_Charles');
mySelect.options[mySelect.options.length] = new Option("Saint Louis schools",'all=Saint_Louis');
mySelect.options[mySelect.options.length] = new Option("Saint Peters schools",'all=Saint_Peters');
mySelect.options[mySelect.options.length] = new Option("Washington schools",'all=Washington');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Saint_Louis[Saint_Louis.length] = createMarker(new GPoint(-90.33679100,38.65184700),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("A Growing Place Montessori School",'Saint_Louis=' + Saint_Louis.length);
Kansas_City[Kansas_City.length] = createMarker(new GPoint(-94.60782300,38.90252100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Academy Montessori Internationale",'Kansas_City=' + Kansas_City.length);
Kansas_City[Kansas_City.length] = createMarker(new GPoint(-94.59321600,38.91963900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Alpha Montessori School, Inc.",'Kansas_City=' + Kansas_City.length);
Kansas_City[Kansas_City.length] = createMarker(new GPoint(-94.57830000,39.09970000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Belmont Schools, Inc",'Kansas_City=' + Kansas_City.length);
Saint_Charles[Saint_Charles.length] = createMarker(new GPoint(-90.57059900,38.80333000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Campbell Montessori School",'Saint_Charles=' + Saint_Charles.length);
Saint_Louis[Saint_Louis.length] = createMarker(new GPoint(-90.40862200,38.57583000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Casa Dia Montessori",'Saint_Louis=' + Saint_Louis.length);
Chesterfield[Chesterfield.length] = createMarker(new GPoint(-90.50813900,38.66131000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chesterfield Montessori School",'Chesterfield=' + Chesterfield.length);
Bridgeton[Bridgeton.length] = createMarker(new GPoint(-90.40263300,38.73991000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Children Of Promise Christian Montessori School",'Bridgeton=' + Bridgeton.length);
Saint_Peters[Saint_Peters.length] = createMarker(new GPoint(-90.62182400,38.77274900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Childrens Edu Care Center",'Saint_Peters=' + Saint_Peters.length);
Columbia[Columbia.length] = createMarker(new GPoint(-92.33051600,38.94065000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Childrens House Montessori Of Columbia",'Columbia=' + Columbia.length);
Liberty[Liberty.length] = createMarker(new GPoint(-94.41690000,39.26010000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Childrens Montessori Center",'Liberty=' + Liberty.length);
Columbia[Columbia.length] = createMarker(new GPoint(-92.34946600,38.95197200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Columbia Montessori School",'Columbia=' + Columbia.length);
Saint_Louis[Saint_Louis.length] = createMarker(new GPoint(-90.45536000,38.65536300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Countryside Montessori School",'Saint_Louis=' + Saint_Louis.length);
Saint_Louis[Saint_Louis.length] = createMarker(new GPoint(-90.42183400,38.63333700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Des Peres Montessori",'Saint_Louis=' + Saint_Louis.length);
Eldon[Eldon.length] = createMarker(new GPoint(-92.56599900,38.35183700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eldon Montessori Children's House",'Eldon=' + Eldon.length);
Saint_Louis[Saint_Louis.length] = createMarker(new GPoint(-90.35952300,38.59445200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Academy",'Saint_Louis=' + Saint_Louis.length);
Kansas_City[Kansas_City.length] = createMarker(new GPoint(-94.59763400,39.04236300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Global Montessori Academy",'Kansas_City=' + Kansas_City.length);
Lake_Saint_Louis[Lake_Saint_Louis.length] = createMarker(new GPoint(-90.76072600,38.80138300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hope Montessori Academy",'Lake_Saint_Louis=' + Lake_Saint_Louis.length);
Ellisville[Ellisville.length] = createMarker(new GPoint(-90.61859800,38.60544600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hope Montessori Academy West",'Ellisville=' + Ellisville.length);
Jefferson_City[Jefferson_City.length] = createMarker(new GPoint(-92.19028800,38.52406300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kim School Montessori",'Jefferson_City=' + Jefferson_City.length);
Kirkwood[Kirkwood.length] = createMarker(new GPoint(-90.41883000,38.56676300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kirkwood Children's House Inc.",'Kirkwood=' + Kirkwood.length);
Lees_Summit[Lees_Summit.length] = createMarker(new GPoint(-94.35538400,39.00106700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lakewood Montessori School",'Lees_Summit=' + Lees_Summit.length);
Lees_Summit[Lees_Summit.length] = createMarker(new GPoint(-94.42477100,38.90548900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lavonna Peterson Early School 3",'Lees_Summit=' + Lees_Summit.length);
Chesterfield[Chesterfield.length] = createMarker(new GPoint(-90.56476600,38.60593300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Linda Vista Catholic School",'Chesterfield=' + Chesterfield.length);
Kansas_City[Kansas_City.length] = createMarker(new GPoint(-94.57746400,39.07361700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Academy",'Kansas_City=' + Kansas_City.length);
Ballwin[Ballwin.length] = createMarker(new GPoint(-90.46548200,38.57956700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Childrens Academy",'Ballwin=' + Ballwin.length);
Jefferson_City[Jefferson_City.length] = createMarker(new GPoint(-92.16630700,38.56130500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Moreau Montessori School",'Jefferson_City=' + Jefferson_City.length);
Kansas_City[Kansas_City.length] = createMarker(new GPoint(-94.58498000,39.07437700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Union Hill Day School",'Kansas_City=' + Kansas_City.length);
Kirkwood[Kirkwood.length] = createMarker(new GPoint(-90.41412300,38.60234700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Villa Di Maria Montessori Center",'Kirkwood=' + Kirkwood.length);
Washington[Washington.length] = createMarker(new GPoint(-91.02284500,38.56363000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Washington Montessori School",'Washington=' + Washington.length);
map.removeOverlays(Ballwin);
map.removeOverlays(Bridgeton);
map.removeOverlays(Chesterfield);
map.removeOverlays(Columbia);
map.removeOverlays(Eldon);
map.removeOverlays(Ellisville);
map.removeOverlays(Jefferson_City);
map.removeOverlays(Kansas_City);
map.removeOverlays(Kirkwood);
map.removeOverlays(Lake_Saint_Louis);
map.removeOverlays(Lees_Summit);
map.removeOverlays(Liberty);
map.removeOverlays(Saint_Charles);
map.removeOverlays(Saint_Louis);
map.removeOverlays(Saint_Peters);
map.removeOverlays(Washington);
setTimeout(function(){map.addOverlays(Ballwin)},1000);
setTimeout(function(){map.addOverlays(Bridgeton)},1000);
setTimeout(function(){map.addOverlays(Chesterfield)},1000);
setTimeout(function(){map.addOverlays(Columbia)},1000);
setTimeout(function(){map.addOverlays(Eldon)},1000);
setTimeout(function(){map.addOverlays(Ellisville)},1000);
setTimeout(function(){map.addOverlays(Jefferson_City)},1000);
setTimeout(function(){map.addOverlays(Kansas_City)},1000);
setTimeout(function(){map.addOverlays(Kirkwood)},1000);
setTimeout(function(){map.addOverlays(Lake_Saint_Louis)},1000);
setTimeout(function(){map.addOverlays(Lees_Summit)},1000);
setTimeout(function(){map.addOverlays(Liberty)},1000);
setTimeout(function(){map.addOverlays(Saint_Charles)},1000);
setTimeout(function(){map.addOverlays(Saint_Louis)},1000);
setTimeout(function(){map.addOverlays(Saint_Peters)},1000);
setTimeout(function(){map.addOverlays(Washington)},1000);
maxLng = -90.33679100;
maxLat = 39.26010000;
minLng = -94.60782300;
minLat = 38.35183700;
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(Ballwin);
map.removeOverlays(Bridgeton);
map.removeOverlays(Chesterfield);
map.removeOverlays(Columbia);
map.removeOverlays(Eldon);
map.removeOverlays(Ellisville);
map.removeOverlays(Jefferson_City);
map.removeOverlays(Kansas_City);
map.removeOverlays(Kirkwood);
map.removeOverlays(Lake_Saint_Louis);
map.removeOverlays(Lees_Summit);
map.removeOverlays(Liberty);
map.removeOverlays(Saint_Charles);
map.removeOverlays(Saint_Louis);
map.removeOverlays(Saint_Peters);
map.removeOverlays(Washington);
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(Saint_Louis);map.removeOverlays(Ballwin);
map.removeOverlays(Bridgeton);
map.removeOverlays(Chesterfield);
map.removeOverlays(Columbia);
map.removeOverlays(Eldon);
map.removeOverlays(Ellisville);
map.removeOverlays(Jefferson_City);
map.removeOverlays(Kansas_City);
map.removeOverlays(Kirkwood);
map.removeOverlays(Lake_Saint_Louis);
map.removeOverlays(Lees_Summit);
map.removeOverlays(Liberty);
map.removeOverlays(Saint_Charles);
map.removeOverlays(Saint_Louis);
map.removeOverlays(Saint_Peters);
map.removeOverlays(Washington);
map.addOverlays(Ballwin);
centerByArray(Ballwin, false, false);
cntMarker += Ballwin.length;
map.addOverlays(Bridgeton);
centerByArray(Bridgeton, false, false);
cntMarker += Bridgeton.length;
map.addOverlays(Chesterfield);
centerByArray(Chesterfield, false, false);
cntMarker += Chesterfield.length;
map.addOverlays(Columbia);
centerByArray(Columbia, false, false);
cntMarker += Columbia.length;
map.addOverlays(Eldon);
centerByArray(Eldon, false, false);
cntMarker += Eldon.length;
map.addOverlays(Ellisville);
centerByArray(Ellisville, false, false);
cntMarker += Ellisville.length;
map.addOverlays(Jefferson_City);
centerByArray(Jefferson_City, false, false);
cntMarker += Jefferson_City.length;
map.addOverlays(Kansas_City);
centerByArray(Kansas_City, false, false);
cntMarker += Kansas_City.length;
map.addOverlays(Kirkwood);
centerByArray(Kirkwood, false, false);
cntMarker += Kirkwood.length;
map.addOverlays(Lake_Saint_Louis);
centerByArray(Lake_Saint_Louis, false, false);
cntMarker += Lake_Saint_Louis.length;
map.addOverlays(Lees_Summit);
centerByArray(Lees_Summit, false, false);
cntMarker += Lees_Summit.length;
map.addOverlays(Liberty);
centerByArray(Liberty, false, false);
cntMarker += Liberty.length;
map.addOverlays(Saint_Charles);
centerByArray(Saint_Charles, false, false);
cntMarker += Saint_Charles.length;
map.addOverlays(Saint_Louis);
centerByArray(Saint_Louis, false, false);
cntMarker += Saint_Louis.length;
map.addOverlays(Saint_Peters);
centerByArray(Saint_Peters, false, false);
cntMarker += Saint_Peters.length;
map.addOverlays(Washington);
centerByArray(Washington, false, false);
cntMarker += Washington.length;
centerByArray(Saint_Louis,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///16214,35441,15839,15809,15666,15689,15715,15768,34775,15665,15610,16196,15632,15735,16209,16221,15804,16169,34592,16211,16212,16200,15650,15609,34776,15696,15706,15721,16199,16177,/all');
//window.open('/map.php?type=2&schools=16214,35441,15839,15809,15666,15689,15715,15768,34775,15665,15610,16196,15632,15735,16209,16221,15804,16169,34592,16211,16212,16200,15650,15609,34776,15696,15706,15721,16199,16177,&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;
}