function addMarkers()
{
mySelect = document.getElementById('selection');
Bethlehem = [];Easton = [];Bangor = [];Nazareth = [];Northampton = [];Freemansburg = [];Bath = [];Walnutport = [];Pen_Argyl = [];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("Freemansburg schools",'all=Freemansburg');
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("Walnutport schools",'all=Walnutport');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.40996552,40.65586853),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Asa Packer Elementary School",'Bethlehem=' + Bethlehem.length);
Easton[Easton.length] = createMarker(new GPoint(-75.24078369,40.67359924),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Avona Elementary School",'Easton=' + Easton.length);
Bangor[Bangor.length] = createMarker(new GPoint(-75.15196991,40.88488388),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bangor Area High School",'Bangor=' + Bangor.length);
Bangor[Bangor.length] = createMarker(new GPoint(-75.20687103,40.86584854),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bangor Area Middle School",'Bangor=' + Bangor.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.33424377,40.66270065),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethlehem Avts",'Bethlehem=' + Bethlehem.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.38009644,40.60817337),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Broughal Middle School",'Bethlehem=' + Bethlehem.length);
Nazareth[Nazareth.length] = createMarker(new GPoint(-75.32402039,40.79252243),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bushkill Elementary School",'Nazareth=' + Nazareth.length);
Easton[Easton.length] = createMarker(new GPoint(-75.23641968,40.76403046),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Career Institute Of Technology",'Easton=' + Easton.length);
Northampton[Northampton.length] = createMarker(new GPoint(-75.46672821,40.65898514),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Catasauqua Senior High School",'Northampton=' + Northampton.length);
Easton[Easton.length] = createMarker(new GPoint(-75.21794891,40.67640686),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cheston Elementary School",'Easton=' + Easton.length);
Bangor[Bangor.length] = createMarker(new GPoint(-75.15190125,40.88162994),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Defranco Elementary School",'Bangor=' + Bangor.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.35919189,40.61111069),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Donegan Elementary School",'Bethlehem=' + Bethlehem.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.34277344,40.66243744),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("East Hills Middle School",'Bethlehem=' + Bethlehem.length);
Easton[Easton.length] = createMarker(new GPoint(-75.24961853,40.68161774),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Easton Area High School",'Easton=' + Easton.length);
Easton[Easton.length] = createMarker(new GPoint(-75.22706604,40.69053650),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Easton Area Middle School",'Easton=' + Easton.length);
Easton[Easton.length] = createMarker(new GPoint(-75.22084045,40.68833923),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Farmersville Elementary School",'Easton=' + Easton.length);
Bangor[Bangor.length] = createMarker(new GPoint(-75.15277863,40.87778854),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Five Points Elementary School",'Bangor=' + Bangor.length);
Easton[Easton.length] = createMarker(new GPoint(-75.21475983,40.71510315),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Forks Elementary School",'Easton=' + Easton.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.33998871,40.66228485),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Freedom High School",'Bethlehem=' + Bethlehem.length);
Freemansburg[Freemansburg.length] = createMarker(new GPoint(-75.33970642,40.62611771),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Freemansburg Elementary School",'Freemansburg=' + Freemansburg.length);
Bath[Bath.length] = createMarker(new GPoint(-75.38913727,40.72307968),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("George Wolf Elementary School",'Bath=' + Bath.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.34265137,40.65340805),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Governor Wolf Elementary School",'Bethlehem=' + Bethlehem.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.40128326,40.66900635),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hanover Elementary School",'Bethlehem=' + Bethlehem.length);
Walnutport[Walnutport.length] = createMarker(new GPoint(-75.53685760,40.76127243),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lehigh Township Elementary School",'Walnutport=' + Walnutport.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.37567139,40.65488052),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lehigh Valley Academy Regional",'Bethlehem=' + Bethlehem.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.37567139,40.65488052),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lehigh Valley Charter High School For Performing Arts",'Bethlehem=' + Bethlehem.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.37058258,40.62893295),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Liberty High School",'Bethlehem=' + Bethlehem.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.35642242,40.63801956),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Bethlehem=' + Bethlehem.length);
Nazareth[Nazareth.length] = createMarker(new GPoint(-75.33499146,40.70498657),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lower Nazareth Elementary School",'Nazareth=' + Nazareth.length);
Easton[Easton.length] = createMarker(new GPoint(-75.20430756,40.70247269),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("March Elementary School",'Easton=' + Easton.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.34394073,40.63346481),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Marvine Elementary School",'Bethlehem=' + Bethlehem.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.32763672,40.64776230),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Miller Heights Elementary School",'Bethlehem=' + Bethlehem.length);
Bath[Bath.length] = createMarker(new GPoint(-75.43048859,40.77833939),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Moore Township Elementary School",'Bath=' + Bath.length);
Nazareth[Nazareth.length] = createMarker(new GPoint(-75.30043030,40.74234009),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Nazareth Area High School",'Nazareth=' + Nazareth.length);
Nazareth[Nazareth.length] = createMarker(new GPoint(-75.28701019,40.73669815),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Nazareth Area Middle School",'Nazareth=' + Nazareth.length);
Northampton[Northampton.length] = createMarker(new GPoint(-75.49185181,40.68689346),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Northampton Area Junior High School",'Northampton=' + Northampton.length);
Northampton[Northampton.length] = createMarker(new GPoint(-75.49185944,40.68693542),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northampton Area Senior High School",'Northampton=' + Northampton.length);
Northampton[Northampton.length] = createMarker(new GPoint(-75.49448395,40.68701553),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Northampton Borough Elementary School",'Northampton=' + Northampton.length);
Northampton[Northampton.length] = createMarker(new GPoint(-75.49185181,40.68689346),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Northampton Middle School",'Northampton=' + Northampton.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.36301422,40.62786102),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Northeast Middle School",'Bethlehem=' + Bethlehem.length);
Easton[Easton.length] = createMarker(new GPoint(-75.26799011,40.68714142),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Palmer Elementary School",'Easton=' + Easton.length);
Easton[Easton.length] = createMarker(new GPoint(-75.22901917,40.70598221),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Paxinosa Elementary School",'Easton=' + Easton.length);
Pen_Argyl[Pen_Argyl.length] = createMarker(new GPoint(-75.25984192,40.87104416),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pen Argyl Area High School",'Pen_Argyl=' + Pen_Argyl.length);
Easton[Easton.length] = createMarker(new GPoint(-75.24243164,40.67203140),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Philip F Lauer Middle School",'Easton=' + Easton.length);
Nazareth[Nazareth.length] = createMarker(new GPoint(-75.27838135,40.78853989),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Plainfield Elementary School",'Nazareth=' + Nazareth.length);
Hellertown[Hellertown.length] = createMarker(new GPoint(-75.32352448,40.57082748),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Saucon Valley Elementary School",'Hellertown=' + Hellertown.length);
Hellertown[Hellertown.length] = createMarker(new GPoint(-75.32244110,40.57089233),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Saucon Valley Middle School",'Hellertown=' + Hellertown.length);
Hellertown[Hellertown.length] = createMarker(new GPoint(-75.32186890,40.57065201),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Saucon Valley Senior High School",'Hellertown=' + Hellertown.length);
Nazareth[Nazareth.length] = createMarker(new GPoint(-75.30127716,40.74129868),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Shafer Elementary School",'Nazareth=' + Nazareth.length);
Easton[Easton.length] = createMarker(new GPoint(-75.23043823,40.70748138),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Shawnee Middle School",'Easton=' + Easton.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.35984802,40.64696884),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Spring Garden Elementary School",'Bethlehem=' + Bethlehem.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.36807251,40.62326431),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Thomas Jefferson Elementary School",'Bethlehem=' + Bethlehem.length);
Easton[Easton.length] = createMarker(new GPoint(-75.25460052,40.71604156),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Tracy Elementary School",'Easton=' + Easton.length);
Bangor[Bangor.length] = createMarker(new GPoint(-75.21260834,40.84418488),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Washington Elementary School",'Bangor=' + Bangor.length);
Northampton[Northampton.length] = createMarker(new GPoint(-75.44808960,40.68677521),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Weaversville Intensive Trmt Un",'Northampton=' + Northampton.length);
Bethlehem[Bethlehem.length] = createMarker(new GPoint(-75.38151550,40.62786865),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("William Penn Elementary School",'Bethlehem=' + Bethlehem.length);
Easton[Easton.length] = createMarker(new GPoint(-75.23664093,40.64013672),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Williams Township Elementary School",'Easton=' + Easton.length);
Easton[Easton.length] = createMarker(new GPoint(-75.24446106,40.68501282),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wilson Area High School",'Easton=' + Easton.length);
Easton[Easton.length] = createMarker(new GPoint(-75.24298096,40.68554688),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wilson Borough Elementary School",'Easton=' + Easton.length);
Pen_Argyl[Pen_Argyl.length] = createMarker(new GPoint(-75.28363037,40.83776093),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Wind Gap Middle School",'Pen_Argyl=' + Pen_Argyl.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,10);
/*
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(Bangor);
map.removeOverlays(Bath);
map.removeOverlays(Bethlehem);
map.removeOverlays(Easton);
map.removeOverlays(Freemansburg);
map.removeOverlays(Hellertown);
map.removeOverlays(Nazareth);
map.removeOverlays(Northampton);
map.removeOverlays(Pen_Argyl);
map.removeOverlays(Walnutport);
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(Bethlehem);map.removeOverlays(Bangor);
map.removeOverlays(Bath);
map.removeOverlays(Bethlehem);
map.removeOverlays(Easton);
map.removeOverlays(Freemansburg);
map.removeOverlays(Hellertown);
map.removeOverlays(Nazareth);
map.removeOverlays(Northampton);
map.removeOverlays(Pen_Argyl);
map.removeOverlays(Walnutport);
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(Freemansburg);
centerByArray(Freemansburg, false, false);
cntMarker += Freemansburg.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(Walnutport);
centerByArray(Walnutport, false, false);
cntMarker += Walnutport.length;
centerByArray(Bethlehem,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');
}
}