function addMarkers()
{
mySelect = document.getElementById('selection');
Ebensburg = [];Nanty_Glo = [];Carrolltown = [];Patton = [];Johnstown = [];Cresson = [];Sidman = [];Flinton = [];Northern_Cambria = [];Lilly = [];Gallitzin = [];Portage = [];mySelect.options[mySelect.options.length] = new Option("Carrolltown schools",'all=Carrolltown');
mySelect.options[mySelect.options.length] = new Option("Cresson schools",'all=Cresson');
mySelect.options[mySelect.options.length] = new Option("Ebensburg schools",'all=Ebensburg');
mySelect.options[mySelect.options.length] = new Option("Flinton schools",'all=Flinton');
mySelect.options[mySelect.options.length] = new Option("Gallitzin schools",'all=Gallitzin');
mySelect.options[mySelect.options.length] = new Option("Johnstown schools",'all=Johnstown');
mySelect.options[mySelect.options.length] = new Option("Lilly schools",'all=Lilly');
mySelect.options[mySelect.options.length] = new Option("Nanty Glo schools",'all=Nanty_Glo');
mySelect.options[mySelect.options.length] = new Option("Northern Cambria schools",'all=Northern_Cambria');
mySelect.options[mySelect.options.length] = new Option("Patton schools",'all=Patton');
mySelect.options[mySelect.options.length] = new Option("Portage schools",'all=Portage');
mySelect.options[mySelect.options.length] = new Option("Sidman schools",'all=Sidman');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Ebensburg[Ebensburg.length] = createMarker(new GPoint(-78.76075745,40.49428558),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Admiral Peary Avts",'Ebensburg=' + Ebensburg.length);
Nanty_Glo[Nanty_Glo.length] = createMarker(new GPoint(-78.83255005,40.48436356),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Blacklick Valley El Center",'Nanty_Glo=' + Nanty_Glo.length);
Nanty_Glo[Nanty_Glo.length] = createMarker(new GPoint(-78.83625031,40.47753525),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Blacklick Valley Junior Senior High School",'Nanty_Glo=' + Nanty_Glo.length);
Ebensburg[Ebensburg.length] = createMarker(new GPoint(-78.73999023,40.48952866),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cambria Elementary School",'Ebensburg=' + Ebensburg.length);
Carrolltown[Carrolltown.length] = createMarker(new GPoint(-78.71369934,40.59949875),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cambria Heights Elementary School",'Carrolltown=' + Carrolltown.length);
Patton[Patton.length] = createMarker(new GPoint(-78.62876129,40.63214874),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Cambria Heights Middle School",'Patton=' + Patton.length);
Patton[Patton.length] = createMarker(new GPoint(-78.62814331,40.63259125),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cambria Heights Senior High School",'Patton=' + Patton.length);
Ebensburg[Ebensburg.length] = createMarker(new GPoint(-78.74045563,40.48947906),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central Cambria High School",'Ebensburg=' + Ebensburg.length);
Ebensburg[Ebensburg.length] = createMarker(new GPoint(-78.72641754,40.48993683),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Central Cambria Middle School",'Ebensburg=' + Ebensburg.length);
Johnstown[Johnstown.length] = createMarker(new GPoint(-78.87330627,40.32619095),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Conemaugh Valley Elementary School",'Johnstown=' + Johnstown.length);
Johnstown[Johnstown.length] = createMarker(new GPoint(-78.88927460,40.35905838),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Conemaugh Valley Junior Senior High School",'Johnstown=' + Johnstown.length);
Cresson[Cresson.length] = createMarker(new GPoint(-78.58589935,40.46289825),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cresson Secure Treatment Unit High School",'Cresson=' + Cresson.length);
Johnstown[Johnstown.length] = createMarker(new GPoint(-78.91057587,40.30930328),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("East Side Elementary School",'Johnstown=' + Johnstown.length);
Johnstown[Johnstown.length] = createMarker(new GPoint(-78.88935089,40.35903168),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("East Taylor Elementary School",'Johnstown=' + Johnstown.length);
Johnstown[Johnstown.length] = createMarker(new GPoint(-78.91657257,40.28750610),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ferndale Area Junior Senior High School",'Johnstown=' + Johnstown.length);
Johnstown[Johnstown.length] = createMarker(new GPoint(-78.93052673,40.31764221),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ferndale Elementary School",'Johnstown=' + Johnstown.length);
Sidman[Sidman.length] = createMarker(new GPoint(-78.75488281,40.33308029),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Forest Hills Elementary School",'Sidman=' + Sidman.length);
Sidman[Sidman.length] = createMarker(new GPoint(-78.75662994,40.33334351),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Forest Hills High School",'Sidman=' + Sidman.length);
Sidman[Sidman.length] = createMarker(new GPoint(-78.71936798,40.36106491),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Forest Hills Middle School",'Sidman=' + Sidman.length);
Flinton[Flinton.length] = createMarker(new GPoint(-78.53768158,40.70613861),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Glendale Elementary School",'Flinton=' + Flinton.length);
Flinton[Flinton.length] = createMarker(new GPoint(-78.56179810,40.68181992),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Glendale Junior Senior High School",'Flinton=' + Flinton.length);
Johnstown[Johnstown.length] = createMarker(new GPoint(-78.82905579,40.27153015),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Greater Johnstown Avts",'Johnstown=' + Johnstown.length);
Johnstown[Johnstown.length] = createMarker(new GPoint(-78.94621277,40.35188675),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Greater Johnstown Middle School",'Johnstown=' + Johnstown.length);
Johnstown[Johnstown.length] = createMarker(new GPoint(-78.91089630,40.30315781),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Greater Johnstown Senior High School",'Johnstown=' + Johnstown.length);
Johnstown[Johnstown.length] = createMarker(new GPoint(-78.84410095,40.44105148),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jackson Elementary School",'Johnstown=' + Johnstown.length);
Northern_Cambria[Northern_Cambria.length] = createMarker(new GPoint(-78.78787994,40.65743256),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Northern Cambria Elementary School",'Northern_Cambria=' + Northern_Cambria.length);
Northern_Cambria[Northern_Cambria.length] = createMarker(new GPoint(-78.78022766,40.65554047),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northern Cambria High School",'Northern_Cambria=' + Northern_Cambria.length);
Northern_Cambria[Northern_Cambria.length] = createMarker(new GPoint(-78.78787994,40.65743256),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Northern Cambria Middle School",'Northern_Cambria=' + Northern_Cambria.length);
Cresson[Cresson.length] = createMarker(new GPoint(-78.58413696,40.46440506),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Penn Cambria High School",'Cresson=' + Cresson.length);
Lilly[Lilly.length] = createMarker(new GPoint(-78.63092041,40.41958618),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Penn Cambria Intrmd School",'Lilly=' + Lilly.length);
Gallitzin[Gallitzin.length] = createMarker(new GPoint(-78.55368042,40.47923279),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Penn Cambria Middle School",'Gallitzin=' + Gallitzin.length);
Cresson[Cresson.length] = createMarker(new GPoint(-78.58091736,40.46384811),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Penn Cambria Pre-primary Elementary School",'Cresson=' + Cresson.length);
Lilly[Lilly.length] = createMarker(new GPoint(-78.62062073,40.42444992),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Penn Cambria Primary School",'Lilly=' + Lilly.length);
Portage[Portage.length] = createMarker(new GPoint(-78.66510010,40.38414001),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Portage Area Elementary School",'Portage=' + Portage.length);
Portage[Portage.length] = createMarker(new GPoint(-78.66510773,40.38386536),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Portage Area High School",'Portage=' + Portage.length);
Portage[Portage.length] = createMarker(new GPoint(-78.66510010,40.38414001),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Portage Area Middle School",'Portage=' + Portage.length);
Johnstown[Johnstown.length] = createMarker(new GPoint(-78.83987427,40.26926041),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Richland Elementary School",'Johnstown=' + Johnstown.length);
Johnstown[Johnstown.length] = createMarker(new GPoint(-78.84219360,40.26684189),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Richland Middle School",'Johnstown=' + Johnstown.length);
Johnstown[Johnstown.length] = createMarker(new GPoint(-78.83716583,40.26790619),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Richland Senior High School",'Johnstown=' + Johnstown.length);
Johnstown[Johnstown.length] = createMarker(new GPoint(-78.95220947,40.32754135),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("West Side Elementary School",'Johnstown=' + Johnstown.length);
Johnstown[Johnstown.length] = createMarker(new GPoint(-78.94406891,40.30041885),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Westmont Hilltop Elementary School",'Johnstown=' + Johnstown.length);
Johnstown[Johnstown.length] = createMarker(new GPoint(-78.97756958,40.31738663),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Westmont Hilltop High School",'Johnstown=' + Johnstown.length);
Johnstown[Johnstown.length] = createMarker(new GPoint(-78.94029999,40.31580353),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Westmont Hilltop Middle School",'Johnstown=' + Johnstown.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(Carrolltown);
map.removeOverlays(Cresson);
map.removeOverlays(Ebensburg);
map.removeOverlays(Flinton);
map.removeOverlays(Gallitzin);
map.removeOverlays(Johnstown);
map.removeOverlays(Lilly);
map.removeOverlays(Nanty_Glo);
map.removeOverlays(Northern_Cambria);
map.removeOverlays(Patton);
map.removeOverlays(Portage);
map.removeOverlays(Sidman);
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(Ebensburg);map.removeOverlays(Carrolltown);
map.removeOverlays(Cresson);
map.removeOverlays(Ebensburg);
map.removeOverlays(Flinton);
map.removeOverlays(Gallitzin);
map.removeOverlays(Johnstown);
map.removeOverlays(Lilly);
map.removeOverlays(Nanty_Glo);
map.removeOverlays(Northern_Cambria);
map.removeOverlays(Patton);
map.removeOverlays(Portage);
map.removeOverlays(Sidman);
map.addOverlays(Carrolltown);
centerByArray(Carrolltown, false, false);
cntMarker += Carrolltown.length;
map.addOverlays(Cresson);
centerByArray(Cresson, false, false);
cntMarker += Cresson.length;
map.addOverlays(Ebensburg);
centerByArray(Ebensburg, false, false);
cntMarker += Ebensburg.length;
map.addOverlays(Flinton);
centerByArray(Flinton, false, false);
cntMarker += Flinton.length;
map.addOverlays(Gallitzin);
centerByArray(Gallitzin, false, false);
cntMarker += Gallitzin.length;
map.addOverlays(Johnstown);
centerByArray(Johnstown, false, false);
cntMarker += Johnstown.length;
map.addOverlays(Lilly);
centerByArray(Lilly, false, false);
cntMarker += Lilly.length;
map.addOverlays(Nanty_Glo);
centerByArray(Nanty_Glo, false, false);
cntMarker += Nanty_Glo.length;
map.addOverlays(Northern_Cambria);
centerByArray(Northern_Cambria, false, false);
cntMarker += Northern_Cambria.length;
map.addOverlays(Patton);
centerByArray(Patton, false, false);
cntMarker += Patton.length;
map.addOverlays(Portage);
centerByArray(Portage, false, false);
cntMarker += Portage.length;
map.addOverlays(Sidman);
centerByArray(Sidman, false, false);
cntMarker += Sidman.length;
centerByArray(Ebensburg,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');
}
}