function addMarkers()
{
mySelect = document.getElementById('selection');
Markleysburg = [];Fairchance = [];Uniontown = [];Mcclellandtown = [];Point_Marion = [];Belle_Vernon = [];Brownsville = [];Connellsville = [];New_Salem = [];East_Millsboro = [];Perryopolis = [];Melcroft = [];Dunbar = [];Vanderbilt = [];Mc_Clellandtown = [];Masontown = [];Smithfield = [];Normalville = [];Farmington = [];mySelect.options[mySelect.options.length] = new Option("Belle Vernon schools",'all=Belle_Vernon');
mySelect.options[mySelect.options.length] = new Option("Brownsville schools",'all=Brownsville');
mySelect.options[mySelect.options.length] = new Option("Connellsville schools",'all=Connellsville');
mySelect.options[mySelect.options.length] = new Option("Dunbar schools",'all=Dunbar');
mySelect.options[mySelect.options.length] = new Option("East Millsboro schools",'all=East_Millsboro');
mySelect.options[mySelect.options.length] = new Option("Fairchance schools",'all=Fairchance');
mySelect.options[mySelect.options.length] = new Option("Farmington schools",'all=Farmington');
mySelect.options[mySelect.options.length] = new Option("Markleysburg schools",'all=Markleysburg');
mySelect.options[mySelect.options.length] = new Option("Masontown schools",'all=Masontown');
mySelect.options[mySelect.options.length] = new Option("Mc Clellandtown schools",'all=Mc_Clellandtown');
mySelect.options[mySelect.options.length] = new Option("Mcclellandtown schools",'all=Mcclellandtown');
mySelect.options[mySelect.options.length] = new Option("Melcroft schools",'all=Melcroft');
mySelect.options[mySelect.options.length] = new Option("New Salem schools",'all=New_Salem');
mySelect.options[mySelect.options.length] = new Option("Normalville schools",'all=Normalville');
mySelect.options[mySelect.options.length] = new Option("Perryopolis schools",'all=Perryopolis');
mySelect.options[mySelect.options.length] = new Option("Point Marion schools",'all=Point_Marion');
mySelect.options[mySelect.options.length] = new Option("Smithfield schools",'all=Smithfield');
mySelect.options[mySelect.options.length] = new Option("Uniontown schools",'all=Uniontown');
mySelect.options[mySelect.options.length] = new Option("Vanderbilt schools",'all=Vanderbilt');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Markleysburg[Markleysburg.length] = createMarker(new GPoint(-79.48827362,39.77367401),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("A J Mcmullen School",'Markleysburg=' + Markleysburg.length);
Fairchance[Fairchance.length] = createMarker(new GPoint(-79.75489807,39.81724167),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("A L Wilson Elementary School",'Fairchance=' + Fairchance.length);
Uniontown[Uniontown.length] = createMarker(new GPoint(-79.78376007,39.82696533),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Albert Gallatin Area Senior High School",'Uniontown=' + Uniontown.length);
Mcclellandtown[Mcclellandtown.length] = createMarker(new GPoint(-79.90101624,39.84679031),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Albert Gallatin North Middle School",'Mcclellandtown=' + Mcclellandtown.length);
Point_Marion[Point_Marion.length] = createMarker(new GPoint(-79.91982269,39.78039932),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Albert Gallatin South Middle School",'Point_Marion=' + Point_Marion.length);
Belle_Vernon[Belle_Vernon.length] = createMarker(new GPoint(-79.83168793,40.11486435),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bellmar Middle School",'Belle_Vernon=' + Belle_Vernon.length);
Uniontown[Uniontown.length] = createMarker(new GPoint(-79.73371887,39.89159393),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ben Franklin School",'Uniontown=' + Uniontown.length);
Brownsville[Brownsville.length] = createMarker(new GPoint(-79.89489746,40.00805283),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Brownsville Area High School",'Brownsville=' + Brownsville.length);
Connellsville[Connellsville.length] = createMarker(new GPoint(-79.56050873,40.05554199),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bullskin Elementary School",'Connellsville=' + Connellsville.length);
New_Salem[New_Salem.length] = createMarker(new GPoint(-79.86225128,39.95703125),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cardale Elementary School",'New_Salem=' + New_Salem.length);
East_Millsboro[East_Millsboro.length] = createMarker(new GPoint(-79.95085907,39.96385956),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'East_Millsboro=' + East_Millsboro.length);
Perryopolis[Perryopolis.length] = createMarker(new GPoint(-79.74680328,40.08885956),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Perryopolis=' + Perryopolis.length);
Uniontown[Uniontown.length] = createMarker(new GPoint(-79.70337677,39.91260147),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clark Elementary School",'Uniontown=' + Uniontown.length);
Melcroft[Melcroft.length] = createMarker(new GPoint(-79.37228394,40.06020355),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clifford N Pritts Elementary School",'Melcroft=' + Melcroft.length);
Connellsville[Connellsville.length] = createMarker(new GPoint(-79.57704163,40.02494049),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Connellsville Area Senior High School",'Connellsville=' + Connellsville.length);
Connellsville[Connellsville.length] = createMarker(new GPoint(-79.58933258,40.01771164),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Connellsville Junior High School East",'Connellsville=' + Connellsville.length);
Connellsville[Connellsville.length] = createMarker(new GPoint(-79.61743164,40.01098251),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Connellsville Junior High School West",'Connellsville=' + Connellsville.length);
Connellsville[Connellsville.length] = createMarker(new GPoint(-79.56501007,40.02161026),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Connellsville Township Elementary School",'Connellsville=' + Connellsville.length);
Brownsville[Brownsville.length] = createMarker(new GPoint(-79.87242126,40.00261307),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cox-donahey Elementary School",'Brownsville=' + Brownsville.length);
Uniontown[Uniontown.length] = createMarker(new GPoint(-79.78421021,39.82891464),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("D Ferd Swaney Elementary School",'Uniontown=' + Uniontown.length);
Dunbar[Dunbar.length] = createMarker(new GPoint(-79.63948059,39.96599197),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dunbar Boro Elementary School",'Dunbar=' + Dunbar.length);
Connellsville[Connellsville.length] = createMarker(new GPoint(-79.61977386,40.01959991),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dunbar Township Elementary School",'Connellsville=' + Connellsville.length);
Uniontown[Uniontown.length] = createMarker(new GPoint(-79.74296570,39.86316681),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fayette County Avts",'Uniontown=' + Uniontown.length);
Vanderbilt[Vanderbilt.length] = createMarker(new GPoint(-79.70291138,40.02318573),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Franklin School",'Vanderbilt=' + Vanderbilt.length);
Perryopolis[Perryopolis.length] = createMarker(new GPoint(-79.75963593,40.08976364),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Frazier High School",'Perryopolis=' + Perryopolis.length);
Perryopolis[Perryopolis.length] = createMarker(new GPoint(-79.75963593,40.08976364),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Frazier Middle School",'Perryopolis=' + Perryopolis.length);
Point_Marion[Point_Marion.length] = createMarker(new GPoint(-79.91979980,39.78100586),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Friendship Hill Elementary School",'Point_Marion=' + Point_Marion.length);
Mc_Clellandtown[Mc_Clellandtown.length] = createMarker(new GPoint(-79.85652161,39.86469269),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("George J Plava Elementary School",'Mc_Clellandtown=' + Mc_Clellandtown.length);
Uniontown[Uniontown.length] = createMarker(new GPoint(-79.72802734,39.87892914),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hatfield Elementary School",'Uniontown=' + Uniontown.length);
Uniontown[Uniontown.length] = createMarker(new GPoint(-79.70835114,39.86301422),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hutchinson Elementary School",'Uniontown=' + Uniontown.length);
Uniontown[Uniontown.length] = createMarker(new GPoint(-79.71473694,39.90031052),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kennedy Elementary School",'Uniontown=' + Uniontown.length);
Uniontown[Uniontown.length] = createMarker(new GPoint(-79.70574951,39.90117645),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lafayette School",'Uniontown=' + Uniontown.length);
Uniontown[Uniontown.length] = createMarker(new GPoint(-79.75148010,39.89477539),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Laurel Highlands Middle School",'Uniontown=' + Uniontown.length);
Uniontown[Uniontown.length] = createMarker(new GPoint(-79.71199799,39.91123581),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Laurel Highlands Senior High School",'Uniontown=' + Uniontown.length);
Markleysburg[Markleysburg.length] = createMarker(new GPoint(-79.48715973,39.72179794),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Marclay School",'Markleysburg=' + Markleysburg.length);
Belle_Vernon[Belle_Vernon.length] = createMarker(new GPoint(-79.83168793,40.11486435),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Marion Elementary School",'Belle_Vernon=' + Belle_Vernon.length);
Uniontown[Uniontown.length] = createMarker(new GPoint(-79.67970276,39.92176437),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Marshall Elementary School",'Uniontown=' + Uniontown.length);
Masontown[Masontown.length] = createMarker(new GPoint(-79.90116119,39.84741974),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Masontown Elementary School",'Masontown=' + Masontown.length);
Uniontown[Uniontown.length] = createMarker(new GPoint(-79.77958679,39.93539429),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Menallen School",'Uniontown=' + Uniontown.length);
Connellsville[Connellsville.length] = createMarker(new GPoint(-79.57337952,40.02150726),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Fayette County Avts",'Connellsville=' + Connellsville.length);
Perryopolis[Perryopolis.length] = createMarker(new GPoint(-79.75963593,40.08976364),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Perry Elementary School",'Perryopolis=' + Perryopolis.length);
Brownsville[Brownsville.length] = createMarker(new GPoint(-79.89489746,40.00805283),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Redstone Middle School",'Brownsville=' + Brownsville.length);
Smithfield[Smithfield.length] = createMarker(new GPoint(-79.80723572,39.80233765),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Smithfield Elementary School",'Smithfield=' + Smithfield.length);
Connellsville[Connellsville.length] = createMarker(new GPoint(-79.58758545,40.00783157),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South Side Elementary School",'Connellsville=' + Connellsville.length);
Normalville[Normalville.length] = createMarker(new GPoint(-79.44663239,40.00166321),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Springfield Elementary School",'Normalville=' + Normalville.length);
Uniontown[Uniontown.length] = createMarker(new GPoint(-79.72005463,39.89635849),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Uniontown Area Senior High School",'Uniontown=' + Uniontown.length);
Farmington[Farmington.length] = createMarker(new GPoint(-79.56803894,39.80514145),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wharton School",'Farmington=' + Farmington.length);
Connellsville[Connellsville.length] = createMarker(new GPoint(-79.58267975,40.02433395),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Zachariah Connell Elementary School",'Connellsville=' + Connellsville.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(Belle_Vernon);
map.removeOverlays(Brownsville);
map.removeOverlays(Connellsville);
map.removeOverlays(Dunbar);
map.removeOverlays(East_Millsboro);
map.removeOverlays(Fairchance);
map.removeOverlays(Farmington);
map.removeOverlays(Markleysburg);
map.removeOverlays(Masontown);
map.removeOverlays(Mc_Clellandtown);
map.removeOverlays(Mcclellandtown);
map.removeOverlays(Melcroft);
map.removeOverlays(New_Salem);
map.removeOverlays(Normalville);
map.removeOverlays(Perryopolis);
map.removeOverlays(Point_Marion);
map.removeOverlays(Smithfield);
map.removeOverlays(Uniontown);
map.removeOverlays(Vanderbilt);
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(Markleysburg);map.removeOverlays(Belle_Vernon);
map.removeOverlays(Brownsville);
map.removeOverlays(Connellsville);
map.removeOverlays(Dunbar);
map.removeOverlays(East_Millsboro);
map.removeOverlays(Fairchance);
map.removeOverlays(Farmington);
map.removeOverlays(Markleysburg);
map.removeOverlays(Masontown);
map.removeOverlays(Mc_Clellandtown);
map.removeOverlays(Mcclellandtown);
map.removeOverlays(Melcroft);
map.removeOverlays(New_Salem);
map.removeOverlays(Normalville);
map.removeOverlays(Perryopolis);
map.removeOverlays(Point_Marion);
map.removeOverlays(Smithfield);
map.removeOverlays(Uniontown);
map.removeOverlays(Vanderbilt);
map.addOverlays(Belle_Vernon);
centerByArray(Belle_Vernon, false, false);
cntMarker += Belle_Vernon.length;
map.addOverlays(Brownsville);
centerByArray(Brownsville, false, false);
cntMarker += Brownsville.length;
map.addOverlays(Connellsville);
centerByArray(Connellsville, false, false);
cntMarker += Connellsville.length;
map.addOverlays(Dunbar);
centerByArray(Dunbar, false, false);
cntMarker += Dunbar.length;
map.addOverlays(East_Millsboro);
centerByArray(East_Millsboro, false, false);
cntMarker += East_Millsboro.length;
map.addOverlays(Fairchance);
centerByArray(Fairchance, false, false);
cntMarker += Fairchance.length;
map.addOverlays(Farmington);
centerByArray(Farmington, false, false);
cntMarker += Farmington.length;
map.addOverlays(Markleysburg);
centerByArray(Markleysburg, false, false);
cntMarker += Markleysburg.length;
map.addOverlays(Masontown);
centerByArray(Masontown, false, false);
cntMarker += Masontown.length;
map.addOverlays(Mc_Clellandtown);
centerByArray(Mc_Clellandtown, false, false);
cntMarker += Mc_Clellandtown.length;
map.addOverlays(Mcclellandtown);
centerByArray(Mcclellandtown, false, false);
cntMarker += Mcclellandtown.length;
map.addOverlays(Melcroft);
centerByArray(Melcroft, false, false);
cntMarker += Melcroft.length;
map.addOverlays(New_Salem);
centerByArray(New_Salem, false, false);
cntMarker += New_Salem.length;
map.addOverlays(Normalville);
centerByArray(Normalville, false, false);
cntMarker += Normalville.length;
map.addOverlays(Perryopolis);
centerByArray(Perryopolis, false, false);
cntMarker += Perryopolis.length;
map.addOverlays(Point_Marion);
centerByArray(Point_Marion, false, false);
cntMarker += Point_Marion.length;
map.addOverlays(Smithfield);
centerByArray(Smithfield, false, false);
cntMarker += Smithfield.length;
map.addOverlays(Uniontown);
centerByArray(Uniontown, false, false);
cntMarker += Uniontown.length;
map.addOverlays(Vanderbilt);
centerByArray(Vanderbilt, false, false);
cntMarker += Vanderbilt.length;
centerByArray(Markleysburg,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');
}
}