function addMarkers(){
mySelect = document.getElementById('selection');
Broken_Arrow = [];Edmond = [];Guthrie = [];Lawton = [];Mustang = [];Norman = [];Oklahoma_City = [];Tulsa = [];mySelect.options[mySelect.options.length] = new Option("Broken Arrow schools",'all=Broken_Arrow');
mySelect.options[mySelect.options.length] = new Option("Edmond schools",'all=Edmond');
mySelect.options[mySelect.options.length] = new Option("Guthrie schools",'all=Guthrie');
mySelect.options[mySelect.options.length] = new Option("Lawton schools",'all=Lawton');
mySelect.options[mySelect.options.length] = new Option("Mustang schools",'all=Mustang');
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("Tulsa schools",'all=Tulsa');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Broken_Arrow[Broken_Arrow.length] = createMarker(new GPoint(-95.81214700,36.03173400),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Council Oaks Learning Campus",'Broken_Arrow=' + Broken_Arrow.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);
Guthrie[Guthrie.length] = createMarker(new GPoint(-97.42540000,35.85050000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Guthrie Christian School",'Guthrie=' + Guthrie.length);
Lawton[Lawton.length] = createMarker(new GPoint(-98.43996600,34.61689200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Play To Learn Preschool-kinder",'Lawton=' + Lawton.length);
Mustang[Mustang.length] = createMarker(new GPoint(-97.76026700,35.39614700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christ Lutheran School",'Mustang=' + Mustang.length);
Norman[Norman.length] = createMarker(new GPoint(-97.42796700,35.21821500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gingerbread Nursery School",'Norman=' + Norman.length);
Norman[Norman.length] = createMarker(new GPoint(-97.44480000,35.22120000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mcfarlin Kindergarten Day Care",'Norman=' + Norman.length);
Norman[Norman.length] = createMarker(new GPoint(-97.44489500,35.19134500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ou Childrens World",'Norman=' + Norman.length);
Norman[Norman.length] = createMarker(new GPoint(-97.44036700,35.20359000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pumpkin Shell School Inc",'Norman=' + Norman.length);
Oklahoma_City[Oklahoma_City.length] = createMarker(new GPoint(-97.53003300,35.33276000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Villa Teresa Moore",'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.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.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.52967400,35.51168000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Crown Heights Christian Center",'Oklahoma_City=' + Oklahoma_City.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);
Tulsa[Tulsa.length] = createMarker(new GPoint(-95.95428500,36.06066300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christ The Redeemer-ecc",'Tulsa=' + Tulsa.length);
Tulsa[Tulsa.length] = createMarker(new GPoint(-95.98796300,36.15320000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("1st Baptist Learning Center",'Tulsa=' + Tulsa.length);
map.removeOverlays(Broken_Arrow);
map.removeOverlays(Edmond);
map.removeOverlays(Guthrie);
map.removeOverlays(Lawton);
map.removeOverlays(Mustang);
map.removeOverlays(Norman);
map.removeOverlays(Oklahoma_City);
map.removeOverlays(Tulsa);
setTimeout(function(){map.addOverlays(Broken_Arrow)},1000);
setTimeout(function(){map.addOverlays(Edmond)},1000);
setTimeout(function(){map.addOverlays(Guthrie)},1000);
setTimeout(function(){map.addOverlays(Lawton)},1000);
setTimeout(function(){map.addOverlays(Mustang)},1000);
setTimeout(function(){map.addOverlays(Norman)},1000);
setTimeout(function(){map.addOverlays(Oklahoma_City)},1000);
setTimeout(function(){map.addOverlays(Tulsa)},1000);
maxLng = -95.81214700;
maxLat = 36.15320000;
minLng = -98.43996600;
minLat = 34.61689200;
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(Edmond);
map.removeOverlays(Guthrie);
map.removeOverlays(Lawton);
map.removeOverlays(Mustang);
map.removeOverlays(Norman);
map.removeOverlays(Oklahoma_City);
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(Broken_Arrow);map.removeOverlays(Broken_Arrow);
map.removeOverlays(Edmond);
map.removeOverlays(Guthrie);
map.removeOverlays(Lawton);
map.removeOverlays(Mustang);
map.removeOverlays(Norman);
map.removeOverlays(Oklahoma_City);
map.removeOverlays(Tulsa);
map.addOverlays(Broken_Arrow);
centerByArray(Broken_Arrow, false, false);
cntMarker += Broken_Arrow.length;
map.addOverlays(Edmond);
centerByArray(Edmond, false, false);
cntMarker += Edmond.length;
map.addOverlays(Guthrie);
centerByArray(Guthrie, false, false);
cntMarker += Guthrie.length;
map.addOverlays(Lawton);
centerByArray(Lawton, false, false);
cntMarker += Lawton.length;
map.addOverlays(Mustang);
centerByArray(Mustang, false, false);
cntMarker += Mustang.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(Tulsa);
centerByArray(Tulsa, false, false);
cntMarker += Tulsa.length;
centerByArray(Broken_Arrow,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=2&schools=&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;
}