function addMarkers(){
mySelect = document.getElementById('selection');
Norman = [];Tulsa = [];Pryor = [];Oklahoma_City = [];Claremore = [];Chickasha = [];Broken_Arrow = [];Okmulgee = [];Moore = [];Miami = [];El_Reno = [];mySelect.options[mySelect.options.length] = new Option("Broken Arrow schools",'all=Broken_Arrow');
mySelect.options[mySelect.options.length] = new Option("Chickasha schools",'all=Chickasha');
mySelect.options[mySelect.options.length] = new Option("Claremore schools",'all=Claremore');
mySelect.options[mySelect.options.length] = new Option("El Reno schools",'all=El_Reno');
mySelect.options[mySelect.options.length] = new Option("Miami schools",'all=Miami');
mySelect.options[mySelect.options.length] = new Option("Moore schools",'all=Moore');
mySelect.options[mySelect.options.length] = new Option("Norman schools",'all=Norman');
mySelect.options[mySelect.options.length] = new Option("Oklahoma City schools",'all=Oklahoma_City');
mySelect.options[mySelect.options.length] = new Option("Okmulgee schools",'all=Okmulgee');
mySelect.options[mySelect.options.length] = new Option("Pryor schools",'all=Pryor');
mySelect.options[mySelect.options.length] = new Option("Tulsa schools",'all=Tulsa');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Norman[Norman.length] = createMarker(new GPoint(-97.49413100,35.26482300),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("All Saints Catholic",'Norman=' + Norman.length);
Tulsa[Tulsa.length] = createMarker(new GPoint(-95.91306800,36.10632200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bishop Kelley High School",'Tulsa=' + Tulsa.length);
Pryor[Pryor.length] = createMarker(new GPoint(-95.29675900,36.30729000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bradford Christian School",'Pryor=' + Pryor.length);
Tulsa[Tulsa.length] = createMarker(new GPoint(-95.99035900,36.15139000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cascia Hall Preparatory School",'Tulsa=' + Tulsa.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);
Claremore[Claremore.length] = createMarker(new GPoint(-95.61903700,36.32181500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Claremore Christian School",'Claremore=' + Claremore.length);
Chickasha[Chickasha.length] = createMarker(new GPoint(-97.93614900,35.05237000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Epworth Christian Day School",'Chickasha=' + Chickasha.length);
Broken_Arrow[Broken_Arrow.length] = createMarker(new GPoint(-95.85108900,36.02305600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grace Christian School",'Broken_Arrow=' + Broken_Arrow.length);
Tulsa[Tulsa.length] = createMarker(new GPoint(-95.85108900,36.02305600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grace Christian School",'Tulsa=' + Tulsa.length);
Tulsa[Tulsa.length] = createMarker(new GPoint(-95.98971500,36.14787000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Family Cathedral School",'Tulsa=' + Tulsa.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);
Okmulgee[Okmulgee.length] = createMarker(new GPoint(-95.97253800,35.61804200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Marian Academy",'Okmulgee=' + Okmulgee.length);
Moore[Moore.length] = createMarker(new GPoint(-97.47664800,35.34640700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Moore Christian School",'Moore=' + Moore.length);
Miami[Miami.length] = createMarker(new GPoint(-94.87777100,36.90242100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mt Olive Lutheran School",'Miami=' + Miami.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);
El_Reno[El_Reno.length] = createMarker(new GPoint(-97.95619600,35.53212800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sacred Heart Catholic School",'El_Reno=' + El_Reno.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);
Moore[Moore.length] = createMarker(new GPoint(-97.48270000,35.34080000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Southwest Christian Academy",'Moore=' + Moore.length);
Tulsa[Tulsa.length] = createMarker(new GPoint(-95.89377200,36.13830200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Pius X School",'Tulsa=' + Tulsa.length);
map.removeOverlays(Broken_Arrow);
map.removeOverlays(Chickasha);
map.removeOverlays(Claremore);
map.removeOverlays(El_Reno);
map.removeOverlays(Miami);
map.removeOverlays(Moore);
map.removeOverlays(Norman);
map.removeOverlays(Oklahoma_City);
map.removeOverlays(Okmulgee);
map.removeOverlays(Pryor);
map.removeOverlays(Tulsa);
setTimeout(function(){map.addOverlays(Broken_Arrow)},1000);
setTimeout(function(){map.addOverlays(Chickasha)},1000);
setTimeout(function(){map.addOverlays(Claremore)},1000);
setTimeout(function(){map.addOverlays(El_Reno)},1000);
setTimeout(function(){map.addOverlays(Miami)},1000);
setTimeout(function(){map.addOverlays(Moore)},1000);
setTimeout(function(){map.addOverlays(Norman)},1000);
setTimeout(function(){map.addOverlays(Oklahoma_City)},1000);
setTimeout(function(){map.addOverlays(Okmulgee)},1000);
setTimeout(function(){map.addOverlays(Pryor)},1000);
setTimeout(function(){map.addOverlays(Tulsa)},1000);
maxLng = -94.87777100;
maxLat = 36.90242100;
minLng = -97.95619600;
minLat = 35.05237000;
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(Broken_Arrow);
map.removeOverlays(Chickasha);
map.removeOverlays(Claremore);
map.removeOverlays(El_Reno);
map.removeOverlays(Miami);
map.removeOverlays(Moore);
map.removeOverlays(Norman);
map.removeOverlays(Oklahoma_City);
map.removeOverlays(Okmulgee);
map.removeOverlays(Pryor);
map.removeOverlays(Tulsa);
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(Norman);map.removeOverlays(Broken_Arrow);
map.removeOverlays(Chickasha);
map.removeOverlays(Claremore);
map.removeOverlays(El_Reno);
map.removeOverlays(Miami);
map.removeOverlays(Moore);
map.removeOverlays(Norman);
map.removeOverlays(Oklahoma_City);
map.removeOverlays(Okmulgee);
map.removeOverlays(Pryor);
map.removeOverlays(Tulsa);
map.addOverlays(Broken_Arrow);
centerByArray(Broken_Arrow, false, false);
cntMarker += Broken_Arrow.length;
map.addOverlays(Chickasha);
centerByArray(Chickasha, false, false);
cntMarker += Chickasha.length;
map.addOverlays(Claremore);
centerByArray(Claremore, false, false);
cntMarker += Claremore.length;
map.addOverlays(El_Reno);
centerByArray(El_Reno, false, false);
cntMarker += El_Reno.length;
map.addOverlays(Miami);
centerByArray(Miami, false, false);
cntMarker += Miami.length;
map.addOverlays(Moore);
centerByArray(Moore, false, false);
cntMarker += Moore.length;
map.addOverlays(Norman);
centerByArray(Norman, false, false);
cntMarker += Norman.length;
map.addOverlays(Oklahoma_City);
centerByArray(Oklahoma_City, false, false);
cntMarker += Oklahoma_City.length;
map.addOverlays(Okmulgee);
centerByArray(Okmulgee, false, false);
cntMarker += Okmulgee.length;
map.addOverlays(Pryor);
centerByArray(Pryor, false, false);
cntMarker += Pryor.length;
map.addOverlays(Tulsa);
centerByArray(Tulsa, false, false);
cntMarker += Tulsa.length;
centerByArray(Norman,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///34438,22466,22550,34439,34437,22449,22456,22486,34438,34440,22466,22543,22522,22520,22550,22441,22457,36050,34439,22558,22561,22562,22509,34437,22486,22495,22570,/all');
//window.open('/map.php?type=2&schools=34438,22466,22550,34439,34437,22449,22456,22486,34438,34440,22466,22543,22522,22520,22550,22441,22457,36050,34439,22558,22561,22562,22509,34437,22486,22495,22570,&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;
}