function addMarkers(){
mySelect = document.getElementById('selection');
University_Park = [];Woodward = [];Aaronsburg = [];Bellefonte = [];State_College = [];Madisonburg = [];Philipsburg = [];Howard = [];Rebersburg = [];Lemont = [];Spring_Mills = [];mySelect.options[mySelect.options.length] = new Option("Aaronsburg schools",'all=Aaronsburg');
mySelect.options[mySelect.options.length] = new Option("Bellefonte schools",'all=Bellefonte');
mySelect.options[mySelect.options.length] = new Option("Howard schools",'all=Howard');
mySelect.options[mySelect.options.length] = new Option("Lemont schools",'all=Lemont');
mySelect.options[mySelect.options.length] = new Option("Madisonburg schools",'all=Madisonburg');
mySelect.options[mySelect.options.length] = new Option("Philipsburg schools",'all=Philipsburg');
mySelect.options[mySelect.options.length] = new Option("Rebersburg schools",'all=Rebersburg');
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("University Park schools",'all=University_Park');
mySelect.options[mySelect.options.length] = new Option("Woodward schools",'all=Woodward');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
University_Park[University_Park.length] = createMarker(new GPoint(-77.86019800,40.80534300),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bennett Family Center",'University_Park=' + University_Park.length);
University_Park[University_Park.length] = createMarker(new GPoint(-77.86019800,40.80534300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bennett Family Child Care Center",'University_Park=' + University_Park.length);
Woodward[Woodward.length] = createMarker(new GPoint(-77.39330000,40.89110000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bower Hollow Parochial School",'Woodward=' + Woodward.length);
Aaronsburg[Aaronsburg.length] = createMarker(new GPoint(-77.42390000,40.90510000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bower Hollow School",'Aaronsburg=' + Aaronsburg.length);
Bellefonte[Bellefonte.length] = createMarker(new GPoint(-77.76882000,40.90751500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Centre County Christian Academy",'Bellefonte=' + Bellefonte.length);
State_College[State_College.length] = createMarker(new GPoint(-77.86683600,40.78836200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Children's House Montessori School",'State_College=' + State_College.length);
Madisonburg[Madisonburg.length] = createMarker(new GPoint(-77.50921200,40.93244600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Elk Creek School",'Madisonburg=' + Madisonburg.length);
Philipsburg[Philipsburg.length] = createMarker(new GPoint(-78.17518200,40.90117500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Christian Academy",'Philipsburg=' + Philipsburg.length);
State_College[State_College.length] = createMarker(new GPoint(-77.85550800,40.79673800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grace Lutheran Dayschool",'State_College=' + State_College.length);
State_College[State_College.length] = createMarker(new GPoint(-77.84587400,40.79133700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grace Prep",'State_College=' + State_College.length);
Howard[Howard.length] = createMarker(new GPoint(-77.58182800,40.98577300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hubler Ridge School",'Howard=' + Howard.length);
State_College[State_College.length] = createMarker(new GPoint(-77.88151300,40.76529000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Learning Station",'State_College=' + State_College.length);
Howard[Howard.length] = createMarker(new GPoint(-77.59337700,41.01341900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Little Nittany School",'Howard=' + Howard.length);
State_College[State_College.length] = createMarker(new GPoint(-77.90448800,40.79096300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Magic Years",'State_College=' + State_College.length);
State_College[State_College.length] = createMarker(new GPoint(-77.81716600,40.81790300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School Of The Ni",'State_College=' + State_College.length);
Rebersburg[Rebersburg.length] = createMarker(new GPoint(-121.84250000,47.53120000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mountain View School",'Rebersburg=' + Rebersburg.length);
Lemont[Lemont.length] = createMarker(new GPoint(-77.81860000,40.81050000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mt Nittany Preschool",'Lemont=' + Lemont.length);
State_College[State_College.length] = createMarker(new GPoint(-77.86427900,40.76783200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Nittany Christian School",'State_College=' + State_College.length);
State_College[State_College.length] = createMarker(new GPoint(-77.85952900,40.78938700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Children's Center",'State_College=' + State_College.length);
State_College[State_College.length] = createMarker(new GPoint(-77.86481500,40.78175600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of Victory Catholic School",'State_College=' + State_College.length);
State_College[State_College.length] = createMarker(new GPoint(-77.90421900,40.80731000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Park Forest Montessori School",'State_College=' + State_College.length);
Aaronsburg[Aaronsburg.length] = createMarker(new GPoint(-77.39852700,40.89987900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Penns Valley Amish Paroch School",'Aaronsburg=' + Aaronsburg.length);
Aaronsburg[Aaronsburg.length] = createMarker(new GPoint(-77.41960000,40.89350000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Penns Valley Amish Parochial School",'Aaronsburg=' + Aaronsburg.length);
State_College[State_College.length] = createMarker(new GPoint(-77.84958300,40.78935400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Red Satchel",'State_College=' + State_College.length);
Rebersburg[Rebersburg.length] = createMarker(new GPoint(-77.47784800,40.92630800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rockville School C/o Verna Beiler",'Rebersburg=' + Rebersburg.length);
Bellefonte[Bellefonte.length] = createMarker(new GPoint(-77.77698900,40.91074200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St John The Evangelist Catholic School",'Bellefonte=' + Bellefonte.length);
State_College[State_College.length] = createMarker(new GPoint(-77.84868000,40.79145700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("State College Children's House",'State_College=' + State_College.length);
State_College[State_College.length] = createMarker(new GPoint(-77.84133000,40.77881200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("State College Friends School",'State_College=' + State_College.length);
Bellefonte[Bellefonte.length] = createMarker(new GPoint(-75.74120000,40.51202000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sunny Meadow Parochial School",'Bellefonte=' + Bellefonte.length);
Bellefonte[Bellefonte.length] = createMarker(new GPoint(-77.64297500,40.98485200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sunset View School",'Bellefonte=' + Bellefonte.length);
Spring_Mills[Spring_Mills.length] = createMarker(new GPoint(-77.49435800,40.87297400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Woodside Amish School C/o Daniel King",'Spring_Mills=' + Spring_Mills.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,11);
/*
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/////3/' + showArray);
map.removeOverlays(Aaronsburg);
map.removeOverlays(Bellefonte);
map.removeOverlays(Howard);
map.removeOverlays(Lemont);
map.removeOverlays(Madisonburg);
map.removeOverlays(Philipsburg);
map.removeOverlays(Rebersburg);
map.removeOverlays(Spring_Mills);
map.removeOverlays(State_College);
map.removeOverlays(University_Park);
map.removeOverlays(Woodward);
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(University_Park);map.removeOverlays(Aaronsburg);
map.removeOverlays(Bellefonte);
map.removeOverlays(Howard);
map.removeOverlays(Lemont);
map.removeOverlays(Madisonburg);
map.removeOverlays(Philipsburg);
map.removeOverlays(Rebersburg);
map.removeOverlays(Spring_Mills);
map.removeOverlays(State_College);
map.removeOverlays(University_Park);
map.removeOverlays(Woodward);
map.addOverlays(Aaronsburg);
centerByArray(Aaronsburg, false, false);
cntMarker += Aaronsburg.length;
map.addOverlays(Bellefonte);
centerByArray(Bellefonte, false, false);
cntMarker += Bellefonte.length;
map.addOverlays(Howard);
centerByArray(Howard, false, false);
cntMarker += Howard.length;
map.addOverlays(Lemont);
centerByArray(Lemont, false, false);
cntMarker += Lemont.length;
map.addOverlays(Madisonburg);
centerByArray(Madisonburg, false, false);
cntMarker += Madisonburg.length;
map.addOverlays(Philipsburg);
centerByArray(Philipsburg, false, false);
cntMarker += Philipsburg.length;
map.addOverlays(Rebersburg);
centerByArray(Rebersburg, false, false);
cntMarker += Rebersburg.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(University_Park);
centerByArray(University_Park, false, false);
cntMarker += University_Park.length;
map.addOverlays(Woodward);
centerByArray(Woodward, false, false);
cntMarker += Woodward.length;
centerByArray(University_Park,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');
//window.open('/map.php?type=1&schools=&school_level=3&radius=&zipcode=&school_type_search=&school_type_code=');
}
}
function createMarker(point, label, icon)
{
var marker = new GMarker(point, icon);
var html = label;
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}