function addMarkers()
{
mySelect = document.getElementById('selection');
Clarks_Summit = [];Moscow = [];Carbondale = [];Scranton = [];Dunmore = [];Simpson = [];Lake_Ariel = [];Jermyn = [];Mayfield = [];Throop = [];Eynon = [];Old_Forge = [];Moosic = [];Taylor = [];Chinchilla = [];Peckville = [];Archbald = [];Waverly = [];mySelect.options[mySelect.options.length] = new Option("Archbald schools",'all=Archbald');
mySelect.options[mySelect.options.length] = new Option("Carbondale schools",'all=Carbondale');
mySelect.options[mySelect.options.length] = new Option("Chinchilla schools",'all=Chinchilla');
mySelect.options[mySelect.options.length] = new Option("Clarks Summit schools",'all=Clarks_Summit');
mySelect.options[mySelect.options.length] = new Option("Dunmore schools",'all=Dunmore');
mySelect.options[mySelect.options.length] = new Option("Eynon schools",'all=Eynon');
mySelect.options[mySelect.options.length] = new Option("Jermyn schools",'all=Jermyn');
mySelect.options[mySelect.options.length] = new Option("Lake Ariel schools",'all=Lake_Ariel');
mySelect.options[mySelect.options.length] = new Option("Mayfield schools",'all=Mayfield');
mySelect.options[mySelect.options.length] = new Option("Moosic schools",'all=Moosic');
mySelect.options[mySelect.options.length] = new Option("Moscow schools",'all=Moscow');
mySelect.options[mySelect.options.length] = new Option("Old Forge schools",'all=Old_Forge');
mySelect.options[mySelect.options.length] = new Option("Peckville schools",'all=Peckville');
mySelect.options[mySelect.options.length] = new Option("Scranton schools",'all=Scranton');
mySelect.options[mySelect.options.length] = new Option("Simpson schools",'all=Simpson');
mySelect.options[mySelect.options.length] = new Option("Taylor schools",'all=Taylor');
mySelect.options[mySelect.options.length] = new Option("Throop schools",'all=Throop');
mySelect.options[mySelect.options.length] = new Option("Waverly schools",'all=Waverly');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Clarks_Summit[Clarks_Summit.length] = createMarker(new GPoint(-75.72132111,41.49383926),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Abington Heights High School",'Clarks_Summit=' + Clarks_Summit.length);
Clarks_Summit[Clarks_Summit.length] = createMarker(new GPoint(-75.71012878,41.48976898),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Abington Heights Middle School",'Clarks_Summit=' + Clarks_Summit.length);
Moscow[Moscow.length] = createMarker(new GPoint(-75.52124023,41.33887863),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Academy Street School",'Moscow=' + Moscow.length);
Carbondale[Carbondale.length] = createMarker(new GPoint(-75.50267029,41.57394028),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Carbondale Area Junior Senior High School",'Carbondale=' + Carbondale.length);
Carbondale[Carbondale.length] = createMarker(new GPoint(-75.51200867,41.56731033),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Carbondale Elementary School",'Carbondale=' + Carbondale.length);
Scranton[Scranton.length] = createMarker(new GPoint(-75.67225647,41.42713928),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Charles Sumner #18 Elementary School",'Scranton=' + Scranton.length);
Clarks_Summit[Clarks_Summit.length] = createMarker(new GPoint(-75.70301056,41.49009323),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clarks Summit Elementary School",'Clarks_Summit=' + Clarks_Summit.length);
Scranton[Scranton.length] = createMarker(new GPoint(-75.66309357,41.40956879),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ctc Of Lackawanna County",'Scranton=' + Scranton.length);
Dunmore[Dunmore.length] = createMarker(new GPoint(-75.62931824,41.42559433),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dunmore El Center",'Dunmore=' + Dunmore.length);
Dunmore[Dunmore.length] = createMarker(new GPoint(-75.62931824,41.42559433),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Dunmore High School",'Dunmore=' + Dunmore.length);
Dunmore[Dunmore.length] = createMarker(new GPoint(-75.62931824,41.42559433),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Dunmore Middle School",'Dunmore=' + Dunmore.length);
Simpson[Simpson.length] = createMarker(new GPoint(-75.48428345,41.59832382),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fell Charter School",'Simpson=' + Simpson.length);
Simpson[Simpson.length] = createMarker(new GPoint(-75.50108337,41.57445908),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fell Elementary School",'Simpson=' + Simpson.length);
Scranton[Scranton.length] = createMarker(new GPoint(-75.68595123,41.40559387),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Frances Willard #32 Elementary School",'Scranton=' + Scranton.length);
Scranton[Scranton.length] = createMarker(new GPoint(-75.66307068,41.42356491),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("George Bancroft #34 Elementary School",'Scranton=' + Scranton.length);
Lake_Ariel[Lake_Ariel.length] = createMarker(new GPoint(-75.50148773,41.41473770),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'Lake_Ariel=' + Lake_Ariel.length);
Scranton[Scranton.length] = createMarker(new GPoint(-75.65781403,41.41896439),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("John Adams #4 Elementary School",'Scranton=' + Scranton.length);
Scranton[Scranton.length] = createMarker(new GPoint(-75.67098236,41.39122009),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("John F. Kennedy #7 Elementary School",'Scranton=' + Scranton.length);
Scranton[Scranton.length] = createMarker(new GPoint(-75.65866852,41.39930725),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("John G Whittier #2 Elementary School",'Scranton=' + Scranton.length);
Scranton[Scranton.length] = createMarker(new GPoint(-75.64614105,41.40109253),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("John J. Audubon #42 Elementary School",'Scranton=' + Scranton.length);
Scranton[Scranton.length] = createMarker(new GPoint(-75.68441772,41.41479874),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("John Marshall #41 Elementary School",'Scranton=' + Scranton.length);
Jermyn[Jermyn.length] = createMarker(new GPoint(-75.60575867,41.55587387),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lakeland Elementary School",'Jermyn=' + Jermyn.length);
Jermyn[Jermyn.length] = createMarker(new GPoint(-75.60227203,41.55955505),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lakeland Junior Senior High School",'Jermyn=' + Jermyn.length);
Scranton[Scranton.length] = createMarker(new GPoint(-75.68759918,41.41239929),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lincoln-jackson #14 Elementary School",'Scranton=' + Scranton.length);
Mayfield[Mayfield.length] = createMarker(new GPoint(-75.53356171,41.54279709),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mayfield Elementary School",'Mayfield=' + Mayfield.length);
Scranton[Scranton.length] = createMarker(new GPoint(-75.66479492,41.39107513),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mcnichols Plaza Elementary School",'Scranton=' + Scranton.length);
Throop[Throop.length] = createMarker(new GPoint(-75.60213470,41.44728088),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mid Valley El Center",'Throop=' + Throop.length);
Throop[Throop.length] = createMarker(new GPoint(-75.60181427,41.44743347),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mid Valley Sec Center",'Throop=' + Throop.length);
Moscow[Moscow.length] = createMarker(new GPoint(-75.53359222,41.33874893),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Moscow El Center",'Moscow=' + Moscow.length);
Scranton[Scranton.length] = createMarker(new GPoint(-75.68441772,41.41479874),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Neil Armstrong #40 Elementary School",'Scranton=' + Scranton.length);
Clarks_Summit[Clarks_Summit.length] = createMarker(new GPoint(-75.71012878,41.48976898),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Newton-ransom School",'Clarks_Summit=' + Clarks_Summit.length);
Moscow[Moscow.length] = createMarker(new GPoint(-75.52886963,41.33755875),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Pocono High School",'Moscow=' + Moscow.length);
Moscow[Moscow.length] = createMarker(new GPoint(-75.52886963,41.33755875),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("North Pocono Middle School",'Moscow=' + Moscow.length);
Eynon[Eynon.length] = createMarker(new GPoint(-75.57489014,41.49646378),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northeast Charter School",'Eynon=' + Eynon.length);
Scranton[Scranton.length] = createMarker(new GPoint(-75.64626312,41.42166138),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Northeast Intrmd School",'Scranton=' + Scranton.length);
Old_Forge[Old_Forge.length] = createMarker(new GPoint(-75.74356079,41.37221146),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Old Forge Elementary School",'Old_Forge=' + Old_Forge.length);
Old_Forge[Old_Forge.length] = createMarker(new GPoint(-75.73954773,41.37194061),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Old Forge Junior Senior High School",'Old_Forge=' + Old_Forge.length);
Moosic[Moosic.length] = createMarker(new GPoint(-75.73822784,41.35287094),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Riverside El School East",'Moosic=' + Moosic.length);
Taylor[Taylor.length] = createMarker(new GPoint(-75.71715546,41.38051987),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Riverside El School West",'Taylor=' + Taylor.length);
Taylor[Taylor.length] = createMarker(new GPoint(-75.71718597,41.38053131),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Riverside Junior Senior High School",'Taylor=' + Taylor.length);
Scranton[Scranton.length] = createMarker(new GPoint(-75.64739990,41.43251038),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Robert Morris #27 Elementary School",'Scranton=' + Scranton.length);
Scranton[Scranton.length] = createMarker(new GPoint(-75.66309357,41.40956879),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Scranton High School",'Scranton=' + Scranton.length);
Scranton[Scranton.length] = createMarker(new GPoint(-75.64174652,41.42953873),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Scranton State School For Deaf",'Scranton=' + Scranton.length);
Chinchilla[Chinchilla.length] = createMarker(new GPoint(-75.66914368,41.46681976),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South Abington School",'Chinchilla=' + Chinchilla.length);
Scranton[Scranton.length] = createMarker(new GPoint(-75.67037201,41.39706421),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("South Scranton Intrmd School",'Scranton=' + Scranton.length);
Peckville[Peckville.length] = createMarker(new GPoint(-75.58602142,41.47941971),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Valley View El Center",'Peckville=' + Peckville.length);
Archbald[Archbald.length] = createMarker(new GPoint(-75.56348900,41.50699100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Valley View High School",'Archbald=' + Archbald.length);
Archbald[Archbald.length] = createMarker(new GPoint(-75.55503845,41.49827576),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Valley View Intrmd School",'Archbald=' + Archbald.length);
Archbald[Archbald.length] = createMarker(new GPoint(-75.55484772,41.49804688),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Valley View Middle School",'Archbald=' + Archbald.length);
Waverly[Waverly.length] = createMarker(new GPoint(-75.70580292,41.52629852),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Waverly School",'Waverly=' + Waverly.length);
Scranton[Scranton.length] = createMarker(new GPoint(-75.68726349,41.40956879),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West Scranton High School",'Scranton=' + Scranton.length);
Scranton[Scranton.length] = createMarker(new GPoint(-75.69338226,41.41065979),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("West Scranton Intrmd School",'Scranton=' + Scranton.length);
Scranton[Scranton.length] = createMarker(new GPoint(-75.63938141,41.41334152),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("William Prescott #38 Elementary School",'Scranton=' + Scranton.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(Archbald);
map.removeOverlays(Carbondale);
map.removeOverlays(Chinchilla);
map.removeOverlays(Clarks_Summit);
map.removeOverlays(Dunmore);
map.removeOverlays(Eynon);
map.removeOverlays(Jermyn);
map.removeOverlays(Lake_Ariel);
map.removeOverlays(Mayfield);
map.removeOverlays(Moosic);
map.removeOverlays(Moscow);
map.removeOverlays(Old_Forge);
map.removeOverlays(Peckville);
map.removeOverlays(Scranton);
map.removeOverlays(Simpson);
map.removeOverlays(Taylor);
map.removeOverlays(Throop);
map.removeOverlays(Waverly);
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(Clarks_Summit);map.removeOverlays(Archbald);
map.removeOverlays(Carbondale);
map.removeOverlays(Chinchilla);
map.removeOverlays(Clarks_Summit);
map.removeOverlays(Dunmore);
map.removeOverlays(Eynon);
map.removeOverlays(Jermyn);
map.removeOverlays(Lake_Ariel);
map.removeOverlays(Mayfield);
map.removeOverlays(Moosic);
map.removeOverlays(Moscow);
map.removeOverlays(Old_Forge);
map.removeOverlays(Peckville);
map.removeOverlays(Scranton);
map.removeOverlays(Simpson);
map.removeOverlays(Taylor);
map.removeOverlays(Throop);
map.removeOverlays(Waverly);
map.addOverlays(Archbald);
centerByArray(Archbald, false, false);
cntMarker += Archbald.length;
map.addOverlays(Carbondale);
centerByArray(Carbondale, false, false);
cntMarker += Carbondale.length;
map.addOverlays(Chinchilla);
centerByArray(Chinchilla, false, false);
cntMarker += Chinchilla.length;
map.addOverlays(Clarks_Summit);
centerByArray(Clarks_Summit, false, false);
cntMarker += Clarks_Summit.length;
map.addOverlays(Dunmore);
centerByArray(Dunmore, false, false);
cntMarker += Dunmore.length;
map.addOverlays(Eynon);
centerByArray(Eynon, false, false);
cntMarker += Eynon.length;
map.addOverlays(Jermyn);
centerByArray(Jermyn, false, false);
cntMarker += Jermyn.length;
map.addOverlays(Lake_Ariel);
centerByArray(Lake_Ariel, false, false);
cntMarker += Lake_Ariel.length;
map.addOverlays(Mayfield);
centerByArray(Mayfield, false, false);
cntMarker += Mayfield.length;
map.addOverlays(Moosic);
centerByArray(Moosic, false, false);
cntMarker += Moosic.length;
map.addOverlays(Moscow);
centerByArray(Moscow, false, false);
cntMarker += Moscow.length;
map.addOverlays(Old_Forge);
centerByArray(Old_Forge, false, false);
cntMarker += Old_Forge.length;
map.addOverlays(Peckville);
centerByArray(Peckville, false, false);
cntMarker += Peckville.length;
map.addOverlays(Scranton);
centerByArray(Scranton, false, false);
cntMarker += Scranton.length;
map.addOverlays(Simpson);
centerByArray(Simpson, false, false);
cntMarker += Simpson.length;
map.addOverlays(Taylor);
centerByArray(Taylor, false, false);
cntMarker += Taylor.length;
map.addOverlays(Throop);
centerByArray(Throop, false, false);
cntMarker += Throop.length;
map.addOverlays(Waverly);
centerByArray(Waverly, false, false);
cntMarker += Waverly.length;
centerByArray(Clarks_Summit,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');
}
}