function addMarkers()
{
mySelect = document.getElementById('selection');
Wingate = [];Bellefonte = [];State_College = [];Pleasant_Gap = [];Centre_Hall = [];Pine_Grove_Mills = [];Port_Matilda = [];Spring_Mills = [];Howard = [];Blanchard = [];Rebersburg = [];Snow_Shoe = [];Philipsburg = [];mySelect.options[mySelect.options.length] = new Option("Bellefonte schools",'all=Bellefonte');
mySelect.options[mySelect.options.length] = new Option("Blanchard schools",'all=Blanchard');
mySelect.options[mySelect.options.length] = new Option("Centre Hall schools",'all=Centre_Hall');
mySelect.options[mySelect.options.length] = new Option("Howard schools",'all=Howard');
mySelect.options[mySelect.options.length] = new Option("Philipsburg schools",'all=Philipsburg');
mySelect.options[mySelect.options.length] = new Option("Pine Grove Mills schools",'all=Pine_Grove_Mills');
mySelect.options[mySelect.options.length] = new Option("Pleasant Gap schools",'all=Pleasant_Gap');
mySelect.options[mySelect.options.length] = new Option("Port Matilda schools",'all=Port_Matilda');
mySelect.options[mySelect.options.length] = new Option("Rebersburg schools",'all=Rebersburg');
mySelect.options[mySelect.options.length] = new Option("Snow Shoe schools",'all=Snow_Shoe');
mySelect.options[mySelect.options.length] = new Option("Spring Mills schools",'all=Spring_Mills');
mySelect.options[mySelect.options.length] = new Option("State College schools",'all=State_College');
mySelect.options[mySelect.options.length] = new Option("Wingate schools",'all=Wingate');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Wingate[Wingate.length] = createMarker(new GPoint(-77.81133270,40.93569183),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bald Eagle Area Junior Senior High School",'Wingate=' + Wingate.length);
Bellefonte[Bellefonte.length] = createMarker(new GPoint(-77.76392365,40.91344070),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bellefonte Area High School",'Bellefonte=' + Bellefonte.length);
Bellefonte[Bellefonte.length] = createMarker(new GPoint(-77.76168060,40.91389847),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bellefonte Area Middle School",'Bellefonte=' + Bellefonte.length);
Bellefonte[Bellefonte.length] = createMarker(new GPoint(-77.77941895,40.91563034),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bellefonte Elementary School",'Bellefonte=' + Bellefonte.length);
Bellefonte[Bellefonte.length] = createMarker(new GPoint(-77.81150818,40.89393616),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Benner Elementary School",'Bellefonte=' + Bellefonte.length);
State_College[State_College.length] = createMarker(new GPoint(-77.80871582,40.78605270),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Boalsburg/panorama Village Elementary School",'State_College=' + State_College.length);
Pleasant_Gap[Pleasant_Gap.length] = createMarker(new GPoint(-77.73718262,40.87977982),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central Pa Institute Of Scienc",'Pleasant_Gap=' + Pleasant_Gap.length);
Centre_Hall[Centre_Hall.length] = createMarker(new GPoint(-77.68808746,40.84646225),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Centre Hall-potter Elementary School",'Centre_Hall=' + Centre_Hall.length);
State_College[State_College.length] = createMarker(new GPoint(-77.88449860,40.76617813),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Centre Learning Community Charter School",'State_College=' + State_College.length);
State_College[State_College.length] = createMarker(new GPoint(-77.87272644,40.78247833),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Corl Street Elementary School",'State_College=' + State_College.length);
State_College[State_College.length] = createMarker(new GPoint(-77.84806824,40.78889847),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Easterly Parkway Elementary School",'State_College=' + State_College.length);
State_College[State_College.length] = createMarker(new GPoint(-77.85850525,40.79019928),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fairmount Avenue Elementary School",'State_College=' + State_College.length);
Pine_Grove_Mills[Pine_Grove_Mills.length] = createMarker(new GPoint(-77.76293900,41.90403000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ferguson Township Elementary School",'Pine_Grove_Mills=' + Pine_Grove_Mills.length);
Port_Matilda[Port_Matilda.length] = createMarker(new GPoint(-77.95900726,40.80123901),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Gray's Woods Elementary School",'Port_Matilda=' + Port_Matilda.length);
Spring_Mills[Spring_Mills.length] = createMarker(new GPoint(-77.49909210,40.87602234),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Gregg Township Elementary School",'Spring_Mills=' + Spring_Mills.length);
State_College[State_College.length] = createMarker(new GPoint(-77.82291412,40.81024170),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Houserville/lemont Elementary School",'State_College=' + State_College.length);
Howard[Howard.length] = createMarker(new GPoint(-77.66889954,41.01990128),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Howard Elementary School",'Howard=' + Howard.length);
Blanchard[Blanchard.length] = createMarker(new GPoint(-77.59880066,41.06499863),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Liberty Curtain Elementary School",'Blanchard=' + Blanchard.length);
Bellefonte[Bellefonte.length] = createMarker(new GPoint(-77.61122131,40.95853806),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Marion-walker Elementary School",'Bellefonte=' + Bellefonte.length);
Port_Matilda[Port_Matilda.length] = createMarker(new GPoint(-78.02079773,40.80519867),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Matternville Elementary School",'Port_Matilda=' + Port_Matilda.length);
Rebersburg[Rebersburg.length] = createMarker(new GPoint(-77.44339752,40.94581985),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Miles Township Elementary School",'Rebersburg=' + Rebersburg.length);
State_College[State_College.length] = createMarker(new GPoint(-77.80598450,40.78521347),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mount Nittany Middle School",'State_College=' + State_College.length);
Snow_Shoe[Snow_Shoe.length] = createMarker(new GPoint(-77.95330048,41.01959991),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mountaintop Area Elementary School",'Snow_Shoe=' + Snow_Shoe.length);
State_College[State_College.length] = createMarker(new GPoint(-77.90473938,40.78387833),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Nittany Valley Charter School",'State_College=' + State_College.length);
State_College[State_College.length] = createMarker(new GPoint(-77.92182922,40.80705643),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Park Forest Elementary School",'State_College=' + State_College.length);
State_College[State_College.length] = createMarker(new GPoint(-77.92216492,40.80694580),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Park Forest Middle School",'State_College=' + State_College.length);
Spring_Mills[Spring_Mills.length] = createMarker(new GPoint(-77.52936554,40.87622833),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Penns Valley Area Elementary School",'Spring_Mills=' + Spring_Mills.length);
Spring_Mills[Spring_Mills.length] = createMarker(new GPoint(-77.52825928,40.87691116),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Penns Valley Area Junior Senior High School",'Spring_Mills=' + Spring_Mills.length);
Philipsburg[Philipsburg.length] = createMarker(new GPoint(-78.21044922,40.89083862),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Philipsburg-osceola Area High School",'Philipsburg=' + Philipsburg.length);
Philipsburg[Philipsburg.length] = createMarker(new GPoint(-78.21814728,40.89859390),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Philipsburg-osceola Junior High School",'Philipsburg=' + Philipsburg.length);
Pleasant_Gap[Pleasant_Gap.length] = createMarker(new GPoint(-77.74023437,40.86647415),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pleasant Gap Elementary School",'Pleasant_Gap=' + Pleasant_Gap.length);
Port_Matilda[Port_Matilda.length] = createMarker(new GPoint(-78.02079773,40.80519867),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Port Matilda Elementary School",'Port_Matilda=' + Port_Matilda.length);
State_College[State_College.length] = createMarker(new GPoint(-77.88448334,40.80006027),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Radio Park Elementary School",'State_College=' + State_College.length);
State_College[State_College.length] = createMarker(new GPoint(-77.85831451,40.78253937),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("State College Area High School",'State_College=' + State_College.length);
Wingate[Wingate.length] = createMarker(new GPoint(-77.81133270,40.93569183),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wingate Elementary School",'Wingate=' + Wingate.length);
State_College[State_College.length] = createMarker(new GPoint(-77.88800800,40.80569600),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wonderland Charter School",'State_College=' + State_College.length);
State_College[State_College.length] = createMarker(new GPoint(-10.00000000,10.00000000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Young Scholars Of Central Pa C",'State_College=' + State_College.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(Bellefonte);
map.removeOverlays(Blanchard);
map.removeOverlays(Centre_Hall);
map.removeOverlays(Howard);
map.removeOverlays(Philipsburg);
map.removeOverlays(Pine_Grove_Mills);
map.removeOverlays(Pleasant_Gap);
map.removeOverlays(Port_Matilda);
map.removeOverlays(Rebersburg);
map.removeOverlays(Snow_Shoe);
map.removeOverlays(Spring_Mills);
map.removeOverlays(State_College);
map.removeOverlays(Wingate);
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(Wingate);map.removeOverlays(Bellefonte);
map.removeOverlays(Blanchard);
map.removeOverlays(Centre_Hall);
map.removeOverlays(Howard);
map.removeOverlays(Philipsburg);
map.removeOverlays(Pine_Grove_Mills);
map.removeOverlays(Pleasant_Gap);
map.removeOverlays(Port_Matilda);
map.removeOverlays(Rebersburg);
map.removeOverlays(Snow_Shoe);
map.removeOverlays(Spring_Mills);
map.removeOverlays(State_College);
map.removeOverlays(Wingate);
map.addOverlays(Bellefonte);
centerByArray(Bellefonte, false, false);
cntMarker += Bellefonte.length;
map.addOverlays(Blanchard);
centerByArray(Blanchard, false, false);
cntMarker += Blanchard.length;
map.addOverlays(Centre_Hall);
centerByArray(Centre_Hall, false, false);
cntMarker += Centre_Hall.length;
map.addOverlays(Howard);
centerByArray(Howard, false, false);
cntMarker += Howard.length;
map.addOverlays(Philipsburg);
centerByArray(Philipsburg, false, false);
cntMarker += Philipsburg.length;
map.addOverlays(Pine_Grove_Mills);
centerByArray(Pine_Grove_Mills, false, false);
cntMarker += Pine_Grove_Mills.length;
map.addOverlays(Pleasant_Gap);
centerByArray(Pleasant_Gap, false, false);
cntMarker += Pleasant_Gap.length;
map.addOverlays(Port_Matilda);
centerByArray(Port_Matilda, false, false);
cntMarker += Port_Matilda.length;
map.addOverlays(Rebersburg);
centerByArray(Rebersburg, false, false);
cntMarker += Rebersburg.length;
map.addOverlays(Snow_Shoe);
centerByArray(Snow_Shoe, false, false);
cntMarker += Snow_Shoe.length;
map.addOverlays(Spring_Mills);
centerByArray(Spring_Mills, false, false);
cntMarker += Spring_Mills.length;
map.addOverlays(State_College);
centerByArray(State_College, false, false);
cntMarker += State_College.length;
map.addOverlays(Wingate);
centerByArray(Wingate, false, false);
cntMarker += Wingate.length;
centerByArray(Wingate,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');
}
}