function addMarkers(){
mySelect = document.getElementById('selection');
Downingtown = [];Glenmoore = [];Exton = [];Westtown = [];Malvern = [];Paoli = [];Devon = [];Honey_Brook = [];West_Chester = [];Kimberton = [];Coatesville = [];Chester_Springs = [];Berwyn = [];Kennett_Square = [];Pottstown = [];Strafford = [];mySelect.options[mySelect.options.length] = new Option("Berwyn schools",'all=Berwyn');
mySelect.options[mySelect.options.length] = new Option("Chester Springs schools",'all=Chester_Springs');
mySelect.options[mySelect.options.length] = new Option("Coatesville schools",'all=Coatesville');
mySelect.options[mySelect.options.length] = new Option("Devon schools",'all=Devon');
mySelect.options[mySelect.options.length] = new Option("Downingtown schools",'all=Downingtown');
mySelect.options[mySelect.options.length] = new Option("Exton schools",'all=Exton');
mySelect.options[mySelect.options.length] = new Option("Glenmoore schools",'all=Glenmoore');
mySelect.options[mySelect.options.length] = new Option("Honey Brook schools",'all=Honey_Brook');
mySelect.options[mySelect.options.length] = new Option("Kennett Square schools",'all=Kennett_Square');
mySelect.options[mySelect.options.length] = new Option("Kimberton schools",'all=Kimberton');
mySelect.options[mySelect.options.length] = new Option("Malvern schools",'all=Malvern');
mySelect.options[mySelect.options.length] = new Option("Paoli schools",'all=Paoli');
mySelect.options[mySelect.options.length] = new Option("Pottstown schools",'all=Pottstown');
mySelect.options[mySelect.options.length] = new Option("Strafford schools",'all=Strafford');
mySelect.options[mySelect.options.length] = new Option("West Chester schools",'all=West_Chester');
mySelect.options[mySelect.options.length] = new Option("Westtown schools",'all=Westtown');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Downingtown[Downingtown.length] = createMarker(new GPoint(-75.68563900,40.01007900),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bishop Shananan High School",'Downingtown=' + Downingtown.length);
Glenmoore[Glenmoore.length] = createMarker(new GPoint(-75.70939600,40.13744100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Camphill Special Schools Inc",'Glenmoore=' + Glenmoore.length);
Exton[Exton.length] = createMarker(new GPoint(-75.59486900,40.03192800),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("CFS, The School At Church Farm",'Exton=' + Exton.length);
Westtown[Westtown.length] = createMarker(new GPoint(-75.51049900,39.95044000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Concept School",'Westtown=' + Westtown.length);
Malvern[Malvern.length] = createMarker(new GPoint(-75.49476600,40.07256600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Crossroads School",'Malvern=' + Malvern.length);
Paoli[Paoli.length] = createMarker(new GPoint(-75.48191300,40.04458500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Delaware Valley Friends School",'Paoli=' + Paoli.length);
Downingtown[Downingtown.length] = createMarker(new GPoint(-75.68369000,40.00385700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Devereux Day School",'Downingtown=' + Downingtown.length);
Malvern[Malvern.length] = createMarker(new GPoint(-75.51428500,40.00815000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Devereux Mapleton High School",'Malvern=' + Malvern.length);
Devon[Devon.length] = createMarker(new GPoint(-75.42368600,40.05386500),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Devon Preparatory School",'Devon=' + Devon.length);
Honey_Brook[Honey_Brook.length] = createMarker(new GPoint(-75.88150000,40.07780000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gateway Baptist Academy",'Honey_Brook=' + Honey_Brook.length);
Honey_Brook[Honey_Brook.length] = createMarker(new GPoint(-75.90578600,40.11175300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Honeybrook Mennonite School",'Honey_Brook=' + Honey_Brook.length);
West_Chester[West_Chester.length] = createMarker(new GPoint(-75.60549100,40.00986200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kanner Learning Center",'West_Chester=' + West_Chester.length);
Kimberton[Kimberton.length] = createMarker(new GPoint(-75.57622900,40.12964600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kimberton Waldorf School",'Kimberton=' + Kimberton.length);
Coatesville[Coatesville.length] = createMarker(new GPoint(-75.86823900,39.98451500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lan-chester Christian School",'Coatesville=' + Coatesville.length);
Downingtown[Downingtown.length] = createMarker(new GPoint(-75.70816900,40.00552300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Landmark Christian School",'Downingtown=' + Downingtown.length);
Malvern[Malvern.length] = createMarker(new GPoint(-75.50950800,40.02888100),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Malvern Preparatory School",'Malvern=' + Malvern.length);
Chester_Springs[Chester_Springs.length] = createMarker(new GPoint(-75.62657800,40.09000400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montgomery School",'Chester_Springs=' + Chester_Springs.length);
Malvern[Malvern.length] = createMarker(new GPoint(-75.52170600,40.02320800),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("The Phelps School",'Malvern=' + Malvern.length);
Paoli[Paoli.length] = createMarker(new GPoint(-75.48250000,40.04230000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Royer-greaves School For Blind",'Paoli=' + Paoli.length);
Berwyn[Berwyn.length] = createMarker(new GPoint(-75.45134200,40.04564700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Timothy School",'Berwyn=' + Berwyn.length);
Glenmoore[Glenmoore.length] = createMarker(new GPoint(-75.72540000,40.10056100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Upattinas School",'Glenmoore=' + Glenmoore.length);
Kennett_Square[Kennett_Square.length] = createMarker(new GPoint(-75.76248000,39.86960400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Upland Country Day School",'Kennett_Square=' + Kennett_Square.length);
Paoli[Paoli.length] = createMarker(new GPoint(-75.48250000,40.04230000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Vanguard School",'Paoli=' + Paoli.length);
Malvern[Malvern.length] = createMarker(new GPoint(-75.50966500,40.03936300),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Villa Maria Academy High School",'Malvern=' + Malvern.length);
Coatesville[Coatesville.length] = createMarker(new GPoint(-75.73219800,39.94843100),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Vtston Quga",'Coatesville=' + Coatesville.length);
West_Chester[West_Chester.length] = createMarker(new GPoint(-75.57078900,39.98063100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West Chester Christian School",'West_Chester=' + West_Chester.length);
Pottstown[Pottstown.length] = createMarker(new GPoint(-75.65490100,40.23067900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West-Mont Christian Academy",'Pottstown=' + Pottstown.length);
West_Chester[West_Chester.length] = createMarker(new GPoint(-75.54397300,39.94937700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Westtown School",'West_Chester=' + West_Chester.length);
Strafford[Strafford.length] = createMarker(new GPoint(-75.40720500,40.05550100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Woodlynde School",'Strafford=' + Strafford.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/////2/' + showArray);
map.removeOverlays(Berwyn);
map.removeOverlays(Chester_Springs);
map.removeOverlays(Coatesville);
map.removeOverlays(Devon);
map.removeOverlays(Downingtown);
map.removeOverlays(Exton);
map.removeOverlays(Glenmoore);
map.removeOverlays(Honey_Brook);
map.removeOverlays(Kennett_Square);
map.removeOverlays(Kimberton);
map.removeOverlays(Malvern);
map.removeOverlays(Paoli);
map.removeOverlays(Pottstown);
map.removeOverlays(Strafford);
map.removeOverlays(West_Chester);
map.removeOverlays(Westtown);
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(Downingtown);map.removeOverlays(Berwyn);
map.removeOverlays(Chester_Springs);
map.removeOverlays(Coatesville);
map.removeOverlays(Devon);
map.removeOverlays(Downingtown);
map.removeOverlays(Exton);
map.removeOverlays(Glenmoore);
map.removeOverlays(Honey_Brook);
map.removeOverlays(Kennett_Square);
map.removeOverlays(Kimberton);
map.removeOverlays(Malvern);
map.removeOverlays(Paoli);
map.removeOverlays(Pottstown);
map.removeOverlays(Strafford);
map.removeOverlays(West_Chester);
map.removeOverlays(Westtown);
map.addOverlays(Berwyn);
centerByArray(Berwyn, false, false);
cntMarker += Berwyn.length;
map.addOverlays(Chester_Springs);
centerByArray(Chester_Springs, false, false);
cntMarker += Chester_Springs.length;
map.addOverlays(Coatesville);
centerByArray(Coatesville, false, false);
cntMarker += Coatesville.length;
map.addOverlays(Devon);
centerByArray(Devon, false, false);
cntMarker += Devon.length;
map.addOverlays(Downingtown);
centerByArray(Downingtown, false, false);
cntMarker += Downingtown.length;
map.addOverlays(Exton);
centerByArray(Exton, false, false);
cntMarker += Exton.length;
map.addOverlays(Glenmoore);
centerByArray(Glenmoore, false, false);
cntMarker += Glenmoore.length;
map.addOverlays(Honey_Brook);
centerByArray(Honey_Brook, false, false);
cntMarker += Honey_Brook.length;
map.addOverlays(Kennett_Square);
centerByArray(Kennett_Square, false, false);
cntMarker += Kennett_Square.length;
map.addOverlays(Kimberton);
centerByArray(Kimberton, false, false);
cntMarker += Kimberton.length;
map.addOverlays(Malvern);
centerByArray(Malvern, false, false);
cntMarker += Malvern.length;
map.addOverlays(Paoli);
centerByArray(Paoli, false, false);
cntMarker += Paoli.length;
map.addOverlays(Pottstown);
centerByArray(Pottstown, false, false);
cntMarker += Pottstown.length;
map.addOverlays(Strafford);
centerByArray(Strafford, false, false);
cntMarker += Strafford.length;
map.addOverlays(West_Chester);
centerByArray(West_Chester, false, false);
cntMarker += West_Chester.length;
map.addOverlays(Westtown);
centerByArray(Westtown, false, false);
cntMarker += Westtown.length;
centerByArray(Downingtown,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=2&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;
}