function addMarkers()
{
mySelect = document.getElementById('selection');
Mercer = [];Hermitage = [];Sharon = [];Hadley = [];Greenville = [];Farrell = [];Grove_City = [];Jamestown = [];Stoneboro = [];West_Middlesex = [];Sharpsville = [];mySelect.options[mySelect.options.length] = new Option("Farrell schools",'all=Farrell');
mySelect.options[mySelect.options.length] = new Option("Greenville schools",'all=Greenville');
mySelect.options[mySelect.options.length] = new Option("Grove City schools",'all=Grove_City');
mySelect.options[mySelect.options.length] = new Option("Hadley schools",'all=Hadley');
mySelect.options[mySelect.options.length] = new Option("Hermitage schools",'all=Hermitage');
mySelect.options[mySelect.options.length] = new Option("Jamestown schools",'all=Jamestown');
mySelect.options[mySelect.options.length] = new Option("Mercer schools",'all=Mercer');
mySelect.options[mySelect.options.length] = new Option("Sharon schools",'all=Sharon');
mySelect.options[mySelect.options.length] = new Option("Sharpsville schools",'all=Sharpsville');
mySelect.options[mySelect.options.length] = new Option("Stoneboro schools",'all=Stoneboro');
mySelect.options[mySelect.options.length] = new Option("West Middlesex schools",'all=West_Middlesex');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Mercer[Mercer.length] = createMarker(new GPoint(-80.18753815,41.29117966),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Advanced Charter Enterprise School",'Mercer=' + Mercer.length);
Hermitage[Hermitage.length] = createMarker(new GPoint(-80.44995117,41.23686600),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Artman Elementary School",'Hermitage=' + Hermitage.length);
Sharon[Sharon.length] = createMarker(new GPoint(-80.51757812,41.23337936),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Brookfield Elementary School",'Sharon=' + Sharon.length);
Sharon[Sharon.length] = createMarker(new GPoint(-80.49061584,41.23371124),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Case Avenue Elementary School",'Sharon=' + Sharon.length);
Hadley[Hadley.length] = createMarker(new GPoint(-80.20934296,41.42690277),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Commodore Perry Junior Senior High School",'Hadley=' + Hadley.length);
Hadley[Hadley.length] = createMarker(new GPoint(-80.20934296,41.42690277),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Commodore Perry School",'Hadley=' + Hadley.length);
Hermitage[Hermitage.length] = createMarker(new GPoint(-80.44998169,41.23792267),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Delahunty Middle School",'Hermitage=' + Hermitage.length);
Greenville[Greenville.length] = createMarker(new GPoint(-80.37786102,41.40453339),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("East Elementary School",'Greenville=' + Greenville.length);
Farrell[Farrell.length] = createMarker(new GPoint(-80.48592377,41.21224213),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Farrell Area Es/lms Elementary School",'Farrell=' + Farrell.length);
Farrell[Farrell.length] = createMarker(new GPoint(-80.48399353,41.21228790),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Farrell Area High School/ums",'Farrell=' + Farrell.length);
Grove_City[Grove_City.length] = createMarker(new GPoint(-80.08801900,41.15748000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("George Jr Republic MiddleSchool",'Grove_City=' + Grove_City.length);
Grove_City[Grove_City.length] = createMarker(new GPoint(-80.11068726,41.16742706),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("George Junior Republic High School",'Grove_City=' + Grove_City.length);
Grove_City[Grove_City.length] = createMarker(new GPoint(-80.11068726,41.16742706),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("George Junior Republic Middle School",'Grove_City=' + Grove_City.length);
Greenville[Greenville.length] = createMarker(new GPoint(-80.37224579,41.40416336),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Greenville Junior Senior High School",'Greenville=' + Greenville.length);
Grove_City[Grove_City.length] = createMarker(new GPoint(-80.09761810,41.16202927),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grove City Area High School",'Grove_City=' + Grove_City.length);
Grove_City[Grove_City.length] = createMarker(new GPoint(-80.08615112,41.15610123),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Grove City Area Middle School",'Grove_City=' + Grove_City.length);
Greenville[Greenville.length] = createMarker(new GPoint(-80.36502838,41.39315414),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hempfield Elementary School",'Greenville=' + Greenville.length);
Hermitage[Hermitage.length] = createMarker(new GPoint(-80.44988251,41.23566437),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hermitage Elementary School",'Hermitage=' + Hermitage.length);
Hermitage[Hermitage.length] = createMarker(new GPoint(-80.44988251,41.23475647),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Hermitage Middle School",'Hermitage=' + Hermitage.length);
Hermitage[Hermitage.length] = createMarker(new GPoint(-80.44971466,41.24166489),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hickory High School",'Hermitage=' + Hermitage.length);
Grove_City[Grove_City.length] = createMarker(new GPoint(-80.09842682,41.16131592),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Highland Elementary School",'Grove_City=' + Grove_City.length);
Grove_City[Grove_City.length] = createMarker(new GPoint(-80.07589722,41.15134811),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hillview Elementary School",'Grove_City=' + Grove_City.length);
Jamestown[Jamestown.length] = createMarker(new GPoint(-80.47070312,41.52259827),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jamestown Area Junior Senior High School",'Jamestown=' + Jamestown.length);
Greenville[Greenville.length] = createMarker(new GPoint(-80.44744873,41.39899445),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Keystone Education Center Charter School",'Greenville=' + Greenville.length);
Stoneboro[Stoneboro.length] = createMarker(new GPoint(-80.09007263,41.34052277),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lakeview High School",'Stoneboro=' + Stoneboro.length);
Stoneboro[Stoneboro.length] = createMarker(new GPoint(-80.09007263,41.34052277),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Lakeview Middle School",'Stoneboro=' + Stoneboro.length);
West_Middlesex[West_Middlesex.length] = createMarker(new GPoint(-80.45166016,41.17223358),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Luther W Low Elementary School",'West_Middlesex=' + West_Middlesex.length);
Mercer[Mercer.length] = createMarker(new GPoint(-80.24440002,41.22986221),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mercer Area Elementary School",'Mercer=' + Mercer.length);
Mercer[Mercer.length] = createMarker(new GPoint(-80.24644470,41.22516632),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mercer Area Junior Senior High School",'Mercer=' + Mercer.length);
Mercer[Mercer.length] = createMarker(new GPoint(-80.24631400,41.22529900),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mercer Area MiddleSchool",'Mercer=' + Mercer.length);
Mercer[Mercer.length] = createMarker(new GPoint(-80.25046539,41.25089645),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mercer County Career Center",'Mercer=' + Mercer.length);
Grove_City[Grove_City.length] = createMarker(new GPoint(-80.07951355,41.15103912),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Midwestern Regional Virtual Charter School",'Grove_City=' + Grove_City.length);
Sharon[Sharon.length] = createMarker(new GPoint(-80.49728394,41.22486115),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Musser Elementary School",'Sharon=' + Sharon.length);
Stoneboro[Stoneboro.length] = createMarker(new GPoint(-80.08425140,41.33943558),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Oakview Elementary School",'Stoneboro=' + Stoneboro.length);
West_Middlesex[West_Middlesex.length] = createMarker(new GPoint(-80.45166016,41.17223358),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Oakview Elementary School",'West_Middlesex=' + West_Middlesex.length);
Greenville[Greenville.length] = createMarker(new GPoint(-80.39651489,41.33813858),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Reynolds Elementary School",'Greenville=' + Greenville.length);
Greenville[Greenville.length] = createMarker(new GPoint(-80.39788818,41.34800720),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Reynolds Junior Senior High School",'Greenville=' + Greenville.length);
Sharon[Sharon.length] = createMarker(new GPoint(-80.48831940,41.23323822),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sharon Middle School High School",'Sharon=' + Sharon.length);
Sharpsville[Sharpsville.length] = createMarker(new GPoint(-80.47861481,41.25686264),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sharpsville Area Elementary School",'Sharpsville=' + Sharpsville.length);
Sharpsville[Sharpsville.length] = createMarker(new GPoint(-80.47653198,41.25526428),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Sharpsville Area Middle School",'Sharpsville=' + Sharpsville.length);
Sharpsville[Sharpsville.length] = createMarker(new GPoint(-80.47647858,41.25526428),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sharpsville Area Senior High School",'Sharpsville=' + Sharpsville.length);
Grove_City[Grove_City.length] = createMarker(new GPoint(-80.07626343,41.16245651),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Washington Kdg Center",'Grove_City=' + Grove_City.length);
Sharon[Sharon.length] = createMarker(new GPoint(-80.51478577,41.23586273),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("West Hill Elementary School",'Sharon=' + Sharon.length);
West_Middlesex[West_Middlesex.length] = createMarker(new GPoint(-80.45166016,41.17223358),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West Middlesex Junior Senior High School",'West_Middlesex=' + West_Middlesex.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(Farrell);
map.removeOverlays(Greenville);
map.removeOverlays(Grove_City);
map.removeOverlays(Hadley);
map.removeOverlays(Hermitage);
map.removeOverlays(Jamestown);
map.removeOverlays(Mercer);
map.removeOverlays(Sharon);
map.removeOverlays(Sharpsville);
map.removeOverlays(Stoneboro);
map.removeOverlays(West_Middlesex);
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(Mercer);map.removeOverlays(Farrell);
map.removeOverlays(Greenville);
map.removeOverlays(Grove_City);
map.removeOverlays(Hadley);
map.removeOverlays(Hermitage);
map.removeOverlays(Jamestown);
map.removeOverlays(Mercer);
map.removeOverlays(Sharon);
map.removeOverlays(Sharpsville);
map.removeOverlays(Stoneboro);
map.removeOverlays(West_Middlesex);
map.addOverlays(Farrell);
centerByArray(Farrell, false, false);
cntMarker += Farrell.length;
map.addOverlays(Greenville);
centerByArray(Greenville, false, false);
cntMarker += Greenville.length;
map.addOverlays(Grove_City);
centerByArray(Grove_City, false, false);
cntMarker += Grove_City.length;
map.addOverlays(Hadley);
centerByArray(Hadley, false, false);
cntMarker += Hadley.length;
map.addOverlays(Hermitage);
centerByArray(Hermitage, false, false);
cntMarker += Hermitage.length;
map.addOverlays(Jamestown);
centerByArray(Jamestown, false, false);
cntMarker += Jamestown.length;
map.addOverlays(Mercer);
centerByArray(Mercer, false, false);
cntMarker += Mercer.length;
map.addOverlays(Sharon);
centerByArray(Sharon, false, false);
cntMarker += Sharon.length;
map.addOverlays(Sharpsville);
centerByArray(Sharpsville, false, false);
cntMarker += Sharpsville.length;
map.addOverlays(Stoneboro);
centerByArray(Stoneboro, false, false);
cntMarker += Stoneboro.length;
map.addOverlays(West_Middlesex);
centerByArray(West_Middlesex, false, false);
cntMarker += West_Middlesex.length;
centerByArray(Mercer,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');
}
}