function addMarkers()
{
mySelect = document.getElementById('selection');
Ashland = [];Orwigsburg = [];Cressona = [];Schuylkill_Haven = [];Friedensburg = [];Pottsville = [];Frackville = [];Valley_View = [];Minersville = [];Mahanoy_City = [];Klingerstown = [];Mcadoo = [];Pine_Grove = [];Ringtown = [];Tamaqua = [];Saint_Clair = [];Mar_Lin = [];Shenandoah = [];Tremont = [];Hegins = [];New_Ringgold = [];Tower_City = [];mySelect.options[mySelect.options.length] = new Option("Ashland schools",'all=Ashland');
mySelect.options[mySelect.options.length] = new Option("Cressona schools",'all=Cressona');
mySelect.options[mySelect.options.length] = new Option("Frackville schools",'all=Frackville');
mySelect.options[mySelect.options.length] = new Option("Friedensburg schools",'all=Friedensburg');
mySelect.options[mySelect.options.length] = new Option("Hegins schools",'all=Hegins');
mySelect.options[mySelect.options.length] = new Option("Klingerstown schools",'all=Klingerstown');
mySelect.options[mySelect.options.length] = new Option("Mahanoy City schools",'all=Mahanoy_City');
mySelect.options[mySelect.options.length] = new Option("Mar Lin schools",'all=Mar_Lin');
mySelect.options[mySelect.options.length] = new Option("Mcadoo schools",'all=Mcadoo');
mySelect.options[mySelect.options.length] = new Option("Minersville schools",'all=Minersville');
mySelect.options[mySelect.options.length] = new Option("New Ringgold schools",'all=New_Ringgold');
mySelect.options[mySelect.options.length] = new Option("Orwigsburg schools",'all=Orwigsburg');
mySelect.options[mySelect.options.length] = new Option("Pine Grove schools",'all=Pine_Grove');
mySelect.options[mySelect.options.length] = new Option("Pottsville schools",'all=Pottsville');
mySelect.options[mySelect.options.length] = new Option("Ringtown schools",'all=Ringtown');
mySelect.options[mySelect.options.length] = new Option("Saint Clair schools",'all=Saint_Clair');
mySelect.options[mySelect.options.length] = new Option("Schuylkill Haven schools",'all=Schuylkill_Haven');
mySelect.options[mySelect.options.length] = new Option("Shenandoah schools",'all=Shenandoah');
mySelect.options[mySelect.options.length] = new Option("Tamaqua schools",'all=Tamaqua');
mySelect.options[mySelect.options.length] = new Option("Tower City schools",'all=Tower_City');
mySelect.options[mySelect.options.length] = new Option("Tremont schools",'all=Tremont');
mySelect.options[mySelect.options.length] = new Option("Valley View schools",'all=Valley_View');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Ashland[Ashland.length] = createMarker(new GPoint(-76.33977509,40.77588654),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ashland Area Elementary School",'Ashland=' + Ashland.length);
Orwigsburg[Orwigsburg.length] = createMarker(new GPoint(-76.08644104,40.65535736),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Blue Mountain East Elementary School",'Orwigsburg=' + Orwigsburg.length);
Cressona[Cressona.length] = createMarker(new GPoint(-76.19488525,40.63200760),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Blue Mountain El Cressona School",'Cressona=' + Cressona.length);
Schuylkill_Haven[Schuylkill_Haven.length] = createMarker(new GPoint(-76.17169952,40.62566757),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Blue Mountain High School",'Schuylkill_Haven=' + Schuylkill_Haven.length);
Orwigsburg[Orwigsburg.length] = createMarker(new GPoint(-76.08599854,40.65545273),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Blue Mountain Middle School",'Orwigsburg=' + Orwigsburg.length);
Friedensburg[Friedensburg.length] = createMarker(new GPoint(-76.25875854,40.58639908),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Blue Mountain West Elementary School",'Friedensburg=' + Friedensburg.length);
Pottsville[Pottsville.length] = createMarker(new GPoint(-76.21279907,40.68119812),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clarke El Center",'Pottsville=' + Pottsville.length);
Frackville[Frackville.length] = createMarker(new GPoint(-76.23480988,40.78339005),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Frackville Area Elementary School",'Frackville=' + Frackville.length);
Valley_View[Valley_View.length] = createMarker(new GPoint(-76.54328400,40.64511000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hegins-hubley Elementary School",'Valley_View=' + Valley_View.length);
Pottsville[Pottsville.length] = createMarker(new GPoint(-76.21244049,40.68368912),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Lengel Middle School",'Pottsville=' + Pottsville.length);
Minersville[Minersville.length] = createMarker(new GPoint(-76.25990295,40.68999863),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Llewellyn Elementary School",'Minersville=' + Minersville.length);
Mahanoy_City[Mahanoy_City.length] = createMarker(new GPoint(-76.14810181,40.81060028),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mahanoy Area Elementary School",'Mahanoy_City=' + Mahanoy_City.length);
Mahanoy_City[Mahanoy_City.length] = createMarker(new GPoint(-76.14810181,40.81060028),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mahanoy Area High School",'Mahanoy_City=' + Mahanoy_City.length);
Mahanoy_City[Mahanoy_City.length] = createMarker(new GPoint(-76.14810181,40.81060028),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mahanoy Area Middle School",'Mahanoy_City=' + Mahanoy_City.length);
Klingerstown[Klingerstown.length] = createMarker(new GPoint(-76.63700104,40.67419815),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mahantongo Elementary School",'Klingerstown=' + Klingerstown.length);
Mcadoo[Mcadoo.length] = createMarker(new GPoint(-75.99833679,40.89369202),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mcadoo-kelayres Elementary School",'Mcadoo=' + Mcadoo.length);
Minersville[Minersville.length] = createMarker(new GPoint(-76.25990295,40.68999863),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Minersville Area El Center",'Minersville=' + Minersville.length);
Minersville[Minersville.length] = createMarker(new GPoint(-76.25990295,40.68999863),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Minersville Area Junior Senior High School",'Minersville=' + Minersville.length);
Ashland[Ashland.length] = createMarker(new GPoint(-76.34596252,40.78181839),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Schuylkill Junior Senior High School",'Ashland=' + Ashland.length);
Pine_Grove[Pine_Grove.length] = createMarker(new GPoint(-76.38217163,40.56040192),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pine Grove Area High School",'Pine_Grove=' + Pine_Grove.length);
Pine_Grove[Pine_Grove.length] = createMarker(new GPoint(-76.38220215,40.56042862),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Pine Grove Area Middle School",'Pine_Grove=' + Pine_Grove.length);
Pine_Grove[Pine_Grove.length] = createMarker(new GPoint(-76.38220978,40.56044388),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pine Grove Elementary School",'Pine_Grove=' + Pine_Grove.length);
Pottsville[Pottsville.length] = createMarker(new GPoint(-76.21279907,40.68119812),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pottsville Area High School",'Pottsville=' + Pottsville.length);
Ringtown[Ringtown.length] = createMarker(new GPoint(-76.23280334,40.85680008),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ringtown Elementary School",'Ringtown=' + Ringtown.length);
Tamaqua[Tamaqua.length] = createMarker(new GPoint(-75.98715973,40.82641220),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Rush Elementary School",'Tamaqua=' + Tamaqua.length);
Saint_Clair[Saint_Clair.length] = createMarker(new GPoint(-76.18650818,40.71763611),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Saint Clair Area El/ms Elementary School",'Saint_Clair=' + Saint_Clair.length);
Schuylkill_Haven[Schuylkill_Haven.length] = createMarker(new GPoint(-76.17206573,40.63403702),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Schuylkill Haven El Center",'Schuylkill_Haven=' + Schuylkill_Haven.length);
Schuylkill_Haven[Schuylkill_Haven.length] = createMarker(new GPoint(-76.17206573,40.63403702),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Schuylkill Haven Middle School",'Schuylkill_Haven=' + Schuylkill_Haven.length);
Schuylkill_Haven[Schuylkill_Haven.length] = createMarker(new GPoint(-76.17206573,40.63403702),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Schuylkill Haven Senior High School",'Schuylkill_Haven=' + Schuylkill_Haven.length);
Frackville[Frackville.length] = createMarker(new GPoint(-76.22852325,40.77612686),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Schuylkill Technology Centers-",'Frackville=' + Frackville.length);
Mar_Lin[Mar_Lin.length] = createMarker(new GPoint(-76.21649933,40.69419861),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Schuylkill Technology Centers-",'Mar_Lin=' + Mar_Lin.length);
Shenandoah[Shenandoah.length] = createMarker(new GPoint(-76.21056366,40.81898117),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Shenandoah Valley Elementary School",'Shenandoah=' + Shenandoah.length);
Shenandoah[Shenandoah.length] = createMarker(new GPoint(-76.21056366,40.81898117),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Shenandoah Valley Junior Senior High School",'Shenandoah=' + Shenandoah.length);
Tamaqua[Tamaqua.length] = createMarker(new GPoint(-75.97808075,40.79226303),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Tamaqua Area Middle School",'Tamaqua=' + Tamaqua.length);
Tamaqua[Tamaqua.length] = createMarker(new GPoint(-75.98030090,40.80020142),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tamaqua Area Senior High School",'Tamaqua=' + Tamaqua.length);
Tamaqua[Tamaqua.length] = createMarker(new GPoint(-75.97947693,40.80202103),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Tamaqua Elementary School",'Tamaqua=' + Tamaqua.length);
Tremont[Tremont.length] = createMarker(new GPoint(-76.38742065,40.63346100),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Tremont Elementary School",'Tremont=' + Tremont.length);
Hegins[Hegins.length] = createMarker(new GPoint(-76.51723480,40.64828491),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tri-valley Junior Senior High School",'Hegins=' + Hegins.length);
New_Ringgold[New_Ringgold.length] = createMarker(new GPoint(-75.87206268,40.74812698),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("West Penn Township Elementary School",'New_Ringgold=' + New_Ringgold.length);
Tower_City[Tower_City.length] = createMarker(new GPoint(-76.50789642,40.59220123),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Williams Valley Elementary School",'Tower_City=' + Tower_City.length);
Tower_City[Tower_City.length] = createMarker(new GPoint(-76.50789642,40.59220123),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Williams Valley Junior Senior High School",'Tower_City=' + Tower_City.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(Ashland);
map.removeOverlays(Cressona);
map.removeOverlays(Frackville);
map.removeOverlays(Friedensburg);
map.removeOverlays(Hegins);
map.removeOverlays(Klingerstown);
map.removeOverlays(Mahanoy_City);
map.removeOverlays(Mar_Lin);
map.removeOverlays(Mcadoo);
map.removeOverlays(Minersville);
map.removeOverlays(New_Ringgold);
map.removeOverlays(Orwigsburg);
map.removeOverlays(Pine_Grove);
map.removeOverlays(Pottsville);
map.removeOverlays(Ringtown);
map.removeOverlays(Saint_Clair);
map.removeOverlays(Schuylkill_Haven);
map.removeOverlays(Shenandoah);
map.removeOverlays(Tamaqua);
map.removeOverlays(Tower_City);
map.removeOverlays(Tremont);
map.removeOverlays(Valley_View);
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(Ashland);map.removeOverlays(Ashland);
map.removeOverlays(Cressona);
map.removeOverlays(Frackville);
map.removeOverlays(Friedensburg);
map.removeOverlays(Hegins);
map.removeOverlays(Klingerstown);
map.removeOverlays(Mahanoy_City);
map.removeOverlays(Mar_Lin);
map.removeOverlays(Mcadoo);
map.removeOverlays(Minersville);
map.removeOverlays(New_Ringgold);
map.removeOverlays(Orwigsburg);
map.removeOverlays(Pine_Grove);
map.removeOverlays(Pottsville);
map.removeOverlays(Ringtown);
map.removeOverlays(Saint_Clair);
map.removeOverlays(Schuylkill_Haven);
map.removeOverlays(Shenandoah);
map.removeOverlays(Tamaqua);
map.removeOverlays(Tower_City);
map.removeOverlays(Tremont);
map.removeOverlays(Valley_View);
map.addOverlays(Ashland);
centerByArray(Ashland, false, false);
cntMarker += Ashland.length;
map.addOverlays(Cressona);
centerByArray(Cressona, false, false);
cntMarker += Cressona.length;
map.addOverlays(Frackville);
centerByArray(Frackville, false, false);
cntMarker += Frackville.length;
map.addOverlays(Friedensburg);
centerByArray(Friedensburg, false, false);
cntMarker += Friedensburg.length;
map.addOverlays(Hegins);
centerByArray(Hegins, false, false);
cntMarker += Hegins.length;
map.addOverlays(Klingerstown);
centerByArray(Klingerstown, false, false);
cntMarker += Klingerstown.length;
map.addOverlays(Mahanoy_City);
centerByArray(Mahanoy_City, false, false);
cntMarker += Mahanoy_City.length;
map.addOverlays(Mar_Lin);
centerByArray(Mar_Lin, false, false);
cntMarker += Mar_Lin.length;
map.addOverlays(Mcadoo);
centerByArray(Mcadoo, false, false);
cntMarker += Mcadoo.length;
map.addOverlays(Minersville);
centerByArray(Minersville, false, false);
cntMarker += Minersville.length;
map.addOverlays(New_Ringgold);
centerByArray(New_Ringgold, false, false);
cntMarker += New_Ringgold.length;
map.addOverlays(Orwigsburg);
centerByArray(Orwigsburg, false, false);
cntMarker += Orwigsburg.length;
map.addOverlays(Pine_Grove);
centerByArray(Pine_Grove, false, false);
cntMarker += Pine_Grove.length;
map.addOverlays(Pottsville);
centerByArray(Pottsville, false, false);
cntMarker += Pottsville.length;
map.addOverlays(Ringtown);
centerByArray(Ringtown, false, false);
cntMarker += Ringtown.length;
map.addOverlays(Saint_Clair);
centerByArray(Saint_Clair, false, false);
cntMarker += Saint_Clair.length;
map.addOverlays(Schuylkill_Haven);
centerByArray(Schuylkill_Haven, false, false);
cntMarker += Schuylkill_Haven.length;
map.addOverlays(Shenandoah);
centerByArray(Shenandoah, false, false);
cntMarker += Shenandoah.length;
map.addOverlays(Tamaqua);
centerByArray(Tamaqua, false, false);
cntMarker += Tamaqua.length;
map.addOverlays(Tower_City);
centerByArray(Tower_City, false, false);
cntMarker += Tower_City.length;
map.addOverlays(Tremont);
centerByArray(Tremont, false, false);
cntMarker += Tremont.length;
map.addOverlays(Valley_View);
centerByArray(Valley_View, false, false);
cntMarker += Valley_View.length;
centerByArray(Ashland,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');
}
}