function addMarkers()
{
mySelect = document.getElementById('selection');
Stroudsburg = [];Cresco = [];Brodheadsville = [];Tobyhanna = [];East_Stroudsburg = [];Kunkletown = [];Sciota = [];Bartonsville = [];Tannersville = [];Swiftwater = [];Pocono_Summit = [];Kresgeville = [];Pocono_Pines = [];mySelect.options[mySelect.options.length] = new Option("Bartonsville schools",'all=Bartonsville');
mySelect.options[mySelect.options.length] = new Option("Brodheadsville schools",'all=Brodheadsville');
mySelect.options[mySelect.options.length] = new Option("Cresco schools",'all=Cresco');
mySelect.options[mySelect.options.length] = new Option("East Stroudsburg schools",'all=East_Stroudsburg');
mySelect.options[mySelect.options.length] = new Option("Kresgeville schools",'all=Kresgeville');
mySelect.options[mySelect.options.length] = new Option("Kunkletown schools",'all=Kunkletown');
mySelect.options[mySelect.options.length] = new Option("Pocono Pines schools",'all=Pocono_Pines');
mySelect.options[mySelect.options.length] = new Option("Pocono Summit schools",'all=Pocono_Summit');
mySelect.options[mySelect.options.length] = new Option("Sciota schools",'all=Sciota');
mySelect.options[mySelect.options.length] = new Option("Stroudsburg schools",'all=Stroudsburg');
mySelect.options[mySelect.options.length] = new Option("Swiftwater schools",'all=Swiftwater');
mySelect.options[mySelect.options.length] = new Option("Tannersville schools",'all=Tannersville');
mySelect.options[mySelect.options.length] = new Option("Tobyhanna schools",'all=Tobyhanna');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Stroudsburg[Stroudsburg.length] = createMarker(new GPoint(-75.21417999,40.98993683),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Arlington Heights Elementary School",'Stroudsburg=' + Stroudsburg.length);
Stroudsburg[Stroudsburg.length] = createMarker(new GPoint(-75.20410156,40.98313522),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("B F Morey Elementary School",'Stroudsburg=' + Stroudsburg.length);
Cresco[Cresco.length] = createMarker(new GPoint(-75.28012085,41.15420151),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Barrett El Center",'Cresco=' + Cresco.length);
Brodheadsville[Brodheadsville.length] = createMarker(new GPoint(-75.39376831,40.92407990),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Chestnuthill Elementary School",'Brodheadsville=' + Brodheadsville.length);
Tobyhanna[Tobyhanna.length] = createMarker(new GPoint(-75.38224792,41.15542221),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clear Run El Center",'Tobyhanna=' + Tobyhanna.length);
Tobyhanna[Tobyhanna.length] = createMarker(new GPoint(-75.38086700,41.15404510),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Clear Run Intermediate School",'Tobyhanna=' + Tobyhanna.length);
Stroudsburg[Stroudsburg.length] = createMarker(new GPoint(-75.20421600,41.00848770),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clearview Elementary School",'Stroudsburg=' + Stroudsburg.length);
Tobyhanna[Tobyhanna.length] = createMarker(new GPoint(-75.42333984,41.17569733),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Coolbaugh El Center",'Tobyhanna=' + Tobyhanna.length);
Tobyhanna[Tobyhanna.length] = createMarker(new GPoint(-75.42390442,41.18001556),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Coolbaugh Learning Center",'Tobyhanna=' + Tobyhanna.length);
East_Stroudsburg[East_Stroudsburg.length] = createMarker(new GPoint(-75.14880371,41.05770111),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("East Stroudsburg Elementary School",'East_Stroudsburg=' + East_Stroudsburg.length);
East_Stroudsburg[East_Stroudsburg.length] = createMarker(new GPoint(-75.18455505,41.00740814),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("East Stroudsburg Shs South High School",'East_Stroudsburg=' + East_Stroudsburg.length);
Kunkletown[Kunkletown.length] = createMarker(new GPoint(-75.47070312,40.85940170),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Eldred Elementary School",'Kunkletown=' + Kunkletown.length);
Sciota[Sciota.length] = createMarker(new GPoint(-75.31690979,40.92942810),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hamilton Township Elementary School",'Sciota=' + Sciota.length);
East_Stroudsburg[East_Stroudsburg.length] = createMarker(new GPoint(-75.17831421,41.00451279),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("J M Hill Elementary School",'East_Stroudsburg=' + East_Stroudsburg.length);
East_Stroudsburg[East_Stroudsburg.length] = createMarker(new GPoint(-75.17554474,41.02206039),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("J T Lambert Intermediate School",'East_Stroudsburg=' + East_Stroudsburg.length);
East_Stroudsburg[East_Stroudsburg.length] = createMarker(new GPoint(-75.07890320,41.06040573),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Middle Smithfield Elementary School",'East_Stroudsburg=' + East_Stroudsburg.length);
Bartonsville[Bartonsville.length] = createMarker(new GPoint(-75.28949738,41.01419830),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Monroe Career & Tech Inst",'Bartonsville=' + Bartonsville.length);
Kunkletown[Kunkletown.length] = createMarker(new GPoint(-75.45629883,40.89450073),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pleasant Valley Elementary School",'Kunkletown=' + Kunkletown.length);
Brodheadsville[Brodheadsville.length] = createMarker(new GPoint(-75.39376831,40.92407990),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pleasant Valley High School",'Brodheadsville=' + Brodheadsville.length);
Kunkletown[Kunkletown.length] = createMarker(new GPoint(-75.50240326,40.91519928),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Pleasant Valley Intrmd School",'Kunkletown=' + Kunkletown.length);
Brodheadsville[Brodheadsville.length] = createMarker(new GPoint(-75.39376831,40.92407990),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Pleasant Valley Middle School",'Brodheadsville=' + Brodheadsville.length);
Tannersville[Tannersville.length] = createMarker(new GPoint(-75.31944275,41.02980042),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pocono El Center",'Tannersville=' + Tannersville.length);
Cresco[Cresco.length] = createMarker(new GPoint(-75.28012085,41.15420151),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pocono Mountain Academy",'Cresco=' + Cresco.length);
Tobyhanna[Tobyhanna.length] = createMarker(new GPoint(-75.36895752,41.19792175),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pocono Mountain Charter School",'Tobyhanna=' + Tobyhanna.length);
Swiftwater[Swiftwater.length] = createMarker(new GPoint(-75.35859680,41.08639908),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pocono Mountain East High School/academ",'Swiftwater=' + Swiftwater.length);
Pocono_Summit[Pocono_Summit.length] = createMarker(new GPoint(-75.41000366,41.09870148),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pocono Mountain West High School",'Pocono_Summit=' + Pocono_Summit.length);
Tobyhanna[Tobyhanna.length] = createMarker(new GPoint(-75.41818400,41.17700800),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pocono School Of Excellence Charter School",'Tobyhanna=' + Tobyhanna.length);
Kresgeville[Kresgeville.length] = createMarker(new GPoint(-75.50334167,40.89688873),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Polk Elementary School",'Kresgeville=' + Kresgeville.length);
East_Stroudsburg[East_Stroudsburg.length] = createMarker(new GPoint(-75.11151886,41.07456207),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Resica Elementary School",'East_Stroudsburg=' + East_Stroudsburg.length);
East_Stroudsburg[East_Stroudsburg.length] = createMarker(new GPoint(-75.17806400,40.99455000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Smithfield Elementary School",'East_Stroudsburg=' + East_Stroudsburg.length);
Stroudsburg[Stroudsburg.length] = createMarker(new GPoint(-75.20558167,40.98293686),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Stroudsburg High School",'Stroudsburg=' + Stroudsburg.length);
Stroudsburg[Stroudsburg.length] = createMarker(new GPoint(-75.23159790,41.00078201),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Stroudsburg Intrmd Elementary School",'Stroudsburg=' + Stroudsburg.length);
Stroudsburg[Stroudsburg.length] = createMarker(new GPoint(-75.21813965,40.99463654),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Stroudsburg Jhs/ms Middle School",'Stroudsburg=' + Stroudsburg.length);
Stroudsburg[Stroudsburg.length] = createMarker(new GPoint(-75.24450400,40.99584400),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Stroudsburg MiddleSchool",'Stroudsburg=' + Stroudsburg.length);
Swiftwater[Swiftwater.length] = createMarker(new GPoint(-75.35859680,41.08639908),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Swiftwater El Center",'Swiftwater=' + Swiftwater.length);
Swiftwater[Swiftwater.length] = createMarker(new GPoint(-75.35859680,41.08639908),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Swiftwater Interm School",'Swiftwater=' + Swiftwater.length);
Tannersville[Tannersville.length] = createMarker(new GPoint(-75.30870056,41.04433823),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Tannersville Learning Center",'Tannersville=' + Tannersville.length);
Pocono_Pines[Pocono_Pines.length] = createMarker(new GPoint(-75.46219635,41.11069870),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Tobyhanna El Center",'Pocono_Pines=' + Pocono_Pines.length);
Stroudsburg[Stroudsburg.length] = createMarker(new GPoint(-75.19343567,40.98899460),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("W H Ramsey Elementary School",'Stroudsburg=' + Stroudsburg.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(Bartonsville);
map.removeOverlays(Brodheadsville);
map.removeOverlays(Cresco);
map.removeOverlays(East_Stroudsburg);
map.removeOverlays(Kresgeville);
map.removeOverlays(Kunkletown);
map.removeOverlays(Pocono_Pines);
map.removeOverlays(Pocono_Summit);
map.removeOverlays(Sciota);
map.removeOverlays(Stroudsburg);
map.removeOverlays(Swiftwater);
map.removeOverlays(Tannersville);
map.removeOverlays(Tobyhanna);
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(Stroudsburg);map.removeOverlays(Bartonsville);
map.removeOverlays(Brodheadsville);
map.removeOverlays(Cresco);
map.removeOverlays(East_Stroudsburg);
map.removeOverlays(Kresgeville);
map.removeOverlays(Kunkletown);
map.removeOverlays(Pocono_Pines);
map.removeOverlays(Pocono_Summit);
map.removeOverlays(Sciota);
map.removeOverlays(Stroudsburg);
map.removeOverlays(Swiftwater);
map.removeOverlays(Tannersville);
map.removeOverlays(Tobyhanna);
map.addOverlays(Bartonsville);
centerByArray(Bartonsville, false, false);
cntMarker += Bartonsville.length;
map.addOverlays(Brodheadsville);
centerByArray(Brodheadsville, false, false);
cntMarker += Brodheadsville.length;
map.addOverlays(Cresco);
centerByArray(Cresco, false, false);
cntMarker += Cresco.length;
map.addOverlays(East_Stroudsburg);
centerByArray(East_Stroudsburg, false, false);
cntMarker += East_Stroudsburg.length;
map.addOverlays(Kresgeville);
centerByArray(Kresgeville, false, false);
cntMarker += Kresgeville.length;
map.addOverlays(Kunkletown);
centerByArray(Kunkletown, false, false);
cntMarker += Kunkletown.length;
map.addOverlays(Pocono_Pines);
centerByArray(Pocono_Pines, false, false);
cntMarker += Pocono_Pines.length;
map.addOverlays(Pocono_Summit);
centerByArray(Pocono_Summit, false, false);
cntMarker += Pocono_Summit.length;
map.addOverlays(Sciota);
centerByArray(Sciota, false, false);
cntMarker += Sciota.length;
map.addOverlays(Stroudsburg);
centerByArray(Stroudsburg, false, false);
cntMarker += Stroudsburg.length;
map.addOverlays(Swiftwater);
centerByArray(Swiftwater, false, false);
cntMarker += Swiftwater.length;
map.addOverlays(Tannersville);
centerByArray(Tannersville, false, false);
cntMarker += Tannersville.length;
map.addOverlays(Tobyhanna);
centerByArray(Tobyhanna, false, false);
cntMarker += Tobyhanna.length;
centerByArray(Stroudsburg,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');
}
}