function addMarkers(){
mySelect = document.getElementById('selection');
Bethany = [];Oklahoma_City = [];Del_City = [];Midwest_City = [];Edmond = [];Harrah = [];Spencer = [];mySelect.options[mySelect.options.length] = new Option("Bethany schools",'all=Bethany');
mySelect.options[mySelect.options.length] = new Option("Del City schools",'all=Del_City');
mySelect.options[mySelect.options.length] = new Option("Edmond schools",'all=Edmond');
mySelect.options[mySelect.options.length] = new Option("Harrah schools",'all=Harrah');
mySelect.options[mySelect.options.length] = new Option("Midwest City schools",'all=Midwest_City');
mySelect.options[mySelect.options.length] = new Option("Oklahoma City schools",'all=Oklahoma_City');
mySelect.options[mySelect.options.length] = new Option("Spencer schools",'all=Spencer');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Bethany[Bethany.length] = createMarker(new GPoint(-97.63053900,35.49348500),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethany Christian Academy",'Bethany=' + Bethany.length);
Bethany[Bethany.length] = createMarker(new GPoint(-97.63686800,35.49124700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethany Montessori Preschool A",'Bethany=' + Bethany.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.53006700,35.50276300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bishop John Carroll School",'Oklahoma_City=' + Oklahoma_City.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.54913800,35.56735900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Casady School",'Oklahoma_City=' + Oklahoma_City.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.51770000,35.47300000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Celebrations Preschool",'Oklahoma_City=' + Oklahoma_City.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.60719900,35.53693700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central Sda School",'Oklahoma_City=' + Oklahoma_City.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.57443000,35.52665300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Childrens Place Integris",'Oklahoma_City=' + Oklahoma_City.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.55509500,35.55204000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christ The King Catholic School",'Oklahoma_City=' + Oklahoma_City.length);
Del_City[Del_City.length] = createMarker(new GPoint(-97.43848100,35.43707100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christian Heritage Academy",'Del_City=' + Del_City.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.54946800,35.57357100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Crescent Academy",'Oklahoma_City=' + Oklahoma_City.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.58490100,35.62012000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Crossings Christian School",'Oklahoma_City=' + Oklahoma_City.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.52967400,35.51168000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Crown Heights Christian Center",'Oklahoma_City=' + Oklahoma_City.length);
Midwest_City[Midwest_City.length] = createMarker(new GPoint(-97.40760300,35.45146300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Academy Christian School",'Midwest_City=' + Midwest_City.length);
Edmond[Edmond.length] = createMarker(new GPoint(-97.47384400,35.64390100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("First Presbyterian Ecp",'Edmond=' + Edmond.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.67062700,35.55123700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gethsemane Lutheran School",'Oklahoma_City=' + Oklahoma_City.length);
Midwest_City[Midwest_City.length] = createMarker(new GPoint(-97.40615400,35.47374900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Good Shepherd Lutheran School",'Midwest_City=' + Midwest_City.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.54229700,35.59446300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Heritage Hall",'Oklahoma_City=' + Oklahoma_City.length);
Edmond[Edmond.length] = createMarker(new GPoint(-97.52234200,35.63837800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Trinity Christian School",'Edmond=' + Edmond.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.58484300,35.58479300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("King's Gate Christian School",'Oklahoma_City=' + Oklahoma_City.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.31791400,35.39931200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Life Christian Academy",'Oklahoma_City=' + Oklahoma_City.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.58738000,35.51107500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mercy School Institute",'Oklahoma_City=' + Oklahoma_City.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.58181600,35.53295400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Messiah Lutheran School",'Oklahoma_City=' + Oklahoma_City.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.43760000,35.42030000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mid-del Christian School",'Oklahoma_City=' + Oklahoma_City.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.63682100,35.48352500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Life Christian Academy",'Oklahoma_City=' + Oklahoma_City.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.65423000,35.54864100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northwest Christian School",'Oklahoma_City=' + Oklahoma_City.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.56576700,35.38837300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Okc Comm. College Cdc",'Oklahoma_City=' + Oklahoma_City.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.52776900,35.51926300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Okc Jewish Community Day School",'Oklahoma_City=' + Oklahoma_City.length);
Harrah[Harrah.length] = createMarker(new GPoint(-97.20213000,35.53422100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Oklahoma Academy",'Harrah=' + Harrah.length);
Edmond[Edmond.length] = createMarker(new GPoint(-97.46631500,35.64563700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Oklahoma Christian Academy",'Edmond=' + Edmond.length);
Edmond[Edmond.length] = createMarker(new GPoint(-97.47795800,35.65447100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Oklahoma Christian School",'Edmond=' + Edmond.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.47679000,35.51417200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Parkview Adventist Academy",'Oklahoma_City=' + Oklahoma_City.length);
Edmond[Edmond.length] = createMarker(new GPoint(-97.53151400,35.61768600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Providence Hall",'Edmond=' + Edmond.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.54365500,35.48906300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rosary School",'Oklahoma_City=' + Oklahoma_City.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.52589000,35.43819300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sacred Heart Catholic School",'Oklahoma_City=' + Oklahoma_City.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.61433000,35.52160000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Charles Borromeo School",'Oklahoma_City=' + Oklahoma_City.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.54890000,35.56590000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Eugene Catholic School",'Oklahoma_City=' + Oklahoma_City.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.49415400,35.52833900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. John Christian Heritage Academy",'Oklahoma_City=' + Oklahoma_City.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.56806800,35.52300800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. John's Episcopal School",'Oklahoma_City=' + Oklahoma_City.length);
Midwest_City[Midwest_City.length] = createMarker(new GPoint(-97.39676700,35.44742100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Philip Neri School",'Midwest_City=' + Midwest_City.length);
Bethany[Bethany.length] = createMarker(new GPoint(-97.63113600,35.51220100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("SNU School For Children",'Bethany=' + Bethany.length);
Spencer[Spencer.length] = createMarker(new GPoint(-97.37941500,35.49563700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Spencer Road Christian School",'Spencer=' + Spencer.length);
Edmond[Edmond.length] = createMarker(new GPoint(-97.47829600,35.64474200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Elizabeth Ann Seton Catholic School",'Edmond=' + Edmond.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.53751900,35.42306300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St James Catholic School",'Oklahoma_City=' + Oklahoma_City.length);
Edmond[Edmond.length] = createMarker(new GPoint(-97.47609900,35.65390800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Marys Episcopal School",'Edmond=' + Edmond.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.49325500,35.57996300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity School",'Oklahoma_City=' + Oklahoma_City.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.52289000,35.48037700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Villa Teresa School",'Oklahoma_City=' + Oklahoma_City.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.52328400,35.51636300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Westminster School",'Oklahoma_City=' + Oklahoma_City.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.61355900,35.49341000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Windsor Hills Baptist School",'Oklahoma_City=' + Oklahoma_City.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.50293000,35.51664600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Young Achievers Christian Academy",'Oklahoma_City=' + Oklahoma_City.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,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/////1/' + showArray);
map.removeOverlays(Bethany);
map.removeOverlays(Del_City);
map.removeOverlays(Edmond);
map.removeOverlays(Harrah);
map.removeOverlays(Midwest_City);
map.removeOverlays(Oklahoma_City);
map.removeOverlays(Spencer);
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(Bethany);map.removeOverlays(Bethany);
map.removeOverlays(Del_City);
map.removeOverlays(Edmond);
map.removeOverlays(Harrah);
map.removeOverlays(Midwest_City);
map.removeOverlays(Oklahoma_City);
map.removeOverlays(Spencer);
map.addOverlays(Bethany);
centerByArray(Bethany, false, false);
cntMarker += Bethany.length;
map.addOverlays(Del_City);
centerByArray(Del_City, false, false);
cntMarker += Del_City.length;
map.addOverlays(Edmond);
centerByArray(Edmond, false, false);
cntMarker += Edmond.length;
map.addOverlays(Harrah);
centerByArray(Harrah, false, false);
cntMarker += Harrah.length;
map.addOverlays(Midwest_City);
centerByArray(Midwest_City, false, false);
cntMarker += Midwest_City.length;
map.addOverlays(Oklahoma_City);
centerByArray(Oklahoma_City, false, false);
cntMarker += Oklahoma_City.length;
map.addOverlays(Spencer);
centerByArray(Spencer, false, false);
cntMarker += Spencer.length;
centerByArray(Bethany,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');
//window.open('/map.php?type=1&schools=&school_level=1&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;
}