function addMarkers(){
mySelect = document.getElementById('selection');
Kansas_City = [];Marshall = [];Nevada = [];Camdenton = [];Springfield = [];Florissant = [];St_Robert = [];Sullivan = [];Forsyth = [];Kahoka = [];Shelbina = [];La_Monte = [];Independence = [];Festus = [];Piedmont = [];Buckner = [];Warrenton = [];Fenton = [];Poplar_Bluff = [];mySelect.options[mySelect.options.length] = new Option("Buckner schools",'all=Buckner');
mySelect.options[mySelect.options.length] = new Option("Camdenton schools",'all=Camdenton');
mySelect.options[mySelect.options.length] = new Option("Fenton schools",'all=Fenton');
mySelect.options[mySelect.options.length] = new Option("Festus schools",'all=Festus');
mySelect.options[mySelect.options.length] = new Option("Florissant schools",'all=Florissant');
mySelect.options[mySelect.options.length] = new Option("Forsyth schools",'all=Forsyth');
mySelect.options[mySelect.options.length] = new Option("Independence schools",'all=Independence');
mySelect.options[mySelect.options.length] = new Option("Kahoka schools",'all=Kahoka');
mySelect.options[mySelect.options.length] = new Option("Kansas City schools",'all=Kansas_City');
mySelect.options[mySelect.options.length] = new Option("La Monte schools",'all=La_Monte');
mySelect.options[mySelect.options.length] = new Option("Marshall schools",'all=Marshall');
mySelect.options[mySelect.options.length] = new Option("Nevada schools",'all=Nevada');
mySelect.options[mySelect.options.length] = new Option("Piedmont schools",'all=Piedmont');
mySelect.options[mySelect.options.length] = new Option("Poplar Bluff schools",'all=Poplar_Bluff');
mySelect.options[mySelect.options.length] = new Option("Shelbina schools",'all=Shelbina');
mySelect.options[mySelect.options.length] = new Option("Springfield schools",'all=Springfield');
mySelect.options[mySelect.options.length] = new Option("St Robert schools",'all=St_Robert');
mySelect.options[mySelect.options.length] = new Option("Sullivan schools",'all=Sullivan');
mySelect.options[mySelect.options.length] = new Option("Warrenton schools",'all=Warrenton');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Kansas_City[Kansas_City.length] = createMarker(new GPoint(-94.50214800,38.95201600),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bannister Christian Academy",'Kansas_City=' + Kansas_City.length);
Marshall[Marshall.length] = createMarker(new GPoint(-93.20897600,39.10214500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calvary Baptist School",'Marshall=' + Marshall.length);
Nevada[Nevada.length] = createMarker(new GPoint(-94.35701000,37.83596300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calvary Christian School",'Nevada=' + Nevada.length);
Camdenton[Camdenton.length] = createMarker(new GPoint(-92.76890000,38.02180000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Camden Christian School",'Camdenton=' + Camdenton.length);
Springfield[Springfield.length] = createMarker(new GPoint(-93.29793500,37.24453700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christian Schools Of Springfield",'Springfield=' + Springfield.length);
Florissant[Florissant.length] = createMarker(new GPoint(-90.31029000,38.79526300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Christian School",'Florissant=' + Florissant.length);
St_Robert[St_Robert.length] = createMarker(new GPoint(-92.14208600,37.80738400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Maranatha Baptist Academy",'St_Robert=' + St_Robert.length);
Sullivan[Sullivan.length] = createMarker(new GPoint(-91.12160000,38.19310000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Meramec Valley Christian School",'Sullivan=' + Sullivan.length);
Forsyth[Forsyth.length] = createMarker(new GPoint(-93.12532800,36.71715300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Riverview Bible Baptist Chr. School",'Forsyth=' + Forsyth.length);
Kahoka[Kahoka.length] = createMarker(new GPoint(-91.73152800,40.43345600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Shiloh Christian School",'Kahoka=' + Kahoka.length);
Shelbina[Shelbina.length] = createMarker(new GPoint(-91.73152800,40.43345600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Shiloh Christian School",'Shelbina=' + Shelbina.length);
La_Monte[La_Monte.length] = createMarker(new GPoint(-93.44772600,38.73434800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Show-Me Christian School",'La_Monte=' + La_Monte.length);
Independence[Independence.length] = createMarker(new GPoint(-94.34278900,39.03599000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tri-city Christian School",'Independence=' + Independence.length);
Festus[Festus.length] = createMarker(new GPoint(-90.40553800,38.22675800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Twin City Christian Academy",'Festus=' + Festus.length);
Piedmont[Piedmont.length] = createMarker(new GPoint(-90.68790000,37.16510000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Victory Baptist Academy",'Piedmont=' + Piedmont.length);
Buckner[Buckner.length] = createMarker(new GPoint(-94.36545600,39.13578500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Victory Mountain Christian School",'Buckner=' + Buckner.length);
Warrenton[Warrenton.length] = createMarker(new GPoint(-91.14475900,38.80280100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Warrenton Christian School",'Warrenton=' + Warrenton.length);
Fenton[Fenton.length] = createMarker(new GPoint(-90.47166900,38.50640000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wee Care Childcare And Messenger Christian School",'Fenton=' + Fenton.length);
Poplar_Bluff[Poplar_Bluff.length] = createMarker(new GPoint(-90.45776300,36.73000300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Westwood Baptist Academy",'Poplar_Bluff=' + Poplar_Bluff.length);
map.removeOverlays(Buckner);
map.removeOverlays(Camdenton);
map.removeOverlays(Fenton);
map.removeOverlays(Festus);
map.removeOverlays(Florissant);
map.removeOverlays(Forsyth);
map.removeOverlays(Independence);
map.removeOverlays(Kahoka);
map.removeOverlays(Kansas_City);
map.removeOverlays(La_Monte);
map.removeOverlays(Marshall);
map.removeOverlays(Nevada);
map.removeOverlays(Piedmont);
map.removeOverlays(Poplar_Bluff);
map.removeOverlays(Shelbina);
map.removeOverlays(Springfield);
map.removeOverlays(St_Robert);
map.removeOverlays(Sullivan);
map.removeOverlays(Warrenton);
setTimeout(function(){map.addOverlays(Buckner)},1000);
setTimeout(function(){map.addOverlays(Camdenton)},1000);
setTimeout(function(){map.addOverlays(Fenton)},1000);
setTimeout(function(){map.addOverlays(Festus)},1000);
setTimeout(function(){map.addOverlays(Florissant)},1000);
setTimeout(function(){map.addOverlays(Forsyth)},1000);
setTimeout(function(){map.addOverlays(Independence)},1000);
setTimeout(function(){map.addOverlays(Kahoka)},1000);
setTimeout(function(){map.addOverlays(Kansas_City)},1000);
setTimeout(function(){map.addOverlays(La_Monte)},1000);
setTimeout(function(){map.addOverlays(Marshall)},1000);
setTimeout(function(){map.addOverlays(Nevada)},1000);
setTimeout(function(){map.addOverlays(Piedmont)},1000);
setTimeout(function(){map.addOverlays(Poplar_Bluff)},1000);
setTimeout(function(){map.addOverlays(Shelbina)},1000);
setTimeout(function(){map.addOverlays(Springfield)},1000);
setTimeout(function(){map.addOverlays(St_Robert)},1000);
setTimeout(function(){map.addOverlays(Sullivan)},1000);
setTimeout(function(){map.addOverlays(Warrenton)},1000);
maxLng = -90.31029000;
maxLat = 40.43345600;
minLng = -94.50214800;
minLat = 36.71715300;
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(Buckner);
map.removeOverlays(Camdenton);
map.removeOverlays(Fenton);
map.removeOverlays(Festus);
map.removeOverlays(Florissant);
map.removeOverlays(Forsyth);
map.removeOverlays(Independence);
map.removeOverlays(Kahoka);
map.removeOverlays(Kansas_City);
map.removeOverlays(La_Monte);
map.removeOverlays(Marshall);
map.removeOverlays(Nevada);
map.removeOverlays(Piedmont);
map.removeOverlays(Poplar_Bluff);
map.removeOverlays(Shelbina);
map.removeOverlays(Springfield);
map.removeOverlays(St_Robert);
map.removeOverlays(Sullivan);
map.removeOverlays(Warrenton);
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(Kansas_City);map.removeOverlays(Buckner);
map.removeOverlays(Camdenton);
map.removeOverlays(Fenton);
map.removeOverlays(Festus);
map.removeOverlays(Florissant);
map.removeOverlays(Forsyth);
map.removeOverlays(Independence);
map.removeOverlays(Kahoka);
map.removeOverlays(Kansas_City);
map.removeOverlays(La_Monte);
map.removeOverlays(Marshall);
map.removeOverlays(Nevada);
map.removeOverlays(Piedmont);
map.removeOverlays(Poplar_Bluff);
map.removeOverlays(Shelbina);
map.removeOverlays(Springfield);
map.removeOverlays(St_Robert);
map.removeOverlays(Sullivan);
map.removeOverlays(Warrenton);
map.addOverlays(Buckner);
centerByArray(Buckner, false, false);
cntMarker += Buckner.length;
map.addOverlays(Camdenton);
centerByArray(Camdenton, false, false);
cntMarker += Camdenton.length;
map.addOverlays(Fenton);
centerByArray(Fenton, false, false);
cntMarker += Fenton.length;
map.addOverlays(Festus);
centerByArray(Festus, false, false);
cntMarker += Festus.length;
map.addOverlays(Florissant);
centerByArray(Florissant, false, false);
cntMarker += Florissant.length;
map.addOverlays(Forsyth);
centerByArray(Forsyth, false, false);
cntMarker += Forsyth.length;
map.addOverlays(Independence);
centerByArray(Independence, false, false);
cntMarker += Independence.length;
map.addOverlays(Kahoka);
centerByArray(Kahoka, false, false);
cntMarker += Kahoka.length;
map.addOverlays(Kansas_City);
centerByArray(Kansas_City, false, false);
cntMarker += Kansas_City.length;
map.addOverlays(La_Monte);
centerByArray(La_Monte, false, false);
cntMarker += La_Monte.length;
map.addOverlays(Marshall);
centerByArray(Marshall, false, false);
cntMarker += Marshall.length;
map.addOverlays(Nevada);
centerByArray(Nevada, false, false);
cntMarker += Nevada.length;
map.addOverlays(Piedmont);
centerByArray(Piedmont, false, false);
cntMarker += Piedmont.length;
map.addOverlays(Poplar_Bluff);
centerByArray(Poplar_Bluff, false, false);
cntMarker += Poplar_Bluff.length;
map.addOverlays(Shelbina);
centerByArray(Shelbina, false, false);
cntMarker += Shelbina.length;
map.addOverlays(Springfield);
centerByArray(Springfield, false, false);
cntMarker += Springfield.length;
map.addOverlays(St_Robert);
centerByArray(St_Robert, false, false);
cntMarker += St_Robert.length;
map.addOverlays(Sullivan);
centerByArray(Sullivan, false, false);
cntMarker += Sullivan.length;
map.addOverlays(Warrenton);
centerByArray(Warrenton, false, false);
cntMarker += Warrenton.length;
centerByArray(Kansas_City,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///16168,15649,16161,15725,16150,34389,15936,15646,15647,16166,34390,15935,15681,15821,15833,16175,16168,15649,16178,16161,15725,15902,16150,34389,33292,15936,15646,15647,16166,34390,15935,15681,15821,15833,16175,/all');
//window.open('/map.php?type=2&schools=16168,15649,16161,15725,16150,34389,15936,15646,15647,16166,34390,15935,15681,15821,15833,16175,16168,15649,16178,16161,15725,15902,16150,34389,33292,15936,15646,15647,16166,34390,15935,15681,15821,15833,16175,&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;
}