function addMarkers(){
mySelect = document.getElementById('selection');
Huntington = [];Parkersburg = [];Cross_Lanes = [];Keyser = [];Mount_Gay = [];Martinsburg = [];Nutter_Fort = [];Wheeling = [];Charleston = [];Morgantown = [];mySelect.options[mySelect.options.length] = new Option("Charleston Schools",'all=Charleston');
mySelect.options[mySelect.options.length] = new Option("Cross Lanes Schools",'all=Cross_Lanes');
mySelect.options[mySelect.options.length] = new Option("Huntington Schools",'all=Huntington');
mySelect.options[mySelect.options.length] = new Option("Keyser Schools",'all=Keyser');
mySelect.options[mySelect.options.length] = new Option("Martinsburg Schools",'all=Martinsburg');
mySelect.options[mySelect.options.length] = new Option("Morgantown Schools",'all=Morgantown');
mySelect.options[mySelect.options.length] = new Option("Mount Gay Schools",'all=Mount_Gay');
mySelect.options[mySelect.options.length] = new Option("Nutter Fort Schools",'all=Nutter_Fort');
mySelect.options[mySelect.options.length] = new Option("Parkersburg Schools",'all=Parkersburg');
mySelect.options[mySelect.options.length] = new Option("Wheeling Schools",'all=Wheeling');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
var tmpLatLng=0;
var tmpLen=0;
tmpLatLng=new GLatLng(38.41928200000000259,-82.4432759999999973);
tmpLen=Huntington.length;
Huntington[tmpLen] = createMarker(tmpLatLng,"
",iconRd);
Huntington[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Huntington Junior College",'Huntington=' + Huntington.length);
tmpLatLng=new GLatLng(39.27322999999999808,-81.5489100000000064);
tmpLen=Parkersburg.length;
Parkersburg[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Parkersburg[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Mountain State College",'Parkersburg=' + Parkersburg.length);
tmpLatLng=new GLatLng(38.42268399999999672,-81.7882079999999973);
tmpLen=Cross_Lanes.length;
Cross_Lanes[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Cross_Lanes[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("National Institute Of Technology",'Cross_Lanes=' + Cross_Lanes.length);
tmpLatLng=new GLatLng(39.43880000000000052,-78.9804599999999936);
tmpLen=Keyser.length;
Keyser[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Keyser[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Potomac State College Of West Virginia University",'Keyser=' + Keyser.length);
tmpLatLng=new GLatLng(37.84164799999999928,-82.0081710000000043);
tmpLen=Mount_Gay.length;
Mount_Gay[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Mount_Gay[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Southern West Virginia Comm & Technical College",'Mount_Gay=' + Mount_Gay.length);
tmpLatLng=new GLatLng(39.45622999999999791,-77.9639889999999979);
tmpLen=Martinsburg.length;
Martinsburg[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Martinsburg[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Valley College",'Martinsburg=' + Martinsburg.length);
tmpLatLng=new GLatLng(39.26084000000000173,-80.3234829999999959);
tmpLen=Nutter_Fort.length;
Nutter_Fort[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Nutter_Fort[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("West Virginia Business College-nutter Fort",'Nutter_Fort=' + Nutter_Fort.length);
tmpLatLng=new GLatLng(40.06910299999999836,-80.7236750000000000);
tmpLen=Wheeling.length;
Wheeling[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Wheeling[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("West Virginia Business College-wheeling",'Wheeling=' + Wheeling.length);
tmpLatLng=new GLatLng(38.34789700000000323,-81.6344449999999994);
tmpLen=Charleston.length;
Charleston[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Charleston[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("West Virginia Junior College",'Charleston=' + Charleston.length);
tmpLatLng=new GLatLng(39.63276599999999660,-79.9545399999999943);
tmpLen=Morgantown.length;
Morgantown[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Morgantown[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("West Virginia Junior College",'Morgantown=' + Morgantown.length);
tmpLatLng=new GLatLng(40.06311000000000177,-80.7216080000000033);
tmpLen=Wheeling.length;
Wheeling[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Wheeling[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("West Virginia Northern Community College",'Wheeling=' + Wheeling.length);
map.removeOverlays(Charleston);
map.removeOverlays(Cross_Lanes);
map.removeOverlays(Huntington);
map.removeOverlays(Keyser);
map.removeOverlays(Martinsburg);
map.removeOverlays(Morgantown);
map.removeOverlays(Mount_Gay);
map.removeOverlays(Nutter_Fort);
map.removeOverlays(Parkersburg);
map.removeOverlays(Wheeling);
setTimeout(function(){map.addOverlays(Charleston)},1000);
setTimeout(function(){map.addOverlays(Cross_Lanes)},1000);
setTimeout(function(){map.addOverlays(Huntington)},1000);
setTimeout(function(){map.addOverlays(Keyser)},1000);
setTimeout(function(){map.addOverlays(Martinsburg)},1000);
setTimeout(function(){map.addOverlays(Morgantown)},1000);
setTimeout(function(){map.addOverlays(Mount_Gay)},1000);
setTimeout(function(){map.addOverlays(Nutter_Fort)},1000);
setTimeout(function(){map.addOverlays(Parkersburg)},1000);
setTimeout(function(){map.addOverlays(Wheeling)},1000);
getPoly("","state","","WV");}
// End addStateMarkers JavaScript Function
//open all when map is defined
function openAll() {
if (map) {
selectChange("all");
} else {
setTimeout("openAll()",200);
}
}
// 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].point.x;
var markLat = myArray[i].point.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].point.x;
maxLat = myArray[0].point.y;
minLng = myArray[0].point.x;
minLat = myArray[0].point.y;
}
// Recenter map based on global max/mins
function reCenterMap(){
//alert('#' + minLat + '#' + minLng + '#' + maxLat + '#' + maxLng);
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,10);
/*
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) {
if (selection.options) {
var _openNewWindow=true;
var myVal = selection.options[selection.selectedIndex].value;
} else {
var _openNewWindow=false;
var myVal=selection;
}
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('schools-by-distance') == -1)
window.open(location.href + '/map/all');
else
window.open('/search////all');
map.removeOverlays(Charleston);
map.removeOverlays(Cross_Lanes);
map.removeOverlays(Huntington);
map.removeOverlays(Keyser);
map.removeOverlays(Martinsburg);
map.removeOverlays(Morgantown);
map.removeOverlays(Mount_Gay);
map.removeOverlays(Nutter_Fort);
map.removeOverlays(Parkersburg);
map.removeOverlays(Wheeling);
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(Huntington);map.removeOverlays(Charleston);
map.removeOverlays(Cross_Lanes);
map.removeOverlays(Huntington);
map.removeOverlays(Keyser);
map.removeOverlays(Martinsburg);
map.removeOverlays(Morgantown);
map.removeOverlays(Mount_Gay);
map.removeOverlays(Nutter_Fort);
map.removeOverlays(Parkersburg);
map.removeOverlays(Wheeling);
map.addOverlays(Charleston);
centerByArray(Charleston, false, false);
cntMarker += Charleston.length;
map.addOverlays(Cross_Lanes);
centerByArray(Cross_Lanes, false, false);
cntMarker += Cross_Lanes.length;
map.addOverlays(Huntington);
centerByArray(Huntington, false, false);
cntMarker += Huntington.length;
map.addOverlays(Keyser);
centerByArray(Keyser, false, false);
cntMarker += Keyser.length;
map.addOverlays(Martinsburg);
centerByArray(Martinsburg, false, false);
cntMarker += Martinsburg.length;
map.addOverlays(Morgantown);
centerByArray(Morgantown, false, false);
cntMarker += Morgantown.length;
map.addOverlays(Mount_Gay);
centerByArray(Mount_Gay, false, false);
cntMarker += Mount_Gay.length;
map.addOverlays(Nutter_Fort);
centerByArray(Nutter_Fort, false, false);
cntMarker += Nutter_Fort.length;
map.addOverlays(Parkersburg);
centerByArray(Parkersburg, false, false);
cntMarker += Parkersburg.length;
map.addOverlays(Wheeling);
centerByArray(Wheeling, false, false);
cntMarker += Wheeling.length;
reCenterMap();
//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');
}
}
function createMarker(point, label, icon){
var marker = new GMarker(point, icon);
var html = label;
GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); });
return marker;
}