function addMarkers()
{
mySelect = document.getElementById('selection');
Jersey_Shore = [];Williamsport = [];Montoursville = [];Lairdsville = [];South_Williamsport = [];Chester = [];Picture_Rocks = [];Cogan_Station = [];Hughesville = [];Montgomery = [];Muncy = [];Linden = [];mySelect.options[mySelect.options.length] = new Option("Chester schools",'all=Chester');
mySelect.options[mySelect.options.length] = new Option("Cogan Station schools",'all=Cogan_Station');
mySelect.options[mySelect.options.length] = new Option("Hughesville schools",'all=Hughesville');
mySelect.options[mySelect.options.length] = new Option("Jersey Shore schools",'all=Jersey_Shore');
mySelect.options[mySelect.options.length] = new Option("Lairdsville schools",'all=Lairdsville');
mySelect.options[mySelect.options.length] = new Option("Linden schools",'all=Linden');
mySelect.options[mySelect.options.length] = new Option("Montgomery schools",'all=Montgomery');
mySelect.options[mySelect.options.length] = new Option("Montoursville schools",'all=Montoursville');
mySelect.options[mySelect.options.length] = new Option("Muncy schools",'all=Muncy');
mySelect.options[mySelect.options.length] = new Option("Picture Rocks schools",'all=Picture_Rocks');
mySelect.options[mySelect.options.length] = new Option("South Williamsport schools",'all=South_Williamsport');
mySelect.options[mySelect.options.length] = new Option("Williamsport schools",'all=Williamsport');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Jersey_Shore[Jersey_Shore.length] = createMarker(new GPoint(-77.19740295,41.08509827),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Avis Elementary School",'Jersey_Shore=' + Jersey_Shore.length);
Williamsport[Williamsport.length] = createMarker(new GPoint(-76.96721649,41.25542068),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Becht Elementary School",'Williamsport=' + Williamsport.length);
Montoursville[Montoursville.length] = createMarker(new GPoint(-76.90640259,41.25502396),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("C E Mccall Middle School",'Montoursville=' + Montoursville.length);
Lairdsville[Lairdsville.length] = createMarker(new GPoint(-76.61192322,41.23086166),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Carl G Renn Elementary School",'Lairdsville=' + Lairdsville.length);
South_Williamsport[South_Williamsport.length] = createMarker(new GPoint(-76.99916840,41.22746658),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'South_Williamsport=' + South_Williamsport.length);
Chester[Chester.length] = createMarker(new GPoint(-81.17787170,34.71132660),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Chester Park Complex Elementary School",'Chester=' + Chester.length);
Williamsport[Williamsport.length] = createMarker(new GPoint(-77.01213074,41.25424957),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cochran Elementary School",'Williamsport=' + Williamsport.length);
Williamsport[Williamsport.length] = createMarker(new GPoint(-77.00373077,41.25177002),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Curtin Middle School",'Williamsport=' + Williamsport.length);
Williamsport[Williamsport.length] = createMarker(new GPoint(-77.03385925,41.22571945),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Duboistown Elementary School",'Williamsport=' + Williamsport.length);
Montoursville[Montoursville.length] = createMarker(new GPoint(-76.94671631,41.26253510),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Four Mile School",'Montoursville=' + Montoursville.length);
Picture_Rocks[Picture_Rocks.length] = createMarker(new GPoint(-76.71691895,41.28107834),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("George A Ferrell Elementary School",'Picture_Rocks=' + Picture_Rocks.length);
Cogan_Station[Cogan_Station.length] = createMarker(new GPoint(-77.06845093,41.32027817),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hepburn-lycoming Elementary School",'Cogan_Station=' + Cogan_Station.length);
Hughesville[Hughesville.length] = createMarker(new GPoint(-76.73300934,41.24124146),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hughesville Junior Senior High School",'Hughesville=' + Hughesville.length);
Williamsport[Williamsport.length] = createMarker(new GPoint(-77.06194305,41.23857880),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jackson Elementary School",'Williamsport=' + Williamsport.length);
Jersey_Shore[Jersey_Shore.length] = createMarker(new GPoint(-77.26390076,41.19968033),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jersey Shore Area Elementary School",'Jersey_Shore=' + Jersey_Shore.length);
Jersey_Shore[Jersey_Shore.length] = createMarker(new GPoint(-77.26184845,41.19696426),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jersey Shore Area Senior High School",'Jersey_Shore=' + Jersey_Shore.length);
Jersey_Shore[Jersey_Shore.length] = createMarker(new GPoint(-77.26261902,41.20089340),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Jersey Shore Middle School",'Jersey_Shore=' + Jersey_Shore.length);
Hughesville[Hughesville.length] = createMarker(new GPoint(-76.72968292,41.23979950),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Joseph C Ashkar Elementary School",'Hughesville=' + Hughesville.length);
Williamsport[Williamsport.length] = createMarker(new GPoint(-77.02718353,41.24116135),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lose Elementary School",'Williamsport=' + Williamsport.length);
Williamsport[Williamsport.length] = createMarker(new GPoint(-76.96450043,41.26023865),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Loyalsock Township Middle School",'Williamsport=' + Williamsport.length);
Williamsport[Williamsport.length] = createMarker(new GPoint(-76.96766663,41.25979614),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Loyalsock Township Senior High School",'Williamsport=' + Williamsport.length);
Montoursville[Montoursville.length] = createMarker(new GPoint(-76.92247772,41.25457001),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Loyalsock Valley Elementary School",'Montoursville=' + Montoursville.length);
Williamsport[Williamsport.length] = createMarker(new GPoint(-77.11045837,41.21835327),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lycoming Ctc",'Williamsport=' + Williamsport.length);
Williamsport[Williamsport.length] = createMarker(new GPoint(-77.05394745,41.29022980),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Lycoming Valley Middle School",'Williamsport=' + Williamsport.length);
Montoursville[Montoursville.length] = createMarker(new GPoint(-76.91445160,41.25323868),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lyter Elementary School",'Montoursville=' + Montoursville.length);
Montgomery[Montgomery.length] = createMarker(new GPoint(-76.87425995,41.17337036),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Montgomery Elementary School",'Montgomery=' + Montgomery.length);
Montgomery[Montgomery.length] = createMarker(new GPoint(-76.87425995,41.17337036),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montgomery Senior High School",'Montgomery=' + Montgomery.length);
Montoursville[Montoursville.length] = createMarker(new GPoint(-76.91980743,41.25011444),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montoursville Area Senior High School",'Montoursville=' + Montoursville.length);
Muncy[Muncy.length] = createMarker(new GPoint(-76.78947449,41.20205307),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Muncy Junior Senior High School",'Muncy=' + Muncy.length);
Williamsport[Williamsport.length] = createMarker(new GPoint(-77.16102600,41.14999390),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Nippenose Valley Elementary School",'Williamsport=' + Williamsport.length);
Williamsport[Williamsport.length] = createMarker(new GPoint(-77.03749847,41.21559906),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Nisbet Elementary School",'Williamsport=' + Williamsport.length);
South_Williamsport[South_Williamsport.length] = createMarker(new GPoint(-76.99909973,41.22947311),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Rommelt Elementary School",'South_Williamsport=' + South_Williamsport.length);
Williamsport[Williamsport.length] = createMarker(new GPoint(-77.06720734,41.23771667),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Roosevelt Middle School",'Williamsport=' + Williamsport.length);
Williamsport[Williamsport.length] = createMarker(new GPoint(-77.07097626,41.25220490),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Round Hills Elementary School",'Williamsport=' + Williamsport.length);
Jersey_Shore[Jersey_Shore.length] = createMarker(new GPoint(-77.26455688,41.20188904),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Salladasburg Elementary School",'Jersey_Shore=' + Jersey_Shore.length);
Williamsport[Williamsport.length] = createMarker(new GPoint(-76.98737335,41.25333786),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sheridan Elementary School",'Williamsport=' + Williamsport.length);
South_Williamsport[South_Williamsport.length] = createMarker(new GPoint(-76.99558258,41.22641754),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Williamsport Area Junior Senior High School",'South_Williamsport=' + South_Williamsport.length);
Williamsport[Williamsport.length] = createMarker(new GPoint(-77.02871704,41.24608612),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Stevens Elementary School",'Williamsport=' + Williamsport.length);
Muncy[Muncy.length] = createMarker(new GPoint(-76.78256226,41.19951248),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ward L Myers Elementary School",'Muncy=' + Muncy.length);
Linden[Linden.length] = createMarker(new GPoint(-77.13961792,41.23049164),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Williamsport Area Alternative",'Linden=' + Linden.length);
Williamsport[Williamsport.length] = createMarker(new GPoint(-77.00141400,41.24094500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Williamsport Area Senior High School",'Williamsport=' + Williamsport.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(Chester);
map.removeOverlays(Cogan_Station);
map.removeOverlays(Hughesville);
map.removeOverlays(Jersey_Shore);
map.removeOverlays(Lairdsville);
map.removeOverlays(Linden);
map.removeOverlays(Montgomery);
map.removeOverlays(Montoursville);
map.removeOverlays(Muncy);
map.removeOverlays(Picture_Rocks);
map.removeOverlays(South_Williamsport);
map.removeOverlays(Williamsport);
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(Jersey_Shore);map.removeOverlays(Chester);
map.removeOverlays(Cogan_Station);
map.removeOverlays(Hughesville);
map.removeOverlays(Jersey_Shore);
map.removeOverlays(Lairdsville);
map.removeOverlays(Linden);
map.removeOverlays(Montgomery);
map.removeOverlays(Montoursville);
map.removeOverlays(Muncy);
map.removeOverlays(Picture_Rocks);
map.removeOverlays(South_Williamsport);
map.removeOverlays(Williamsport);
map.addOverlays(Chester);
centerByArray(Chester, false, false);
cntMarker += Chester.length;
map.addOverlays(Cogan_Station);
centerByArray(Cogan_Station, false, false);
cntMarker += Cogan_Station.length;
map.addOverlays(Hughesville);
centerByArray(Hughesville, false, false);
cntMarker += Hughesville.length;
map.addOverlays(Jersey_Shore);
centerByArray(Jersey_Shore, false, false);
cntMarker += Jersey_Shore.length;
map.addOverlays(Lairdsville);
centerByArray(Lairdsville, false, false);
cntMarker += Lairdsville.length;
map.addOverlays(Linden);
centerByArray(Linden, false, false);
cntMarker += Linden.length;
map.addOverlays(Montgomery);
centerByArray(Montgomery, false, false);
cntMarker += Montgomery.length;
map.addOverlays(Montoursville);
centerByArray(Montoursville, false, false);
cntMarker += Montoursville.length;
map.addOverlays(Muncy);
centerByArray(Muncy, false, false);
cntMarker += Muncy.length;
map.addOverlays(Picture_Rocks);
centerByArray(Picture_Rocks, false, false);
cntMarker += Picture_Rocks.length;
map.addOverlays(South_Williamsport);
centerByArray(South_Williamsport, false, false);
cntMarker += South_Williamsport.length;
map.addOverlays(Williamsport);
centerByArray(Williamsport, false, false);
cntMarker += Williamsport.length;
centerByArray(Jersey_Shore,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');
}
}