function addMarkers(){
mySelect = document.getElementById('selection');
Omar = [];Cross_Lanes = [];Elkview = [];Clarksburg = [];Huntington = [];Ravenswood = [];Romney = [];Princeton = [];Lenore = [];Morgantown = [];Culloden = [];Pipestem = [];Ronceverte = [];Buckhannon = [];Beaver = [];Williamstown = [];mySelect.options[mySelect.options.length] = new Option("Beaver schools",'all=Beaver');
mySelect.options[mySelect.options.length] = new Option("Buckhannon schools",'all=Buckhannon');
mySelect.options[mySelect.options.length] = new Option("Clarksburg schools",'all=Clarksburg');
mySelect.options[mySelect.options.length] = new Option("Cross Lanes schools",'all=Cross_Lanes');
mySelect.options[mySelect.options.length] = new Option("Culloden schools",'all=Culloden');
mySelect.options[mySelect.options.length] = new Option("Elkview schools",'all=Elkview');
mySelect.options[mySelect.options.length] = new Option("Huntington schools",'all=Huntington');
mySelect.options[mySelect.options.length] = new Option("Lenore schools",'all=Lenore');
mySelect.options[mySelect.options.length] = new Option("Morgantown schools",'all=Morgantown');
mySelect.options[mySelect.options.length] = new Option("Omar schools",'all=Omar');
mySelect.options[mySelect.options.length] = new Option("Pipestem schools",'all=Pipestem');
mySelect.options[mySelect.options.length] = new Option("Princeton schools",'all=Princeton');
mySelect.options[mySelect.options.length] = new Option("Ravenswood schools",'all=Ravenswood');
mySelect.options[mySelect.options.length] = new Option("Romney schools",'all=Romney');
mySelect.options[mySelect.options.length] = new Option("Ronceverte schools",'all=Ronceverte');
mySelect.options[mySelect.options.length] = new Option("Williamstown schools",'all=Williamstown');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Omar[Omar.length] = createMarker(new GPoint(-82.03510000,37.67490000),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Beth Haven Christian School",'Omar=' + Omar.length);
Cross_Lanes[Cross_Lanes.length] = createMarker(new GPoint(-81.78087000,38.43696600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cross Lanes Christian School",'Cross_Lanes=' + Cross_Lanes.length);
Elkview[Elkview.length] = createMarker(new GPoint(-81.47393200,38.44402900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Elk Valley Christian School",'Elkview=' + Elkview.length);
Clarksburg[Clarksburg.length] = createMarker(new GPoint(-80.34649600,39.29242800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Emmanuel Christian School",'Clarksburg=' + Clarksburg.length);
Huntington[Huntington.length] = createMarker(new GPoint(-82.47548500,38.41283700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grace Christian School",'Huntington=' + Huntington.length);
Ravenswood[Ravenswood.length] = createMarker(new GPoint(-81.74120000,38.96710000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Heritage Christian Academy",'Ravenswood=' + Ravenswood.length);
Romney[Romney.length] = createMarker(new GPoint(-78.73800000,39.34870000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Maranatha Christian Academy",'Romney=' + Romney.length);
Princeton[Princeton.length] = createMarker(new GPoint(-81.06900600,37.36506000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mercer Christian Academy",'Princeton=' + Princeton.length);
Lenore[Lenore.length] = createMarker(new GPoint(-82.25750000,37.79220000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mingo Christian School",'Lenore=' + Lenore.length);
Morgantown[Morgantown.length] = createMarker(new GPoint(-79.93645100,39.61112900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Morgantown Christian Academy",'Morgantown=' + Morgantown.length);
Culloden[Culloden.length] = createMarker(new GPoint(-82.06090000,38.41640000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mountain State Christian School",'Culloden=' + Culloden.length);
Pipestem[Pipestem.length] = createMarker(new GPoint(-80.94260000,37.52330000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pipestem Christian Academy",'Pipestem=' + Pipestem.length);
Ronceverte[Ronceverte.length] = createMarker(new GPoint(-80.45344900,37.75266000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Seneca Trail Christian Academy",'Ronceverte=' + Ronceverte.length);
Buckhannon[Buckhannon.length] = createMarker(new GPoint(-80.22386200,38.98172500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Upshur County Christian Academy",'Buckhannon=' + Buckhannon.length);
Beaver[Beaver.length] = createMarker(new GPoint(-81.08070000,37.76700000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Victory Baptist Academy",'Beaver=' + Beaver.length);
Williamstown[Williamstown.length] = createMarker(new GPoint(-81.44883400,39.39595800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wood County Christian School",'Williamstown=' + Williamstown.length);
map.removeOverlays(Beaver);
map.removeOverlays(Buckhannon);
map.removeOverlays(Clarksburg);
map.removeOverlays(Cross_Lanes);
map.removeOverlays(Culloden);
map.removeOverlays(Elkview);
map.removeOverlays(Huntington);
map.removeOverlays(Lenore);
map.removeOverlays(Morgantown);
map.removeOverlays(Omar);
map.removeOverlays(Pipestem);
map.removeOverlays(Princeton);
map.removeOverlays(Ravenswood);
map.removeOverlays(Romney);
map.removeOverlays(Ronceverte);
map.removeOverlays(Williamstown);
setTimeout(function(){map.addOverlays(Beaver)},1000);
setTimeout(function(){map.addOverlays(Buckhannon)},1000);
setTimeout(function(){map.addOverlays(Clarksburg)},1000);
setTimeout(function(){map.addOverlays(Cross_Lanes)},1000);
setTimeout(function(){map.addOverlays(Culloden)},1000);
setTimeout(function(){map.addOverlays(Elkview)},1000);
setTimeout(function(){map.addOverlays(Huntington)},1000);
setTimeout(function(){map.addOverlays(Lenore)},1000);
setTimeout(function(){map.addOverlays(Morgantown)},1000);
setTimeout(function(){map.addOverlays(Omar)},1000);
setTimeout(function(){map.addOverlays(Pipestem)},1000);
setTimeout(function(){map.addOverlays(Princeton)},1000);
setTimeout(function(){map.addOverlays(Ravenswood)},1000);
setTimeout(function(){map.addOverlays(Romney)},1000);
setTimeout(function(){map.addOverlays(Ronceverte)},1000);
setTimeout(function(){map.addOverlays(Williamstown)},1000);
maxLng = -78.73800000;
maxLat = 39.61112900;
minLng = -82.47548500;
minLat = 37.36506000;
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(Beaver);
map.removeOverlays(Buckhannon);
map.removeOverlays(Clarksburg);
map.removeOverlays(Cross_Lanes);
map.removeOverlays(Culloden);
map.removeOverlays(Elkview);
map.removeOverlays(Huntington);
map.removeOverlays(Lenore);
map.removeOverlays(Morgantown);
map.removeOverlays(Omar);
map.removeOverlays(Pipestem);
map.removeOverlays(Princeton);
map.removeOverlays(Ravenswood);
map.removeOverlays(Romney);
map.removeOverlays(Ronceverte);
map.removeOverlays(Williamstown);
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(Omar);map.removeOverlays(Beaver);
map.removeOverlays(Buckhannon);
map.removeOverlays(Clarksburg);
map.removeOverlays(Cross_Lanes);
map.removeOverlays(Culloden);
map.removeOverlays(Elkview);
map.removeOverlays(Huntington);
map.removeOverlays(Lenore);
map.removeOverlays(Morgantown);
map.removeOverlays(Omar);
map.removeOverlays(Pipestem);
map.removeOverlays(Princeton);
map.removeOverlays(Ravenswood);
map.removeOverlays(Romney);
map.removeOverlays(Ronceverte);
map.removeOverlays(Williamstown);
map.addOverlays(Beaver);
centerByArray(Beaver, false, false);
cntMarker += Beaver.length;
map.addOverlays(Buckhannon);
centerByArray(Buckhannon, false, false);
cntMarker += Buckhannon.length;
map.addOverlays(Clarksburg);
centerByArray(Clarksburg, false, false);
cntMarker += Clarksburg.length;
map.addOverlays(Cross_Lanes);
centerByArray(Cross_Lanes, false, false);
cntMarker += Cross_Lanes.length;
map.addOverlays(Culloden);
centerByArray(Culloden, false, false);
cntMarker += Culloden.length;
map.addOverlays(Elkview);
centerByArray(Elkview, false, false);
cntMarker += Elkview.length;
map.addOverlays(Huntington);
centerByArray(Huntington, false, false);
cntMarker += Huntington.length;
map.addOverlays(Lenore);
centerByArray(Lenore, false, false);
cntMarker += Lenore.length;
map.addOverlays(Morgantown);
centerByArray(Morgantown, false, false);
cntMarker += Morgantown.length;
map.addOverlays(Omar);
centerByArray(Omar, false, false);
cntMarker += Omar.length;
map.addOverlays(Pipestem);
centerByArray(Pipestem, false, false);
cntMarker += Pipestem.length;
map.addOverlays(Princeton);
centerByArray(Princeton, false, false);
cntMarker += Princeton.length;
map.addOverlays(Ravenswood);
centerByArray(Ravenswood, false, false);
cntMarker += Ravenswood.length;
map.addOverlays(Romney);
centerByArray(Romney, false, false);
cntMarker += Romney.length;
map.addOverlays(Ronceverte);
centerByArray(Ronceverte, false, false);
cntMarker += Ronceverte.length;
map.addOverlays(Williamstown);
centerByArray(Williamstown, false, false);
cntMarker += Williamstown.length;
centerByArray(Omar,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///29368,29366,29268,29265,29304,29267,29275,29241,29325,29293,29277,29291,29333,29374,29368,29366,29268,29265,29304,29267,29275,29296,29299,29241,29325,29293,29277,29291,29333,29374,/all');
//window.open('/map.php?type=2&schools=29368,29366,29268,29265,29304,29267,29275,29241,29325,29293,29277,29291,29333,29374,29368,29366,29268,29265,29304,29267,29275,29296,29299,29241,29325,29293,29277,29291,29333,29374,&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;
}