function addMarkers(){
mySelect = document.getElementById('selection');
Wichita = [];Derby = [];Goddard = [];Cheney = [];Haysville = [];mySelect.options[mySelect.options.length] = new Option("Cheney schools",'all=Cheney');
mySelect.options[mySelect.options.length] = new Option("Derby schools",'all=Derby');
mySelect.options[mySelect.options.length] = new Option("Goddard schools",'all=Goddard');
mySelect.options[mySelect.options.length] = new Option("Haysville schools",'all=Haysville');
mySelect.options[mySelect.options.length] = new Option("Wichita schools",'all=Wichita');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Wichita[Wichita.length] = createMarker(new GPoint(-97.29742100,37.66626300),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("All Saints Catholic Elementary School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.26107600,37.74726300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Annoor Islamic School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.35127100,37.64666900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethany Lutheran School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.37087200,37.62675800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethel Life School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.29163900,37.68657600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Blessed Sacrament Catholic School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.30229900,37.67896300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calvary Christian School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.24445800,37.73609600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central Christian Academy",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.39515500,37.68011200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christ The King Elementary School",'Wichita=' + Wichita.length);
Derby[Derby.length] = createMarker(new GPoint(-97.26644100,37.54205800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Lutheran School",'Derby=' + Derby.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.23649500,37.73788500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Heartspring",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.20762900,37.69594400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Cross Lutheran School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.30228900,37.70885900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Savior Catholic Academy",'Wichita=' + Wichita.length);
Goddard[Goddard.length] = createMarker(new GPoint(-97.54960000,37.66444000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Spirit Catholic School",'Goddard=' + Goddard.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.23917600,37.68646300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Independent School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.18987300,37.72126500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Magdalen Catholic School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.26232500,37.77193900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Resurrection Catholic School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.37192900,37.76153800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Riverlawn Christian Academy",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.35318500,37.64318900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Anne Elementary School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.48087200,37.69214900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Elizabeth Ann Seton",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.36034200,37.68316000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Joseph Catholic School",'Wichita=' + Wichita.length);
Derby[Derby.length] = createMarker(new GPoint(-97.26663300,37.54918700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Mary Parish Catholic School",'Derby=' + Derby.length);
Cheney[Cheney.length] = createMarker(new GPoint(-97.78568600,37.63179500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Pauls Lutheran School",'Cheney=' + Cheney.length);
Haysville[Haysville.length] = createMarker(new GPoint(-97.37327000,37.56443700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Cecilia Catholic School",'Haysville=' + Haysville.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.43805400,37.69714800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Francis Of Assisi School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.36292500,37.73808300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Jude Catholic School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.32237200,37.64524100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Margaret Mary School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.34489900,37.71938700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Patrick Elementary School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.47100000,37.62333700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Peter Catholic School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.25871000,37.70678600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Thomas Aquinas Elementary School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.31732500,37.76561300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Three Angels School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.34887200,37.64570300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wichita Adventist Christian Academy",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.23241700,37.70825000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wichita Collegiate School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.51078900,37.66443700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wichita Friends School Inc.",'Wichita=' + Wichita.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(Cheney);
map.removeOverlays(Derby);
map.removeOverlays(Goddard);
map.removeOverlays(Haysville);
map.removeOverlays(Wichita);
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(Wichita);map.removeOverlays(Cheney);
map.removeOverlays(Derby);
map.removeOverlays(Goddard);
map.removeOverlays(Haysville);
map.removeOverlays(Wichita);
map.addOverlays(Cheney);
centerByArray(Cheney, false, false);
cntMarker += Cheney.length;
map.addOverlays(Derby);
centerByArray(Derby, false, false);
cntMarker += Derby.length;
map.addOverlays(Goddard);
centerByArray(Goddard, false, false);
cntMarker += Goddard.length;
map.addOverlays(Haysville);
centerByArray(Haysville, false, false);
cntMarker += Haysville.length;
map.addOverlays(Wichita);
centerByArray(Wichita, false, false);
cntMarker += Wichita.length;
centerByArray(Wichita,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;
}