function addMarkers()
{
mySelect = document.getElementById('selection');
Mars = [];Butler = [];Bruin = [];Sarver = [];Chicora = [];Fenelton = [];Saxonburg = [];Renfrew = [];Zelienople = [];West_Sunbury = [];Evans_City = [];Cranberry_Twp = [];Harrisville = [];Karns_City = [];Valencia = [];Prospect = [];Harmony = [];Slippery_Rock = [];Parker = [];Cabot = [];mySelect.options[mySelect.options.length] = new Option("Bruin schools",'all=Bruin');
mySelect.options[mySelect.options.length] = new Option("Butler schools",'all=Butler');
mySelect.options[mySelect.options.length] = new Option("Cabot schools",'all=Cabot');
mySelect.options[mySelect.options.length] = new Option("Chicora schools",'all=Chicora');
mySelect.options[mySelect.options.length] = new Option("Cranberry Twp schools",'all=Cranberry_Twp');
mySelect.options[mySelect.options.length] = new Option("Evans City schools",'all=Evans_City');
mySelect.options[mySelect.options.length] = new Option("Fenelton schools",'all=Fenelton');
mySelect.options[mySelect.options.length] = new Option("Harmony schools",'all=Harmony');
mySelect.options[mySelect.options.length] = new Option("Harrisville schools",'all=Harrisville');
mySelect.options[mySelect.options.length] = new Option("Karns City schools",'all=Karns_City');
mySelect.options[mySelect.options.length] = new Option("Mars schools",'all=Mars');
mySelect.options[mySelect.options.length] = new Option("Parker schools",'all=Parker');
mySelect.options[mySelect.options.length] = new Option("Prospect schools",'all=Prospect');
mySelect.options[mySelect.options.length] = new Option("Renfrew schools",'all=Renfrew');
mySelect.options[mySelect.options.length] = new Option("Sarver schools",'all=Sarver');
mySelect.options[mySelect.options.length] = new Option("Saxonburg schools",'all=Saxonburg');
mySelect.options[mySelect.options.length] = new Option("Slippery Rock schools",'all=Slippery_Rock');
mySelect.options[mySelect.options.length] = new Option("Valencia schools",'all=Valencia');
mySelect.options[mySelect.options.length] = new Option("West Sunbury schools",'all=West_Sunbury');
mySelect.options[mySelect.options.length] = new Option("Zelienople schools",'all=Zelienople');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Mars[Mars.length] = createMarker(new GPoint(-79.98615265,40.69413757),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Adams Elementary School",'Mars=' + Mars.length);
Butler[Butler.length] = createMarker(new GPoint(-79.90229034,40.86252594),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Broad St School",'Butler=' + Butler.length);
Bruin[Bruin.length] = createMarker(new GPoint(-79.72638702,41.06092834),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bruin Elementary School",'Bruin=' + Bruin.length);
Sarver[Sarver.length] = createMarker(new GPoint(-79.75561523,40.72296143),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Buffalo Elementary School",'Sarver=' + Sarver.length);
Butler[Butler.length] = createMarker(new GPoint(-79.91587067,40.86091232),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Butler Area Ihs",'Butler=' + Butler.length);
Butler[Butler.length] = createMarker(new GPoint(-79.89344025,40.86230087),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Butler Area Junior High School",'Butler=' + Butler.length);
Butler[Butler.length] = createMarker(new GPoint(-79.91978455,40.86598206),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Butler Area Senior High School",'Butler=' + Butler.length);
Butler[Butler.length] = createMarker(new GPoint(-79.91648102,40.86396027),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Butler County Avts",'Butler=' + Butler.length);
Butler[Butler.length] = createMarker(new GPoint(-79.88839722,40.85490036),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Center Avenue School",'Butler=' + Butler.length);
Butler[Butler.length] = createMarker(new GPoint(-79.92897034,40.90574265),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Center Township School",'Butler=' + Butler.length);
Chicora[Chicora.length] = createMarker(new GPoint(-79.73851013,40.95095062),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Chicora Elementary School",'Chicora=' + Chicora.length);
Fenelton[Fenelton.length] = createMarker(new GPoint(-79.72829437,40.85535431),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clearfield Elementary School",'Fenelton=' + Fenelton.length);
Saxonburg[Saxonburg.length] = createMarker(new GPoint(-79.84139252,40.72077942),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clinton Elementary School",'Saxonburg=' + Saxonburg.length);
Renfrew[Renfrew.length] = createMarker(new GPoint(-80.01133728,40.82396317),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Connoquenessing Elementary School",'Renfrew=' + Renfrew.length);
Zelienople[Zelienople.length] = createMarker(new GPoint(-80.12759399,40.79338455),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Connoquenessing Valley Elementary School",'Zelienople=' + Zelienople.length);
West_Sunbury[West_Sunbury.length] = createMarker(new GPoint(-79.88114929,41.00044250),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dassa Mckinney Elementary School",'West_Sunbury=' + West_Sunbury.length);
Butler[Butler.length] = createMarker(new GPoint(-79.89707947,40.86463928),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Emily Brittain Elementary School",'Butler=' + Butler.length);
Evans_City[Evans_City.length] = createMarker(new GPoint(-80.06900024,40.76974869),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Evans City Elementary School",'Evans_City=' + Evans_City.length);
Evans_City[Evans_City.length] = createMarker(new GPoint(-80.06900024,40.76974869),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Evans City Middle School",'Evans_City=' + Evans_City.length);
Cranberry_Twp[Cranberry_Twp.length] = createMarker(new GPoint(-80.12599945,40.69533539),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Haine Elementary School",'Cranberry_Twp=' + Cranberry_Twp.length);
Cranberry_Twp[Cranberry_Twp.length] = createMarker(new GPoint(-79.71043396,41.34944153),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Haine Middle School",'Cranberry_Twp=' + Cranberry_Twp.length);
Harrisville[Harrisville.length] = createMarker(new GPoint(-80.00933838,41.13570023),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Har-mer Elementary School",'Harrisville=' + Harrisville.length);
Butler[Butler.length] = createMarker(new GPoint(-79.84975433,40.80187225),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'Butler=' + Butler.length);
Karns_City[Karns_City.length] = createMarker(new GPoint(-79.72589111,40.98765945),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Karns City High School",'Karns_City=' + Karns_City.length);
Saxonburg[Saxonburg.length] = createMarker(new GPoint(-79.82768250,40.74686813),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Knoch High School",'Saxonburg=' + Saxonburg.length);
Saxonburg[Saxonburg.length] = createMarker(new GPoint(-79.83300018,40.75126266),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Knoch Middle School",'Saxonburg=' + Saxonburg.length);
Mars[Mars.length] = createMarker(new GPoint(-79.97697449,40.69676971),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mars Area Middle School",'Mars=' + Mars.length);
Mars[Mars.length] = createMarker(new GPoint(-79.98148346,40.69279480),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mars Area Senior High School",'Mars=' + Mars.length);
Mars[Mars.length] = createMarker(new GPoint(-79.98651886,40.69413757),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mars Primary Center",'Mars=' + Mars.length);
Butler[Butler.length] = createMarker(new GPoint(-79.88896179,40.84487915),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mcquistion Elementary School",'Butler=' + Butler.length);
Butler[Butler.length] = createMarker(new GPoint(-79.96161652,40.85121918),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Meridian School",'Butler=' + Butler.length);
Valencia[Valencia.length] = createMarker(new GPoint(-79.92837524,40.71342087),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Middlesex Elementary School",'Valencia=' + Valencia.length);
West_Sunbury[West_Sunbury.length] = createMarker(new GPoint(-79.90087891,41.05831146),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Moniteau Junior Senior High School",'West_Sunbury=' + West_Sunbury.length);
Prospect[Prospect.length] = createMarker(new GPoint(-80.04326630,40.90456390),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Moraine Elementary School",'Prospect=' + Prospect.length);
Butler[Butler.length] = createMarker(new GPoint(-79.93817139,40.86979675),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Northwest School",'Butler=' + Butler.length);
Butler[Butler.length] = createMarker(new GPoint(-79.81873322,40.90220261),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Oakland Township School",'Butler=' + Butler.length);
Butler[Butler.length] = createMarker(new GPoint(-79.93710327,40.77997208),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Penn Elementary School",'Butler=' + Butler.length);
Cranberry_Twp[Cranberry_Twp.length] = createMarker(new GPoint(-80.09606934,40.70405960),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Rowan Elementary School",'Cranberry_Twp=' + Cranberry_Twp.length);
Harmony[Harmony.length] = createMarker(new GPoint(-80.10710144,40.80948639),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Seneca Valley Ihs",'Harmony=' + Harmony.length);
Harmony[Harmony.length] = createMarker(new GPoint(-80.10739899,40.80963898),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Seneca Valley Middle School",'Harmony=' + Harmony.length);
Harmony[Harmony.length] = createMarker(new GPoint(-80.12788600,40.79964200),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Seneca Valley MiddleSchool",'Harmony=' + Harmony.length);
Harmony[Harmony.length] = createMarker(new GPoint(-80.10694885,40.80941391),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Seneca Valley Senior High School",'Harmony=' + Harmony.length);
Slippery_Rock[Slippery_Rock.length] = createMarker(new GPoint(-80.06451416,41.07089615),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Slippery Rock Area Elementary School",'Slippery_Rock=' + Slippery_Rock.length);
Slippery_Rock[Slippery_Rock.length] = createMarker(new GPoint(-80.04304504,41.05866241),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Slippery Rock Area High School",'Slippery_Rock=' + Slippery_Rock.length);
Slippery_Rock[Slippery_Rock.length] = createMarker(new GPoint(-80.04304504,41.05866241),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Slippery Rock Area Middle School",'Slippery_Rock=' + Slippery_Rock.length);
Saxonburg[Saxonburg.length] = createMarker(new GPoint(-79.82737732,40.74645996),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("South Butler Intermediate El S",'Saxonburg=' + Saxonburg.length);
Saxonburg[Saxonburg.length] = createMarker(new GPoint(-79.82750702,40.74554825),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South Butler Primary School",'Saxonburg=' + Saxonburg.length);
Butler[Butler.length] = createMarker(new GPoint(-79.82836914,40.84033966),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Summit Elementary School",'Butler=' + Butler.length);
Parker[Parker.length] = createMarker(new GPoint(-79.79139709,41.09138870),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Washington Elementary School",'Parker=' + Parker.length);
Cabot[Cabot.length] = createMarker(new GPoint(-79.75746155,40.77463531),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Winfield Elementary School",'Cabot=' + Cabot.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(Bruin);
map.removeOverlays(Butler);
map.removeOverlays(Cabot);
map.removeOverlays(Chicora);
map.removeOverlays(Cranberry_Twp);
map.removeOverlays(Evans_City);
map.removeOverlays(Fenelton);
map.removeOverlays(Harmony);
map.removeOverlays(Harrisville);
map.removeOverlays(Karns_City);
map.removeOverlays(Mars);
map.removeOverlays(Parker);
map.removeOverlays(Prospect);
map.removeOverlays(Renfrew);
map.removeOverlays(Sarver);
map.removeOverlays(Saxonburg);
map.removeOverlays(Slippery_Rock);
map.removeOverlays(Valencia);
map.removeOverlays(West_Sunbury);
map.removeOverlays(Zelienople);
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(Mars);map.removeOverlays(Bruin);
map.removeOverlays(Butler);
map.removeOverlays(Cabot);
map.removeOverlays(Chicora);
map.removeOverlays(Cranberry_Twp);
map.removeOverlays(Evans_City);
map.removeOverlays(Fenelton);
map.removeOverlays(Harmony);
map.removeOverlays(Harrisville);
map.removeOverlays(Karns_City);
map.removeOverlays(Mars);
map.removeOverlays(Parker);
map.removeOverlays(Prospect);
map.removeOverlays(Renfrew);
map.removeOverlays(Sarver);
map.removeOverlays(Saxonburg);
map.removeOverlays(Slippery_Rock);
map.removeOverlays(Valencia);
map.removeOverlays(West_Sunbury);
map.removeOverlays(Zelienople);
map.addOverlays(Bruin);
centerByArray(Bruin, false, false);
cntMarker += Bruin.length;
map.addOverlays(Butler);
centerByArray(Butler, false, false);
cntMarker += Butler.length;
map.addOverlays(Cabot);
centerByArray(Cabot, false, false);
cntMarker += Cabot.length;
map.addOverlays(Chicora);
centerByArray(Chicora, false, false);
cntMarker += Chicora.length;
map.addOverlays(Cranberry_Twp);
centerByArray(Cranberry_Twp, false, false);
cntMarker += Cranberry_Twp.length;
map.addOverlays(Evans_City);
centerByArray(Evans_City, false, false);
cntMarker += Evans_City.length;
map.addOverlays(Fenelton);
centerByArray(Fenelton, false, false);
cntMarker += Fenelton.length;
map.addOverlays(Harmony);
centerByArray(Harmony, false, false);
cntMarker += Harmony.length;
map.addOverlays(Harrisville);
centerByArray(Harrisville, false, false);
cntMarker += Harrisville.length;
map.addOverlays(Karns_City);
centerByArray(Karns_City, false, false);
cntMarker += Karns_City.length;
map.addOverlays(Mars);
centerByArray(Mars, false, false);
cntMarker += Mars.length;
map.addOverlays(Parker);
centerByArray(Parker, false, false);
cntMarker += Parker.length;
map.addOverlays(Prospect);
centerByArray(Prospect, false, false);
cntMarker += Prospect.length;
map.addOverlays(Renfrew);
centerByArray(Renfrew, false, false);
cntMarker += Renfrew.length;
map.addOverlays(Sarver);
centerByArray(Sarver, false, false);
cntMarker += Sarver.length;
map.addOverlays(Saxonburg);
centerByArray(Saxonburg, false, false);
cntMarker += Saxonburg.length;
map.addOverlays(Slippery_Rock);
centerByArray(Slippery_Rock, false, false);
cntMarker += Slippery_Rock.length;
map.addOverlays(Valencia);
centerByArray(Valencia, false, false);
cntMarker += Valencia.length;
map.addOverlays(West_Sunbury);
centerByArray(West_Sunbury, false, false);
cntMarker += West_Sunbury.length;
map.addOverlays(Zelienople);
centerByArray(Zelienople, false, false);
cntMarker += Zelienople.length;
centerByArray(Mars,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');
}
}