function addMarkers()
{
mySelect = document.getElementById('selection');
Athens = [];Wyalusing = [];Canton = [];Gillett = [];East_Smithfield = [];Sayre = [];Monroeton = [];Towanda = [];New_Albany = [];Rome = [];Ulster = [];Columbia_Cross_Roads = [];Troy = [];Millerton = [];Wysox = [];mySelect.options[mySelect.options.length] = new Option("Athens schools",'all=Athens');
mySelect.options[mySelect.options.length] = new Option("Canton schools",'all=Canton');
mySelect.options[mySelect.options.length] = new Option("Columbia Cross Roads schools",'all=Columbia_Cross_Roads');
mySelect.options[mySelect.options.length] = new Option("East Smithfield schools",'all=East_Smithfield');
mySelect.options[mySelect.options.length] = new Option("Gillett schools",'all=Gillett');
mySelect.options[mySelect.options.length] = new Option("Millerton schools",'all=Millerton');
mySelect.options[mySelect.options.length] = new Option("Monroeton schools",'all=Monroeton');
mySelect.options[mySelect.options.length] = new Option("New Albany schools",'all=New_Albany');
mySelect.options[mySelect.options.length] = new Option("Rome schools",'all=Rome');
mySelect.options[mySelect.options.length] = new Option("Sayre schools",'all=Sayre');
mySelect.options[mySelect.options.length] = new Option("Towanda schools",'all=Towanda');
mySelect.options[mySelect.options.length] = new Option("Troy schools",'all=Troy');
mySelect.options[mySelect.options.length] = new Option("Ulster schools",'all=Ulster');
mySelect.options[mySelect.options.length] = new Option("Wyalusing schools",'all=Wyalusing');
mySelect.options[mySelect.options.length] = new Option("Wysox schools",'all=Wysox');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Athens[Athens.length] = createMarker(new GPoint(-76.52725220,41.97092819),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Athens Area High School",'Athens=' + Athens.length);
Athens[Athens.length] = createMarker(new GPoint(-76.51670837,41.95974731),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Athens Area Middle School",'Athens=' + Athens.length);
Athens[Athens.length] = createMarker(new GPoint(-76.52487946,41.96401978),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Audrielle Lynch-ellen Bustin E Elementary School",'Athens=' + Athens.length);
Wyalusing[Wyalusing.length] = createMarker(new GPoint(-76.27940369,41.69630051),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Camptown Elementary School",'Wyalusing=' + Wyalusing.length);
Canton[Canton.length] = createMarker(new GPoint(-76.84323883,41.65800476),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Canton Area Elementary School",'Canton=' + Canton.length);
Canton[Canton.length] = createMarker(new GPoint(-76.84315491,41.65689850),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Canton Junior Senior High School",'Canton=' + Canton.length);
Gillett[Gillett.length] = createMarker(new GPoint(-76.78029633,41.98550034),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Gladys Burnham Elementary School",'Gillett=' + Gillett.length);
Athens[Athens.length] = createMarker(new GPoint(-76.51828003,41.95690155),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Harlan Rowe Jhs",'Athens=' + Athens.length);
East_Smithfield[East_Smithfield.length] = createMarker(new GPoint(-76.62560272,41.86674118),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Harriet Child Elementary School",'East_Smithfield=' + East_Smithfield.length);
Sayre[Sayre.length] = createMarker(new GPoint(-76.51640320,41.99390030),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Litchfield Township Elementary School",'Sayre=' + Sayre.length);
Athens[Athens.length] = createMarker(new GPoint(-76.51997375,41.96237564),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Main Elementary Annex",'Athens=' + Athens.length);
Monroeton[Monroeton.length] = createMarker(new GPoint(-76.48359680,41.69979858),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Monroe-franklin Elementary School",'Monroeton=' + Monroeton.length);
Towanda[Towanda.length] = createMarker(new GPoint(-76.44823456,41.77210617),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Morrow Elementary School",'Towanda=' + Towanda.length);
Towanda[Towanda.length] = createMarker(new GPoint(-76.44835663,41.76610184),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mulberry Street School",'Towanda=' + Towanda.length);
New_Albany[New_Albany.length] = createMarker(new GPoint(-76.45809937,41.59510040),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("New Albany Elementary School",'New_Albany=' + New_Albany.length);
Rome[Rome.length] = createMarker(new GPoint(-76.30979919,41.89369965),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Northeast Bradford Elementary School",'Rome=' + Rome.length);
Rome[Rome.length] = createMarker(new GPoint(-76.30979919,41.89369965),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northeast Bradford Junior Senior High School",'Rome=' + Rome.length);
Towanda[Towanda.length] = createMarker(new GPoint(-76.44989777,41.78300095),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northern Tier Career Center",'Towanda=' + Towanda.length);
East_Smithfield[East_Smithfield.length] = createMarker(new GPoint(-76.62560272,41.86674118),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("S R U Middle School",'East_Smithfield=' + East_Smithfield.length);
Sayre[Sayre.length] = createMarker(new GPoint(-76.52281952,41.98290634),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sayre Area High School",'Sayre=' + Sayre.length);
Ulster[Ulster.length] = createMarker(new GPoint(-76.48090363,41.84619904),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sheshequin-ulster Elementary School",'Ulster=' + Ulster.length);
Sayre[Sayre.length] = createMarker(new GPoint(-76.53231049,41.98784637),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Snyder Elementary School",'Sayre=' + Sayre.length);
Columbia_Cross_Roads[Columbia_Cross_Roads.length] = createMarker(new GPoint(-76.75460052,41.83219910),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Springfield Township Elementary School",'Columbia_Cross_Roads=' + Columbia_Cross_Roads.length);
Towanda[Towanda.length] = createMarker(new GPoint(-76.44725800,41.76786041),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Towanda Area Middle School",'Towanda=' + Towanda.length);
Towanda[Towanda.length] = createMarker(new GPoint(-76.44851685,41.77282715),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Towanda Area Senior High School",'Towanda=' + Towanda.length);
Towanda[Towanda.length] = createMarker(new GPoint(-76.47699738,41.75350189),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Towanda Township Kdg Complex Elementary School",'Towanda=' + Towanda.length);
Troy[Troy.length] = createMarker(new GPoint(-76.78611755,41.78905869),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Troy Area Middle School",'Troy=' + Troy.length);
Troy[Troy.length] = createMarker(new GPoint(-76.78562927,41.78942108),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Troy Area Senior High School",'Troy=' + Troy.length);
Troy[Troy.length] = createMarker(new GPoint(-76.79640198,41.77519989),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Troy El Center East",'Troy=' + Troy.length);
Troy[Troy.length] = createMarker(new GPoint(-76.79178619,41.78002548),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("W R Croman Elementary School",'Troy=' + Troy.length);
Millerton[Millerton.length] = createMarker(new GPoint(-76.97730255,41.95989990),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wells Township Elementary School",'Millerton=' + Millerton.length);
Wyalusing[Wyalusing.length] = createMarker(new GPoint(-76.27940369,41.69630051),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wyalusing Elementary School",'Wyalusing=' + Wyalusing.length);
Wyalusing[Wyalusing.length] = createMarker(new GPoint(-76.27940369,41.69630051),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wyalusing Valley Junior Senior High School",'Wyalusing=' + Wyalusing.length);
Wysox[Wysox.length] = createMarker(new GPoint(-76.37409973,41.77819824),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wysox Elementary School",'Wysox=' + Wysox.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(Athens);
map.removeOverlays(Canton);
map.removeOverlays(Columbia_Cross_Roads);
map.removeOverlays(East_Smithfield);
map.removeOverlays(Gillett);
map.removeOverlays(Millerton);
map.removeOverlays(Monroeton);
map.removeOverlays(New_Albany);
map.removeOverlays(Rome);
map.removeOverlays(Sayre);
map.removeOverlays(Towanda);
map.removeOverlays(Troy);
map.removeOverlays(Ulster);
map.removeOverlays(Wyalusing);
map.removeOverlays(Wysox);
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(Athens);map.removeOverlays(Athens);
map.removeOverlays(Canton);
map.removeOverlays(Columbia_Cross_Roads);
map.removeOverlays(East_Smithfield);
map.removeOverlays(Gillett);
map.removeOverlays(Millerton);
map.removeOverlays(Monroeton);
map.removeOverlays(New_Albany);
map.removeOverlays(Rome);
map.removeOverlays(Sayre);
map.removeOverlays(Towanda);
map.removeOverlays(Troy);
map.removeOverlays(Ulster);
map.removeOverlays(Wyalusing);
map.removeOverlays(Wysox);
map.addOverlays(Athens);
centerByArray(Athens, false, false);
cntMarker += Athens.length;
map.addOverlays(Canton);
centerByArray(Canton, false, false);
cntMarker += Canton.length;
map.addOverlays(Columbia_Cross_Roads);
centerByArray(Columbia_Cross_Roads, false, false);
cntMarker += Columbia_Cross_Roads.length;
map.addOverlays(East_Smithfield);
centerByArray(East_Smithfield, false, false);
cntMarker += East_Smithfield.length;
map.addOverlays(Gillett);
centerByArray(Gillett, false, false);
cntMarker += Gillett.length;
map.addOverlays(Millerton);
centerByArray(Millerton, false, false);
cntMarker += Millerton.length;
map.addOverlays(Monroeton);
centerByArray(Monroeton, false, false);
cntMarker += Monroeton.length;
map.addOverlays(New_Albany);
centerByArray(New_Albany, false, false);
cntMarker += New_Albany.length;
map.addOverlays(Rome);
centerByArray(Rome, false, false);
cntMarker += Rome.length;
map.addOverlays(Sayre);
centerByArray(Sayre, false, false);
cntMarker += Sayre.length;
map.addOverlays(Towanda);
centerByArray(Towanda, false, false);
cntMarker += Towanda.length;
map.addOverlays(Troy);
centerByArray(Troy, false, false);
cntMarker += Troy.length;
map.addOverlays(Ulster);
centerByArray(Ulster, false, false);
cntMarker += Ulster.length;
map.addOverlays(Wyalusing);
centerByArray(Wyalusing, false, false);
cntMarker += Wyalusing.length;
map.addOverlays(Wysox);
centerByArray(Wysox, false, false);
cntMarker += Wysox.length;
centerByArray(Athens,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');
}
}