function addMarkers(){
mySelect = document.getElementById('selection');
South_Mountain = [];Shippensburg = [];Greencastle = [];Willow_Hill = [];Chambersburg = [];Fayetteville = [];Blue_Ridge_Summit = [];Dry_Run = [];Orrstown = [];Mercersburg = [];Spring_Run = [];Newburg = [];Waynesboro = [];Doylesburg = [];mySelect.options[mySelect.options.length] = new Option("Blue Ridge Summit schools",'all=Blue_Ridge_Summit');
mySelect.options[mySelect.options.length] = new Option("Chambersburg schools",'all=Chambersburg');
mySelect.options[mySelect.options.length] = new Option("Doylesburg schools",'all=Doylesburg');
mySelect.options[mySelect.options.length] = new Option("Dry Run schools",'all=Dry_Run');
mySelect.options[mySelect.options.length] = new Option("Fayetteville schools",'all=Fayetteville');
mySelect.options[mySelect.options.length] = new Option("Greencastle schools",'all=Greencastle');
mySelect.options[mySelect.options.length] = new Option("Mercersburg schools",'all=Mercersburg');
mySelect.options[mySelect.options.length] = new Option("Newburg schools",'all=Newburg');
mySelect.options[mySelect.options.length] = new Option("Orrstown schools",'all=Orrstown');
mySelect.options[mySelect.options.length] = new Option("Shippensburg schools",'all=Shippensburg');
mySelect.options[mySelect.options.length] = new Option("South Mountain schools",'all=South_Mountain');
mySelect.options[mySelect.options.length] = new Option("Spring Run schools",'all=Spring_Run');
mySelect.options[mySelect.options.length] = new Option("Waynesboro schools",'all=Waynesboro');
mySelect.options[mySelect.options.length] = new Option("Willow Hill schools",'all=Willow_Hill');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
South_Mountain[South_Mountain.length] = createMarker(new GPoint(-77.48800000,39.84630000),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Abraxas Leadership",'South_Mountain=' + South_Mountain.length);
Shippensburg[Shippensburg.length] = createMarker(new GPoint(-77.58684900,40.03389900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Anchor Christian School",'Shippensburg=' + Shippensburg.length);
Greencastle[Greencastle.length] = createMarker(new GPoint(-77.70207700,39.81266500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Antrim Mennonite School",'Greencastle=' + Greencastle.length);
Shippensburg[Shippensburg.length] = createMarker(new GPoint(-77.56793500,40.03763700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Clearfield Parochial School",'Shippensburg=' + Shippensburg.length);
Willow_Hill[Willow_Hill.length] = createMarker(new GPoint(-77.77986200,40.12181900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Conococheague Creek School",'Willow_Hill=' + Willow_Hill.length);
Chambersburg[Chambersburg.length] = createMarker(new GPoint(-77.65844000,39.94158300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Corpus Christi School",'Chambersburg=' + Chambersburg.length);
Chambersburg[Chambersburg.length] = createMarker(new GPoint(-77.62531800,40.00451000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Culbertson Christian Day School",'Chambersburg=' + Chambersburg.length);
Chambersburg[Chambersburg.length] = createMarker(new GPoint(-77.67157400,39.94290200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cumberland Valley Christian School",'Chambersburg=' + Chambersburg.length);
Chambersburg[Chambersburg.length] = createMarker(new GPoint(-77.79867100,39.95982500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Emmanuel Christian School",'Chambersburg=' + Chambersburg.length);
Fayetteville[Fayetteville.length] = createMarker(new GPoint(-77.53889600,39.91711200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Valley Christian School",'Fayetteville=' + Fayetteville.length);
Blue_Ridge_Summit[Blue_Ridge_Summit.length] = createMarker(new GPoint(-77.47543100,39.72057600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Highfield Christian Academy",'Blue_Ridge_Summit=' + Blue_Ridge_Summit.length);
Chambersburg[Chambersburg.length] = createMarker(new GPoint(-77.64682100,39.92092900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Magic Years Childcare And Learning Center",'Chambersburg=' + Chambersburg.length);
Dry_Run[Dry_Run.length] = createMarker(new GPoint(-77.72028800,40.19375100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Maple Grove School",'Dry_Run=' + Dry_Run.length);
Orrstown[Orrstown.length] = createMarker(new GPoint(-77.58674000,40.12938000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mcclays Mill Amish School",'Orrstown=' + Orrstown.length);
Mercersburg[Mercersburg.length] = createMarker(new GPoint(-77.89995500,39.82817600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mercersburg Academy",'Mercersburg=' + Mercersburg.length);
Chambersburg[Chambersburg.length] = createMarker(new GPoint(-77.59075100,39.93544100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Academy Of Chambersburg",'Chambersburg=' + Chambersburg.length);
Spring_Run[Spring_Run.length] = createMarker(new GPoint(-77.76724800,40.15156600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mountain View Amish School",'Spring_Run=' + Spring_Run.length);
Newburg[Newburg.length] = createMarker(new GPoint(-77.58375900,40.11154100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mowersville Christian Academy",'Newburg=' + Newburg.length);
Shippensburg[Shippensburg.length] = createMarker(new GPoint(-77.55461200,40.01372100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mt Rock Parochial School",'Shippensburg=' + Shippensburg.length);
Mercersburg[Mercersburg.length] = createMarker(new GPoint(-77.93220300,39.79622000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Life Christian Academy",'Mercersburg=' + Mercersburg.length);
Waynesboro[Waynesboro.length] = createMarker(new GPoint(-77.57934800,39.75416400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Noahs Ark Christian Child Care Center",'Waynesboro=' + Waynesboro.length);
Doylesburg[Doylesburg.length] = createMarker(new GPoint(-77.73232200,40.22115300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Path Valley Christian School",'Doylesburg=' + Doylesburg.length);
Waynesboro[Waynesboro.length] = createMarker(new GPoint(-77.57387000,39.75354900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Andrew School",'Waynesboro=' + Waynesboro.length);
Greencastle[Greencastle.length] = createMarker(new GPoint(-77.68215300,39.78056300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Shady Grove Mennonite School",'Greencastle=' + Greencastle.length);
Chambersburg[Chambersburg.length] = createMarker(new GPoint(-77.69032800,39.87412200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Shalom Christian Academy",'Chambersburg=' + Chambersburg.length);
Orrstown[Orrstown.length] = createMarker(new GPoint(-77.62491500,40.05832800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Stoney Creek School",'Orrstown=' + Orrstown.length);
Doylesburg[Doylesburg.length] = createMarker(new GPoint(-77.75090400,40.17839800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sunny-meadow Amish School",'Doylesburg=' + Doylesburg.length);
Dry_Run[Dry_Run.length] = createMarker(new GPoint(-77.71927200,40.19506600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sweetwater Ridge School",'Dry_Run=' + Dry_Run.length);
South_Mountain[South_Mountain.length] = createMarker(new GPoint(-77.48800000,39.84630000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Vision Quest S Mountain Lodge",'South_Mountain=' + South_Mountain.length);
Spring_Run[Spring_Run.length] = createMarker(new GPoint(-77.76067900,40.12326600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Willow Hill Parochial School",'Spring_Run=' + Spring_Run.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(Blue_Ridge_Summit);
map.removeOverlays(Chambersburg);
map.removeOverlays(Doylesburg);
map.removeOverlays(Dry_Run);
map.removeOverlays(Fayetteville);
map.removeOverlays(Greencastle);
map.removeOverlays(Mercersburg);
map.removeOverlays(Newburg);
map.removeOverlays(Orrstown);
map.removeOverlays(Shippensburg);
map.removeOverlays(South_Mountain);
map.removeOverlays(Spring_Run);
map.removeOverlays(Waynesboro);
map.removeOverlays(Willow_Hill);
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(South_Mountain);map.removeOverlays(Blue_Ridge_Summit);
map.removeOverlays(Chambersburg);
map.removeOverlays(Doylesburg);
map.removeOverlays(Dry_Run);
map.removeOverlays(Fayetteville);
map.removeOverlays(Greencastle);
map.removeOverlays(Mercersburg);
map.removeOverlays(Newburg);
map.removeOverlays(Orrstown);
map.removeOverlays(Shippensburg);
map.removeOverlays(South_Mountain);
map.removeOverlays(Spring_Run);
map.removeOverlays(Waynesboro);
map.removeOverlays(Willow_Hill);
map.addOverlays(Blue_Ridge_Summit);
centerByArray(Blue_Ridge_Summit, false, false);
cntMarker += Blue_Ridge_Summit.length;
map.addOverlays(Chambersburg);
centerByArray(Chambersburg, false, false);
cntMarker += Chambersburg.length;
map.addOverlays(Doylesburg);
centerByArray(Doylesburg, false, false);
cntMarker += Doylesburg.length;
map.addOverlays(Dry_Run);
centerByArray(Dry_Run, false, false);
cntMarker += Dry_Run.length;
map.addOverlays(Fayetteville);
centerByArray(Fayetteville, false, false);
cntMarker += Fayetteville.length;
map.addOverlays(Greencastle);
centerByArray(Greencastle, false, false);
cntMarker += Greencastle.length;
map.addOverlays(Mercersburg);
centerByArray(Mercersburg, false, false);
cntMarker += Mercersburg.length;
map.addOverlays(Newburg);
centerByArray(Newburg, false, false);
cntMarker += Newburg.length;
map.addOverlays(Orrstown);
centerByArray(Orrstown, false, false);
cntMarker += Orrstown.length;
map.addOverlays(Shippensburg);
centerByArray(Shippensburg, false, false);
cntMarker += Shippensburg.length;
map.addOverlays(South_Mountain);
centerByArray(South_Mountain, false, false);
cntMarker += South_Mountain.length;
map.addOverlays(Spring_Run);
centerByArray(Spring_Run, false, false);
cntMarker += Spring_Run.length;
map.addOverlays(Waynesboro);
centerByArray(Waynesboro, false, false);
cntMarker += Waynesboro.length;
map.addOverlays(Willow_Hill);
centerByArray(Willow_Hill, false, false);
cntMarker += Willow_Hill.length;
centerByArray(South_Mountain,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;
}