function addMarkers(){
mySelect = document.getElementById('selection');
Bangor = [];Bethlehem = [];Easton = [];Roseto = [];Nazareth = [];Pen_Argyl = [];Northampton = [];Bath = [];Hellertown = [];mySelect.options[mySelect.options.length] = new Option("Bangor schools",'all=Bangor');
mySelect.options[mySelect.options.length] = new Option("Bath schools",'all=Bath');
mySelect.options[mySelect.options.length] = new Option("Bethlehem schools",'all=Bethlehem');
mySelect.options[mySelect.options.length] = new Option("Easton schools",'all=Easton');
mySelect.options[mySelect.options.length] = new Option("Hellertown schools",'all=Hellertown');
mySelect.options[mySelect.options.length] = new Option("Nazareth schools",'all=Nazareth');
mySelect.options[mySelect.options.length] = new Option("Northampton schools",'all=Northampton');
mySelect.options[mySelect.options.length] = new Option("Pen Argyl schools",'all=Pen_Argyl');
mySelect.options[mySelect.options.length] = new Option("Roseto schools",'all=Roseto');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Bangor[Bangor.length] = createMarker(new GPoint(-75.20967000,40.86472200),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bangor Preschool",'Bangor=' + Bangor.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.37144300,40.64139000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethlehem Catholic High School",'Bethlehem=' + Bethlehem.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.33211000,40.65989700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethlehem Christian School",'Bethlehem=' + Bethlehem.length);
Easton[Easton.length] = createMarker(new GPoint(-75.25354200,40.68572800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Children's Garden Early Education Center",'Easton=' + Easton.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.35793700,40.61120700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Concordia Lutheran Church & School",'Bethlehem=' + Bethlehem.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.38218000,40.67354000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Creative Kids Club",'Bethlehem=' + Bethlehem.length);
Easton[Easton.length] = createMarker(new GPoint(-75.26254100,40.68839700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Easton Baptist Academy",'Easton=' + Easton.length);
Easton[Easton.length] = createMarker(new GPoint(-75.22053700,40.68703700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Easton Catholic School",'Easton=' + Easton.length);
Roseto[Roseto.length] = createMarker(new GPoint(-75.21807300,40.87516700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Christian School",'Roseto=' + Roseto.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.37526800,40.61951200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gateway School of Lehigh Valley",'Bethlehem=' + Bethlehem.length);
Nazareth[Nazareth.length] = createMarker(new GPoint(-75.32071400,40.74277300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Family Elementary School",'Nazareth=' + Nazareth.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.37666200,40.61063700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Infancy School",'Bethlehem=' + Bethlehem.length);
Pen_Argyl[Pen_Argyl.length] = createMarker(new GPoint(-75.25690000,40.86955000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Immaculate Conception School",'Pen_Argyl=' + Pen_Argyl.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.37899500,40.62054300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Moravian Academy",'Bethlehem=' + Bethlehem.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.37907000,40.62054800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Moravian Academy Middle School",'Bethlehem=' + Bethlehem.length);
Easton[Easton.length] = createMarker(new GPoint(-75.30170400,40.66939200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Notre Dame High School",'Easton=' + Easton.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.41293400,40.64040400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Notre Dame Of Bethlehem School",'Bethlehem=' + Bethlehem.length);
Northampton[Northampton.length] = createMarker(new GPoint(-75.49265400,40.67973000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of Hungary Regional School",'Northampton=' + Northampton.length);
Roseto[Roseto.length] = createMarker(new GPoint(-75.21629800,40.87455900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of Mt Carmel School",'Roseto=' + Roseto.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.33773500,40.66098800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of Perpetual Help School",'Bethlehem=' + Bethlehem.length);
Bangor[Bangor.length] = createMarker(new GPoint(-75.21362400,40.87448100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pius X High School",'Bangor=' + Bangor.length);
Bath[Bath.length] = createMarker(new GPoint(-75.39061800,40.72576200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sacred Heart School",'Bath=' + Bath.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.33079300,40.64112900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sacred Heart School",'Bethlehem=' + Bethlehem.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.36755500,40.63449400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Anne School",'Bethlehem=' + Bethlehem.length);
Northampton[Northampton.length] = createMarker(new GPoint(-75.49369600,40.68119400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. John The Baptist",'Northampton=' + Northampton.length);
Hellertown[Hellertown.length] = createMarker(new GPoint(-75.33580000,40.58936300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Theresa School",'Hellertown=' + Hellertown.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.36958600,40.60834000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ss Cyril - Methodius School",'Bethlehem=' + Bethlehem.length);
Easton[Easton.length] = createMarker(new GPoint(-75.23876900,40.68575300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Jane Frances De Chantal School",'Easton=' + Easton.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.38252300,40.66889900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tot Time Child Development Center",'Bethlehem=' + Bethlehem.length);
Northampton[Northampton.length] = createMarker(new GPoint(-75.42395500,40.73833800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Valley View Baptist Academy",'Northampton=' + Northampton.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(Bangor);
map.removeOverlays(Bath);
map.removeOverlays(Bethlehem);
map.removeOverlays(Easton);
map.removeOverlays(Hellertown);
map.removeOverlays(Nazareth);
map.removeOverlays(Northampton);
map.removeOverlays(Pen_Argyl);
map.removeOverlays(Roseto);
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(Bangor);map.removeOverlays(Bangor);
map.removeOverlays(Bath);
map.removeOverlays(Bethlehem);
map.removeOverlays(Easton);
map.removeOverlays(Hellertown);
map.removeOverlays(Nazareth);
map.removeOverlays(Northampton);
map.removeOverlays(Pen_Argyl);
map.removeOverlays(Roseto);
map.addOverlays(Bangor);
centerByArray(Bangor, false, false);
cntMarker += Bangor.length;
map.addOverlays(Bath);
centerByArray(Bath, false, false);
cntMarker += Bath.length;
map.addOverlays(Bethlehem);
centerByArray(Bethlehem, false, false);
cntMarker += Bethlehem.length;
map.addOverlays(Easton);
centerByArray(Easton, false, false);
cntMarker += Easton.length;
map.addOverlays(Hellertown);
centerByArray(Hellertown, false, false);
cntMarker += Hellertown.length;
map.addOverlays(Nazareth);
centerByArray(Nazareth, false, false);
cntMarker += Nazareth.length;
map.addOverlays(Northampton);
centerByArray(Northampton, false, false);
cntMarker += Northampton.length;
map.addOverlays(Pen_Argyl);
centerByArray(Pen_Argyl, false, false);
cntMarker += Pen_Argyl.length;
map.addOverlays(Roseto);
centerByArray(Roseto, false, false);
cntMarker += Roseto.length;
centerByArray(Bangor,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;
}