function addMarkers(){
mySelect = document.getElementById('selection');
Bala_Cynwyd = [];Elkins_Park = [];New_Bloomfield = [];Fairless_Hills = [];Spring_City = [];Tannersville = [];Pittsburgh = [];Broomall = [];Jenkintown = [];Aston = [];Media = [];Upper_Saint_Clair = [];State_College = [];Mount_Lebanon = [];Penn_Wynne = [];Collingdale = [];Phoenixville = [];Limerick = [];Malvern = [];mySelect.options[mySelect.options.length] = new Option("Aston schools",'all=Aston');
mySelect.options[mySelect.options.length] = new Option("Bala Cynwyd schools",'all=Bala_Cynwyd');
mySelect.options[mySelect.options.length] = new Option("Broomall schools",'all=Broomall');
mySelect.options[mySelect.options.length] = new Option("Collingdale schools",'all=Collingdale');
mySelect.options[mySelect.options.length] = new Option("Elkins Park schools",'all=Elkins_Park');
mySelect.options[mySelect.options.length] = new Option("Fairless Hills schools",'all=Fairless_Hills');
mySelect.options[mySelect.options.length] = new Option("Jenkintown schools",'all=Jenkintown');
mySelect.options[mySelect.options.length] = new Option("Limerick schools",'all=Limerick');
mySelect.options[mySelect.options.length] = new Option("Malvern schools",'all=Malvern');
mySelect.options[mySelect.options.length] = new Option("Media schools",'all=Media');
mySelect.options[mySelect.options.length] = new Option("Mount Lebanon schools",'all=Mount_Lebanon');
mySelect.options[mySelect.options.length] = new Option("New Bloomfield schools",'all=New_Bloomfield');
mySelect.options[mySelect.options.length] = new Option("Penn Wynne schools",'all=Penn_Wynne');
mySelect.options[mySelect.options.length] = new Option("Phoenixville schools",'all=Phoenixville');
mySelect.options[mySelect.options.length] = new Option("Pittsburgh schools",'all=Pittsburgh');
mySelect.options[mySelect.options.length] = new Option("Spring City schools",'all=Spring_City');
mySelect.options[mySelect.options.length] = new Option("State College schools",'all=State_College');
mySelect.options[mySelect.options.length] = new Option("Tannersville schools",'all=Tannersville');
mySelect.options[mySelect.options.length] = new Option("Upper Saint Clair schools",'all=Upper_Saint_Clair');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Bala_Cynwyd[Bala_Cynwyd.length] = createMarker(new GPoint(-75.23100000,40.01330000),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Bala House Montessori",'Bala_Cynwyd=' + Bala_Cynwyd.length);
Elkins_Park[Elkins_Park.length] = createMarker(new GPoint(-75.12775400,40.08460700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bayt Yeladeem: Childrens House",'Elkins_Park=' + Elkins_Park.length);
New_Bloomfield[New_Bloomfield.length] = createMarker(new GPoint(-77.18870500,40.42230500),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Carson Long Military Institute",'New_Bloomfield=' + New_Bloomfield.length);
Fairless_Hills[Fairless_Hills.length] = createMarker(new GPoint(-74.83680600,40.18451900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Children's House Of Bucks County",'Fairless_Hills=' + Fairless_Hills.length);
Spring_City[Spring_City.length] = createMarker(new GPoint(-75.61016300,40.17919400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Collegeville Montessori",'Spring_City=' + Spring_City.length);
Tannersville[Tannersville.length] = createMarker(new GPoint(-75.32420000,41.04940000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Growing Concern School",'Tannersville=' + Tannersville.length);
Pittsburgh[Pittsburgh.length] = createMarker(new GPoint(-79.72012400,40.47588100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Happy Holiday Childrens Ctr/plum Borough Kdgn",'Pittsburgh=' + Pittsburgh.length);
Pittsburgh[Pittsburgh.length] = createMarker(new GPoint(-79.72012400,40.47588100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holiday Farms Country Day School",'Pittsburgh=' + Pittsburgh.length);
Broomall[Broomall.length] = createMarker(new GPoint(-75.36208300,39.97228900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lane Good Council Mont School",'Broomall=' + Broomall.length);
Jenkintown[Jenkintown.length] = createMarker(new GPoint(-75.11583600,40.09480700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Meadowlane Montessori School",'Jenkintown=' + Jenkintown.length);
Aston[Aston.length] = createMarker(new GPoint(-75.42217600,39.86689200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Media Childrens House",'Aston=' + Aston.length);
Media[Media.length] = createMarker(new GPoint(-75.42339200,39.91318100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Middletown Montessori School",'Media=' + Media.length);
Upper_Saint_Clair[Upper_Saint_Clair.length] = createMarker(new GPoint(-80.08274600,40.32355400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Early Childhood Center",'Upper_Saint_Clair=' + Upper_Saint_Clair.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);
Mount_Lebanon[Mount_Lebanon.length] = createMarker(new GPoint(-80.02384600,40.37631000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mount Lebanon Montessori",'Mount_Lebanon=' + Mount_Lebanon.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);
Penn_Wynne[Penn_Wynne.length] = createMarker(new GPoint(-75.28300000,39.98540000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Penn Wynne Children's House",'Penn_Wynne=' + Penn_Wynne.length);
Collingdale[Collingdale.length] = createMarker(new GPoint(-75.28005400,39.91649500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ted Di Renzo Montessori School",'Collingdale=' + Collingdale.length);
Phoenixville[Phoenixville.length] = createMarker(new GPoint(-75.51451900,40.12131900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Vfkh Montessori School",'Phoenixville=' + Phoenixville.length);
Limerick[Limerick.length] = createMarker(new GPoint(-75.51354100,40.22340600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Vfkh Montessori School",'Limerick=' + Limerick.length);
Malvern[Malvern.length] = createMarker(new GPoint(-75.52415700,40.01800500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Willistown Country Day School",'Malvern=' + Malvern.length);
map.removeOverlays(Aston);
map.removeOverlays(Bala_Cynwyd);
map.removeOverlays(Broomall);
map.removeOverlays(Collingdale);
map.removeOverlays(Elkins_Park);
map.removeOverlays(Fairless_Hills);
map.removeOverlays(Jenkintown);
map.removeOverlays(Limerick);
map.removeOverlays(Malvern);
map.removeOverlays(Media);
map.removeOverlays(Mount_Lebanon);
map.removeOverlays(New_Bloomfield);
map.removeOverlays(Penn_Wynne);
map.removeOverlays(Phoenixville);
map.removeOverlays(Pittsburgh);
map.removeOverlays(Spring_City);
map.removeOverlays(State_College);
map.removeOverlays(Tannersville);
map.removeOverlays(Upper_Saint_Clair);
setTimeout(function(){map.addOverlays(Aston)},1000);
setTimeout(function(){map.addOverlays(Bala_Cynwyd)},1000);
setTimeout(function(){map.addOverlays(Broomall)},1000);
setTimeout(function(){map.addOverlays(Collingdale)},1000);
setTimeout(function(){map.addOverlays(Elkins_Park)},1000);
setTimeout(function(){map.addOverlays(Fairless_Hills)},1000);
setTimeout(function(){map.addOverlays(Jenkintown)},1000);
setTimeout(function(){map.addOverlays(Limerick)},1000);
setTimeout(function(){map.addOverlays(Malvern)},1000);
setTimeout(function(){map.addOverlays(Media)},1000);
setTimeout(function(){map.addOverlays(Mount_Lebanon)},1000);
setTimeout(function(){map.addOverlays(New_Bloomfield)},1000);
setTimeout(function(){map.addOverlays(Penn_Wynne)},1000);
setTimeout(function(){map.addOverlays(Phoenixville)},1000);
setTimeout(function(){map.addOverlays(Pittsburgh)},1000);
setTimeout(function(){map.addOverlays(Spring_City)},1000);
setTimeout(function(){map.addOverlays(State_College)},1000);
setTimeout(function(){map.addOverlays(Tannersville)},1000);
setTimeout(function(){map.addOverlays(Upper_Saint_Clair)},1000);
maxLng = -74.83680600;
maxLat = 41.04940000;
minLng = -80.08274600;
minLat = 39.86689200;
reCenterMap();
} // 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//////' + showArray);
map.removeOverlays(Aston);
map.removeOverlays(Bala_Cynwyd);
map.removeOverlays(Broomall);
map.removeOverlays(Collingdale);
map.removeOverlays(Elkins_Park);
map.removeOverlays(Fairless_Hills);
map.removeOverlays(Jenkintown);
map.removeOverlays(Limerick);
map.removeOverlays(Malvern);
map.removeOverlays(Media);
map.removeOverlays(Mount_Lebanon);
map.removeOverlays(New_Bloomfield);
map.removeOverlays(Penn_Wynne);
map.removeOverlays(Phoenixville);
map.removeOverlays(Pittsburgh);
map.removeOverlays(Spring_City);
map.removeOverlays(State_College);
map.removeOverlays(Tannersville);
map.removeOverlays(Upper_Saint_Clair);
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(Bala_Cynwyd);map.removeOverlays(Aston);
map.removeOverlays(Bala_Cynwyd);
map.removeOverlays(Broomall);
map.removeOverlays(Collingdale);
map.removeOverlays(Elkins_Park);
map.removeOverlays(Fairless_Hills);
map.removeOverlays(Jenkintown);
map.removeOverlays(Limerick);
map.removeOverlays(Malvern);
map.removeOverlays(Media);
map.removeOverlays(Mount_Lebanon);
map.removeOverlays(New_Bloomfield);
map.removeOverlays(Penn_Wynne);
map.removeOverlays(Phoenixville);
map.removeOverlays(Pittsburgh);
map.removeOverlays(Spring_City);
map.removeOverlays(State_College);
map.removeOverlays(Tannersville);
map.removeOverlays(Upper_Saint_Clair);
map.addOverlays(Aston);
centerByArray(Aston, false, false);
cntMarker += Aston.length;
map.addOverlays(Bala_Cynwyd);
centerByArray(Bala_Cynwyd, false, false);
cntMarker += Bala_Cynwyd.length;
map.addOverlays(Broomall);
centerByArray(Broomall, false, false);
cntMarker += Broomall.length;
map.addOverlays(Collingdale);
centerByArray(Collingdale, false, false);
cntMarker += Collingdale.length;
map.addOverlays(Elkins_Park);
centerByArray(Elkins_Park, false, false);
cntMarker += Elkins_Park.length;
map.addOverlays(Fairless_Hills);
centerByArray(Fairless_Hills, false, false);
cntMarker += Fairless_Hills.length;
map.addOverlays(Jenkintown);
centerByArray(Jenkintown, false, false);
cntMarker += Jenkintown.length;
map.addOverlays(Limerick);
centerByArray(Limerick, false, false);
cntMarker += Limerick.length;
map.addOverlays(Malvern);
centerByArray(Malvern, false, false);
cntMarker += Malvern.length;
map.addOverlays(Media);
centerByArray(Media, false, false);
cntMarker += Media.length;
map.addOverlays(Mount_Lebanon);
centerByArray(Mount_Lebanon, false, false);
cntMarker += Mount_Lebanon.length;
map.addOverlays(New_Bloomfield);
centerByArray(New_Bloomfield, false, false);
cntMarker += New_Bloomfield.length;
map.addOverlays(Penn_Wynne);
centerByArray(Penn_Wynne, false, false);
cntMarker += Penn_Wynne.length;
map.addOverlays(Phoenixville);
centerByArray(Phoenixville, false, false);
cntMarker += Phoenixville.length;
map.addOverlays(Pittsburgh);
centerByArray(Pittsburgh, false, false);
cntMarker += Pittsburgh.length;
map.addOverlays(Spring_City);
centerByArray(Spring_City, false, false);
cntMarker += Spring_City.length;
map.addOverlays(State_College);
centerByArray(State_College, false, false);
cntMarker += State_College.length;
map.addOverlays(Tannersville);
centerByArray(Tannersville, false, false);
cntMarker += Tannersville.length;
map.addOverlays(Upper_Saint_Clair);
centerByArray(Upper_Saint_Clair, false, false);
cntMarker += Upper_Saint_Clair.length;
centerByArray(Bala_Cynwyd,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///23221,24085,23067,34799,25006,34800,23285,24066,25110,25193,24107,24157,23221,24335,34801,35229,34798,23349,24141,24328,23645,24136,/all');
//window.open('/map.php?type=2&schools=23221,24085,23067,34799,25006,34800,23285,24066,25110,25193,24107,24157,23221,24335,34801,35229,34798,23349,24141,24328,23645,24136,&school_level=&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;
}