function addMarkers(){
mySelect = document.getElementById('selection');
Enterprise = [];Eureka = [];Great_Bend = [];Garden_City = [];Hays = [];Shawnee_Mission = [];Salina = [];Wichita = [];Topeka = [];Kansas_City = [];mySelect.options[mySelect.options.length] = new Option("Enterprise schools",'all=Enterprise');
mySelect.options[mySelect.options.length] = new Option("Eureka schools",'all=Eureka');
mySelect.options[mySelect.options.length] = new Option("Garden City schools",'all=Garden_City');
mySelect.options[mySelect.options.length] = new Option("Great Bend schools",'all=Great_Bend');
mySelect.options[mySelect.options.length] = new Option("Hays schools",'all=Hays');
mySelect.options[mySelect.options.length] = new Option("Kansas City schools",'all=Kansas_City');
mySelect.options[mySelect.options.length] = new Option("Salina schools",'all=Salina');
mySelect.options[mySelect.options.length] = new Option("Shawnee Mission schools",'all=Shawnee_Mission');
mySelect.options[mySelect.options.length] = new Option("Topeka schools",'all=Topeka');
mySelect.options[mySelect.options.length] = new Option("Wichita schools",'all=Wichita');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Enterprise[Enterprise.length] = createMarker(new GPoint(-97.10630000,38.89590000),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Enterprise Academy",'Enterprise=' + Enterprise.length);
Enterprise[Enterprise.length] = createMarker(new GPoint(-97.10630000,38.89590000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Enterprise Sda School",'Enterprise=' + Enterprise.length);
Eureka[Eureka.length] = createMarker(new GPoint(-96.30750000,37.83320000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eureka Sda Elementary School",'Eureka=' + Eureka.length);
Great_Bend[Great_Bend.length] = createMarker(new GPoint(-98.82997400,38.36076100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Great Bend Sda School",'Great_Bend=' + Great_Bend.length);
Garden_City[Garden_City.length] = createMarker(new GPoint(-100.85404100,37.99177200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("High Plains Christian School",'Garden_City=' + Garden_City.length);
Hays[Hays.length] = createMarker(new GPoint(-99.24341800,38.88831900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Maranatha Christian School",'Hays=' + Hays.length);
Shawnee_Mission[Shawnee_Mission.length] = createMarker(new GPoint(-94.77041800,39.00317400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Midland Adventist Academy",'Shawnee_Mission=' + Shawnee_Mission.length);
Salina[Salina.length] = createMarker(new GPoint(-97.61375400,38.85507300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Salina Sda School",'Salina=' + Salina.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);
Topeka[Topeka.length] = createMarker(new GPoint(-95.76247600,39.02269200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Topeka Adventist School",'Topeka=' + Topeka.length);
Kansas_City[Kansas_City.length] = createMarker(new GPoint(-94.67650000,39.13710000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("V. Lindsay Sda School",'Kansas_City=' + Kansas_City.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);
map.removeOverlays(Enterprise);
map.removeOverlays(Eureka);
map.removeOverlays(Garden_City);
map.removeOverlays(Great_Bend);
map.removeOverlays(Hays);
map.removeOverlays(Kansas_City);
map.removeOverlays(Salina);
map.removeOverlays(Shawnee_Mission);
map.removeOverlays(Topeka);
map.removeOverlays(Wichita);
setTimeout(function(){map.addOverlays(Enterprise)},1000);
setTimeout(function(){map.addOverlays(Eureka)},1000);
setTimeout(function(){map.addOverlays(Garden_City)},1000);
setTimeout(function(){map.addOverlays(Great_Bend)},1000);
setTimeout(function(){map.addOverlays(Hays)},1000);
setTimeout(function(){map.addOverlays(Kansas_City)},1000);
setTimeout(function(){map.addOverlays(Salina)},1000);
setTimeout(function(){map.addOverlays(Shawnee_Mission)},1000);
setTimeout(function(){map.addOverlays(Topeka)},1000);
setTimeout(function(){map.addOverlays(Wichita)},1000);
maxLng = -94.67650000;
maxLat = 39.13710000;
minLng = -100.85404100;
minLat = 37.64570300;
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(Enterprise);
map.removeOverlays(Eureka);
map.removeOverlays(Garden_City);
map.removeOverlays(Great_Bend);
map.removeOverlays(Hays);
map.removeOverlays(Kansas_City);
map.removeOverlays(Salina);
map.removeOverlays(Shawnee_Mission);
map.removeOverlays(Topeka);
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(Enterprise);map.removeOverlays(Enterprise);
map.removeOverlays(Eureka);
map.removeOverlays(Garden_City);
map.removeOverlays(Great_Bend);
map.removeOverlays(Hays);
map.removeOverlays(Kansas_City);
map.removeOverlays(Salina);
map.removeOverlays(Shawnee_Mission);
map.removeOverlays(Topeka);
map.removeOverlays(Wichita);
map.addOverlays(Enterprise);
centerByArray(Enterprise, false, false);
cntMarker += Enterprise.length;
map.addOverlays(Eureka);
centerByArray(Eureka, false, false);
cntMarker += Eureka.length;
map.addOverlays(Garden_City);
centerByArray(Garden_City, false, false);
cntMarker += Garden_City.length;
map.addOverlays(Great_Bend);
centerByArray(Great_Bend, false, false);
cntMarker += Great_Bend.length;
map.addOverlays(Hays);
centerByArray(Hays, false, false);
cntMarker += Hays.length;
map.addOverlays(Kansas_City);
centerByArray(Kansas_City, false, false);
cntMarker += Kansas_City.length;
map.addOverlays(Salina);
centerByArray(Salina, false, false);
cntMarker += Salina.length;
map.addOverlays(Shawnee_Mission);
centerByArray(Shawnee_Mission, false, false);
cntMarker += Shawnee_Mission.length;
map.addOverlays(Topeka);
centerByArray(Topeka, false, false);
cntMarker += Topeka.length;
map.addOverlays(Wichita);
centerByArray(Wichita, false, false);
cntMarker += Wichita.length;
centerByArray(Enterprise,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///10905,10959,11055,11069,10906,10907,33939,10916,33938,11067,33940,10959,11059,11055,11069,/all');
//window.open('/map.php?type=2&schools=10905,10959,11055,11069,10906,10907,33939,10916,33938,11067,33940,10959,11059,11055,11069,&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;
}