function addMarkers(){
mySelect = document.getElementById('selection');
Overland_Park = [];Lawrence = [];Manhattan = [];Hays = [];Great_Bend = [];Wichita = [];Linn = [];Plainville = [];Augusta = [];Conway_Springs = [];Salina = [];Topeka = [];mySelect.options[mySelect.options.length] = new Option("Augusta schools",'all=Augusta');
mySelect.options[mySelect.options.length] = new Option("Conway Springs schools",'all=Conway_Springs');
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("Lawrence schools",'all=Lawrence');
mySelect.options[mySelect.options.length] = new Option("Linn schools",'all=Linn');
mySelect.options[mySelect.options.length] = new Option("Manhattan schools",'all=Manhattan');
mySelect.options[mySelect.options.length] = new Option("Overland Park schools",'all=Overland_Park');
mySelect.options[mySelect.options.length] = new Option("Plainville schools",'all=Plainville');
mySelect.options[mySelect.options.length] = new Option("Salina schools",'all=Salina');
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("---------------------------",'');
Overland_Park[Overland_Park.length] = createMarker(new GPoint(-94.65820500,38.96388000),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethany Lutheran School",'Overland_Park=' + Overland_Park.length);
Lawrence[Lawrence.length] = createMarker(new GPoint(-95.29200400,38.94303700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bishop Seabury Academy",'Lawrence=' + Lawrence.length);
Manhattan[Manhattan.length] = createMarker(new GPoint(-96.51042500,39.20026200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Flint Hills Christian School",'Manhattan=' + Manhattan.length);
Hays[Hays.length] = createMarker(new GPoint(-99.32005800,38.87514900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Family Elementary School",'Hays=' + Hays.length);
Great_Bend[Great_Bend.length] = createMarker(new GPoint(-98.79457200,38.36653700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Family School",'Great_Bend=' + Great_Bend.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);
Wichita[Wichita.length] = createMarker(new GPoint(-97.23828900,37.69403700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kapaun Mt Carmel Catholic High School",'Wichita=' + Wichita.length);
Linn[Linn.length] = createMarker(new GPoint(-97.08897700,39.68236300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Linn Lutheran School",'Linn=' + Linn.length);
Plainville[Plainville.length] = createMarker(new GPoint(-99.31070000,39.23340000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sacred Heart Elementary School",'Plainville=' + Plainville.length);
Augusta[Augusta.length] = createMarker(new GPoint(-96.96916000,37.70123700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St James Catholic School",'Augusta=' + Augusta.length);
Conway_Springs[Conway_Springs.length] = createMarker(new GPoint(-97.64137200,37.39296300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Joseph Catholic School",'Conway_Springs=' + Conway_Springs.length);
Salina[Salina.length] = createMarker(new GPoint(-97.60480200,38.81246300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Mary Queen Of The Universe Grade School",'Salina=' + Salina.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);
Topeka[Topeka.length] = createMarker(new GPoint(-95.73552900,39.02805900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Topeka Collegiate School",'Topeka=' + Topeka.length);
Topeka[Topeka.length] = createMarker(new GPoint(-95.70309800,39.05738400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Topeka Lutheran School",'Topeka=' + Topeka.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);
map.removeOverlays(Augusta);
map.removeOverlays(Conway_Springs);
map.removeOverlays(Great_Bend);
map.removeOverlays(Hays);
map.removeOverlays(Lawrence);
map.removeOverlays(Linn);
map.removeOverlays(Manhattan);
map.removeOverlays(Overland_Park);
map.removeOverlays(Plainville);
map.removeOverlays(Salina);
map.removeOverlays(Topeka);
map.removeOverlays(Wichita);
setTimeout(function(){map.addOverlays(Augusta)},1000);
setTimeout(function(){map.addOverlays(Conway_Springs)},1000);
setTimeout(function(){map.addOverlays(Great_Bend)},1000);
setTimeout(function(){map.addOverlays(Hays)},1000);
setTimeout(function(){map.addOverlays(Lawrence)},1000);
setTimeout(function(){map.addOverlays(Linn)},1000);
setTimeout(function(){map.addOverlays(Manhattan)},1000);
setTimeout(function(){map.addOverlays(Overland_Park)},1000);
setTimeout(function(){map.addOverlays(Plainville)},1000);
setTimeout(function(){map.addOverlays(Salina)},1000);
setTimeout(function(){map.addOverlays(Topeka)},1000);
setTimeout(function(){map.addOverlays(Wichita)},1000);
maxLng = -94.65820500;
maxLat = 39.68236300;
minLng = -99.32005800;
minLat = 37.39296300;
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(Augusta);
map.removeOverlays(Conway_Springs);
map.removeOverlays(Great_Bend);
map.removeOverlays(Hays);
map.removeOverlays(Lawrence);
map.removeOverlays(Linn);
map.removeOverlays(Manhattan);
map.removeOverlays(Overland_Park);
map.removeOverlays(Plainville);
map.removeOverlays(Salina);
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(Overland_Park);map.removeOverlays(Augusta);
map.removeOverlays(Conway_Springs);
map.removeOverlays(Great_Bend);
map.removeOverlays(Hays);
map.removeOverlays(Lawrence);
map.removeOverlays(Linn);
map.removeOverlays(Manhattan);
map.removeOverlays(Overland_Park);
map.removeOverlays(Plainville);
map.removeOverlays(Salina);
map.removeOverlays(Topeka);
map.removeOverlays(Wichita);
map.addOverlays(Augusta);
centerByArray(Augusta, false, false);
cntMarker += Augusta.length;
map.addOverlays(Conway_Springs);
centerByArray(Conway_Springs, false, false);
cntMarker += Conway_Springs.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(Lawrence);
centerByArray(Lawrence, false, false);
cntMarker += Lawrence.length;
map.addOverlays(Linn);
centerByArray(Linn, false, false);
cntMarker += Linn.length;
map.addOverlays(Manhattan);
centerByArray(Manhattan, false, false);
cntMarker += Manhattan.length;
map.addOverlays(Overland_Park);
centerByArray(Overland_Park, false, false);
cntMarker += Overland_Park.length;
map.addOverlays(Plainville);
centerByArray(Plainville, false, false);
cntMarker += Plainville.length;
map.addOverlays(Salina);
centerByArray(Salina, false, false);
cntMarker += Salina.length;
map.addOverlays(Topeka);
centerByArray(Topeka, false, false);
cntMarker += Topeka.length;
map.addOverlays(Wichita);
centerByArray(Wichita, false, false);
cntMarker += Wichita.length;
centerByArray(Overland_Park,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///10884,10911,10947,35646,11009,11019,11039,10928,10953,10911,35645,10988,11028,11059,11057,11058,10934,35646,/all');
//window.open('/map.php?type=2&schools=10884,10911,10947,35646,11009,11019,11039,10928,10953,10911,35645,10988,11028,11059,11057,11058,10934,35646,&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;
}