function addMarkers(){
mySelect = document.getElementById('selection');
Oklahoma_City = [];Bethany = [];Del_City = [];Midwest_City = [];Harrah = [];Edmond = [];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("---------------------------",'');
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.51407800,35.47424600),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bayard Rustin Living Learning Center",'Oklahoma_City=' + Oklahoma_City.length);
Bethany[Bethany.length] = createMarker(new GPoint(-97.63053900,35.49348500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethany Christian Academy",'Bethany=' + Bethany.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.52686700,35.52243700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bishop Mcguinness High 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);
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);
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);
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);
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.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.52576700,35.43715300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mount St Mary High 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);
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);
Bethany[Bethany.length] = createMarker(new GPoint(-97.62685900,35.49340600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Redeemer Lutheran Academy",'Bethany=' + Bethany.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);
} // 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/////2/' + showArray);
map.removeOverlays(Bethany);
map.removeOverlays(Del_City);
map.removeOverlays(Edmond);
map.removeOverlays(Harrah);
map.removeOverlays(Midwest_City);
map.removeOverlays(Oklahoma_City);
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(Oklahoma_City);map.removeOverlays(Bethany);
map.removeOverlays(Del_City);
map.removeOverlays(Edmond);
map.removeOverlays(Harrah);
map.removeOverlays(Midwest_City);
map.removeOverlays(Oklahoma_City);
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;
centerByArray(Oklahoma_City,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=2&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;
}