function addMarkers()
{
mySelect = document.getElementById('selection');
Cumberland = [];Frostburg = [];Lavale = [];Cresaptown = [];Flintstone = [];Lonaconing = [];Mount_Savage = [];Mt_Savage = [];Westernport = [];mySelect.options[mySelect.options.length] = new Option("Cresaptown schools",'all=Cresaptown');
mySelect.options[mySelect.options.length] = new Option("Cumberland schools",'all=Cumberland');
mySelect.options[mySelect.options.length] = new Option("Flintstone schools",'all=Flintstone');
mySelect.options[mySelect.options.length] = new Option("Frostburg schools",'all=Frostburg');
mySelect.options[mySelect.options.length] = new Option("Lavale schools",'all=Lavale');
mySelect.options[mySelect.options.length] = new Option("Lonaconing schools",'all=Lonaconing');
mySelect.options[mySelect.options.length] = new Option("Mount Savage schools",'all=Mount_Savage');
mySelect.options[mySelect.options.length] = new Option("Mt Savage schools",'all=Mt_Savage');
mySelect.options[mySelect.options.length] = new Option("Westernport schools",'all=Westernport');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Cumberland[Cumberland.length] = createMarker(new GPoint(-78.76790619,39.65098953),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Allegany County Home & Hospital",'Cumberland=' + Cumberland.length);
Cumberland[Cumberland.length] = createMarker(new GPoint(-78.77497101,39.65643692),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Allegany High School",'Cumberland=' + Cumberland.length);
Frostburg[Frostburg.length] = createMarker(new GPoint(-78.93160248,39.65470123),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Beall Elementary School",'Frostburg=' + Frostburg.length);
Frostburg[Frostburg.length] = createMarker(new GPoint(-78.92767334,39.65675354),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Beall High School",'Frostburg=' + Frostburg.length);
Cumberland[Cumberland.length] = createMarker(new GPoint(-78.85165405,39.57735825),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bel Air Elementary School",'Cumberland=' + Cumberland.length);
Cumberland[Cumberland.length] = createMarker(new GPoint(-78.77143097,39.66606903),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Braddock Middle School",'Cumberland=' + Cumberland.length);
Lavale[Lavale.length] = createMarker(new GPoint(-78.81488037,39.66051483),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cash Valley Elementary School",'Lavale=' + Lavale.length);
Cresaptown[Cresaptown.length] = createMarker(new GPoint(-78.82469177,39.60004044),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Center For Career & Technology Education",'Cresaptown=' + Cresaptown.length);
Cresaptown[Cresaptown.length] = createMarker(new GPoint(-78.83192444,39.58982468),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cresaptown Elementary School",'Cresaptown=' + Cresaptown.length);
Frostburg[Frostburg.length] = createMarker(new GPoint(-78.90110016,39.65428162),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eckhart Alternative School",'Frostburg=' + Frostburg.length);
Flintstone[Flintstone.length] = createMarker(new GPoint(-78.56502533,39.70207214),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Flintstone Elementary School",'Flintstone=' + Flintstone.length);
Cumberland[Cumberland.length] = createMarker(new GPoint(-78.74902344,39.64446259),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fort Hill High School",'Cumberland=' + Cumberland.length);
Frostburg[Frostburg.length] = createMarker(new GPoint(-78.93033600,39.66979599),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Frost Elementary School",'Frostburg=' + Frostburg.length);
Lonaconing[Lonaconing.length] = createMarker(new GPoint(-78.95311737,39.58125687),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("George's Creek Elementary School",'Lonaconing=' + Lonaconing.length);
Cumberland[Cumberland.length] = createMarker(new GPoint(-78.77043915,39.62765884),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("John Humbird Elementary School",'Cumberland=' + Cumberland.length);
Mount_Savage[Mount_Savage.length] = createMarker(new GPoint(-78.88531494,39.70081711),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mount Savage Middle School",'Mount_Savage=' + Mount_Savage.length);
Mt_Savage[Mt_Savage.length] = createMarker(new GPoint(-78.84472100,39.70077300),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mt. Savage Elementary School",'Mt_Savage=' + Mt_Savage.length);
Cumberland[Cumberland.length] = createMarker(new GPoint(-78.75489807,39.67598343),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Northeast Elementary School",'Cumberland=' + Cumberland.length);
Lavale[Lavale.length] = createMarker(new GPoint(-78.82666016,39.64425278),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Parkside Elementary School",'Lavale=' + Lavale.length);
Cumberland[Cumberland.length] = createMarker(new GPoint(-78.75768280,39.63570404),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South Penn Elementary School",'Cumberland=' + Cumberland.length);
Cumberland[Cumberland.length] = createMarker(new GPoint(-10.00000000,10.00000000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Transition Program At Cumberland",'Cumberland=' + Cumberland.length);
Frostburg[Frostburg.length] = createMarker(new GPoint(-78.93180084,39.64799881),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Transition Program At Frostburg",'Frostburg=' + Frostburg.length);
Cumberland[Cumberland.length] = createMarker(new GPoint(-78.74566650,39.63721085),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Washington Middle School",'Cumberland=' + Cumberland.length);
Cumberland[Cumberland.length] = createMarker(new GPoint(-78.77252960,39.64948273),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("West Side Elementary School",'Cumberland=' + Cumberland.length);
Westernport[Westernport.length] = createMarker(new GPoint(-79.04071045,39.48139191),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Westernport Elementary School",'Westernport=' + Westernport.length);
Lonaconing[Lonaconing.length] = createMarker(new GPoint(-78.99021912,39.55567932),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Westmar High School",'Lonaconing=' + Lonaconing.length);
Westernport[Westernport.length] = createMarker(new GPoint(-79.03826141,39.48601913),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Westmar Middle School",'Westernport=' + Westernport.length);
} // 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,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)
{
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(Cresaptown);
map.removeOverlays(Cumberland);
map.removeOverlays(Flintstone);
map.removeOverlays(Frostburg);
map.removeOverlays(Lavale);
map.removeOverlays(Lonaconing);
map.removeOverlays(Mount_Savage);
map.removeOverlays(Mt_Savage);
map.removeOverlays(Westernport);
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(Cumberland);map.removeOverlays(Cresaptown);
map.removeOverlays(Cumberland);
map.removeOverlays(Flintstone);
map.removeOverlays(Frostburg);
map.removeOverlays(Lavale);
map.removeOverlays(Lonaconing);
map.removeOverlays(Mount_Savage);
map.removeOverlays(Mt_Savage);
map.removeOverlays(Westernport);
map.addOverlays(Cresaptown);
centerByArray(Cresaptown, false, false);
cntMarker += Cresaptown.length;
map.addOverlays(Cumberland);
centerByArray(Cumberland, false, false);
cntMarker += Cumberland.length;
map.addOverlays(Flintstone);
centerByArray(Flintstone, false, false);
cntMarker += Flintstone.length;
map.addOverlays(Frostburg);
centerByArray(Frostburg, false, false);
cntMarker += Frostburg.length;
map.addOverlays(Lavale);
centerByArray(Lavale, false, false);
cntMarker += Lavale.length;
map.addOverlays(Lonaconing);
centerByArray(Lonaconing, false, false);
cntMarker += Lonaconing.length;
map.addOverlays(Mount_Savage);
centerByArray(Mount_Savage, false, false);
cntMarker += Mount_Savage.length;
map.addOverlays(Mt_Savage);
centerByArray(Mt_Savage, false, false);
cntMarker += Mt_Savage.length;
map.addOverlays(Westernport);
centerByArray(Westernport, false, false);
cntMarker += Westernport.length;
centerByArray(Cumberland,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////all');
}
}