function addMarkers()
{
mySelect = document.getElementById('selection');
Annville = [];Lebanon = [];Cleona = [];Cornwall = [];Myerstown = [];Palmyra = [];Fredericksburg = [];Jonestown = [];Schaefferstown = [];mySelect.options[mySelect.options.length] = new Option("Annville schools",'all=Annville');
mySelect.options[mySelect.options.length] = new Option("Cleona schools",'all=Cleona');
mySelect.options[mySelect.options.length] = new Option("Cornwall schools",'all=Cornwall');
mySelect.options[mySelect.options.length] = new Option("Fredericksburg schools",'all=Fredericksburg');
mySelect.options[mySelect.options.length] = new Option("Jonestown schools",'all=Jonestown');
mySelect.options[mySelect.options.length] = new Option("Lebanon schools",'all=Lebanon');
mySelect.options[mySelect.options.length] = new Option("Myerstown schools",'all=Myerstown');
mySelect.options[mySelect.options.length] = new Option("Palmyra schools",'all=Palmyra');
mySelect.options[mySelect.options.length] = new Option("Schaefferstown schools",'all=Schaefferstown');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Annville[Annville.length] = createMarker(new GPoint(-76.51167297,40.32358170),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Annville Cleona Junior Senior High School",'Annville=' + Annville.length);
Annville[Annville.length] = createMarker(new GPoint(-76.51412964,40.32707596),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Annville Elementary School",'Annville=' + Annville.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-76.40308380,40.30995560),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cedar Crest High School",'Lebanon=' + Lebanon.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-76.40458679,40.30883789),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Cedar Crest Middle School",'Lebanon=' + Lebanon.length);
Cleona[Cleona.length] = createMarker(new GPoint(-76.47410583,40.33531570),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cleona Elementary School",'Cleona=' + Cleona.length);
Cornwall[Cornwall.length] = createMarker(new GPoint(-76.40630341,40.27360153),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cornwall Elementary School",'Cornwall=' + Cornwall.length);
Annville[Annville.length] = createMarker(new GPoint(-76.58040619,40.39697647),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("East Hanover Elementary School",'Annville=' + Annville.length);
Myerstown[Myerstown.length] = createMarker(new GPoint(-76.29171753,40.34205246),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Eastern Lebanon Co Middle School",'Myerstown=' + Myerstown.length);
Myerstown[Myerstown.length] = createMarker(new GPoint(-76.28919220,40.34612656),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eastern Lebanon Co Senior High School",'Myerstown=' + Myerstown.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-76.43457794,40.36949921),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ebenezer Elementary School",'Lebanon=' + Lebanon.length);
Palmyra[Palmyra.length] = createMarker(new GPoint(-76.58404541,40.30815887),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Forge Road Elementary School",'Palmyra=' + Palmyra.length);
Fredericksburg[Fredericksburg.length] = createMarker(new GPoint(-76.42849731,40.45460129),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fredericksburg Elementary School",'Fredericksburg=' + Fredericksburg.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-76.42142487,40.33810806),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Harding Elementary School",'Lebanon=' + Lebanon.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-76.40697479,40.34656143),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Houck Elementary School",'Lebanon=' + Lebanon.length);
Myerstown[Myerstown.length] = createMarker(new GPoint(-76.33004761,40.36960983),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jackson Elementary School",'Myerstown=' + Myerstown.length);
Jonestown[Jonestown.length] = createMarker(new GPoint(-76.50199890,40.43249893),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jonestown Elementary School",'Jonestown=' + Jonestown.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-76.39575958,40.34168243),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lebanon County Ctc",'Lebanon=' + Lebanon.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-76.42270660,40.32731247),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lebanon Senior High School",'Lebanon=' + Lebanon.length);
Jonestown[Jonestown.length] = createMarker(new GPoint(-76.47878265,40.41368866),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lickdale Elementary School",'Jonestown=' + Jonestown.length);
Myerstown[Myerstown.length] = createMarker(new GPoint(-76.31620026,40.38750076),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Myerstown Elementary School",'Myerstown=' + Myerstown.length);
Annville[Annville.length] = createMarker(new GPoint(-76.51552582,40.32928085),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("North Annville Elementary School",'Annville=' + Annville.length);
Fredericksburg[Fredericksburg.length] = createMarker(new GPoint(-76.42849731,40.45460129),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Northern Lebanon Middle School",'Fredericksburg=' + Fredericksburg.length);
Fredericksburg[Fredericksburg.length] = createMarker(new GPoint(-76.42849731,40.45460129),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northern Lebanon Senior High School",'Fredericksburg=' + Fredericksburg.length);
Palmyra[Palmyra.length] = createMarker(new GPoint(-76.59691620,40.31538773),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Northside Elementary School",'Palmyra=' + Palmyra.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-76.42773437,40.34973145),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Northwest Elementary School",'Lebanon=' + Lebanon.length);
Palmyra[Palmyra.length] = createMarker(new GPoint(-76.59470367,40.30654907),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Palmyra Area Middle School",'Palmyra=' + Palmyra.length);
Palmyra[Palmyra.length] = createMarker(new GPoint(-76.58511353,40.29971313),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Palmyra Area Senior High School",'Palmyra=' + Palmyra.length);
Palmyra[Palmyra.length] = createMarker(new GPoint(-76.59177399,40.30277252),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pine Street Elementary School",'Palmyra=' + Palmyra.length);
Schaefferstown[Schaefferstown.length] = createMarker(new GPoint(-76.30519867,40.30450058),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Schaefferstown Elementary School",'Schaefferstown=' + Schaefferstown.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-76.36685944,40.31725311),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South Lebanon Elementary School",'Lebanon=' + Lebanon.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-76.40427399,40.33654404),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Southeast Elementary School",'Lebanon=' + Lebanon.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-76.43276978,40.32701111),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Southwest Elementary School",'Lebanon=' + Lebanon.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-76.37789154,40.36096573),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Union Canal Elementary School",'Lebanon=' + Lebanon.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(Annville);
map.removeOverlays(Cleona);
map.removeOverlays(Cornwall);
map.removeOverlays(Fredericksburg);
map.removeOverlays(Jonestown);
map.removeOverlays(Lebanon);
map.removeOverlays(Myerstown);
map.removeOverlays(Palmyra);
map.removeOverlays(Schaefferstown);
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(Annville);map.removeOverlays(Annville);
map.removeOverlays(Cleona);
map.removeOverlays(Cornwall);
map.removeOverlays(Fredericksburg);
map.removeOverlays(Jonestown);
map.removeOverlays(Lebanon);
map.removeOverlays(Myerstown);
map.removeOverlays(Palmyra);
map.removeOverlays(Schaefferstown);
map.addOverlays(Annville);
centerByArray(Annville, false, false);
cntMarker += Annville.length;
map.addOverlays(Cleona);
centerByArray(Cleona, false, false);
cntMarker += Cleona.length;
map.addOverlays(Cornwall);
centerByArray(Cornwall, false, false);
cntMarker += Cornwall.length;
map.addOverlays(Fredericksburg);
centerByArray(Fredericksburg, false, false);
cntMarker += Fredericksburg.length;
map.addOverlays(Jonestown);
centerByArray(Jonestown, false, false);
cntMarker += Jonestown.length;
map.addOverlays(Lebanon);
centerByArray(Lebanon, false, false);
cntMarker += Lebanon.length;
map.addOverlays(Myerstown);
centerByArray(Myerstown, false, false);
cntMarker += Myerstown.length;
map.addOverlays(Palmyra);
centerByArray(Palmyra, false, false);
cntMarker += Palmyra.length;
map.addOverlays(Schaefferstown);
centerByArray(Schaefferstown, false, false);
cntMarker += Schaefferstown.length;
centerByArray(Annville,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');
}
}