function addMarkers()
{
mySelect = document.getElementById('selection');
Bigler = [];Clearfield = [];Curwensville = [];Du_Bois = [];Frenchville = [];Westover = [];Luthersburg = [];Houtzdale = [];Philipsburg = [];Osceola_Mills = [];Penfield = [];Grampian = [];Mahaffey = [];Wallaceton = [];Morrisdale = [];mySelect.options[mySelect.options.length] = new Option("Bigler schools",'all=Bigler');
mySelect.options[mySelect.options.length] = new Option("Clearfield schools",'all=Clearfield');
mySelect.options[mySelect.options.length] = new Option("Curwensville schools",'all=Curwensville');
mySelect.options[mySelect.options.length] = new Option("Du Bois schools",'all=Du_Bois');
mySelect.options[mySelect.options.length] = new Option("Frenchville schools",'all=Frenchville');
mySelect.options[mySelect.options.length] = new Option("Grampian schools",'all=Grampian');
mySelect.options[mySelect.options.length] = new Option("Houtzdale schools",'all=Houtzdale');
mySelect.options[mySelect.options.length] = new Option("Luthersburg schools",'all=Luthersburg');
mySelect.options[mySelect.options.length] = new Option("Mahaffey schools",'all=Mahaffey');
mySelect.options[mySelect.options.length] = new Option("Morrisdale schools",'all=Morrisdale');
mySelect.options[mySelect.options.length] = new Option("Osceola Mills schools",'all=Osceola_Mills');
mySelect.options[mySelect.options.length] = new Option("Penfield schools",'all=Penfield');
mySelect.options[mySelect.options.length] = new Option("Philipsburg schools",'all=Philipsburg');
mySelect.options[mySelect.options.length] = new Option("Wallaceton schools",'all=Wallaceton');
mySelect.options[mySelect.options.length] = new Option("Westover schools",'all=Westover');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Bigler[Bigler.length] = createMarker(new GPoint(-78.43869781,41.02809906),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bradford Township Elementary School",'Bigler=' + Bigler.length);
Clearfield[Clearfield.length] = createMarker(new GPoint(-78.43869781,41.02809906),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Centre Elementary School",'Clearfield=' + Clearfield.length);
Clearfield[Clearfield.length] = createMarker(new GPoint(-78.43869781,41.02809906),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Clearfield Area High School",'Clearfield=' + Clearfield.length);
Clearfield[Clearfield.length] = createMarker(new GPoint(-78.43869781,41.02809906),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Clearfield Area Middle School",'Clearfield=' + Clearfield.length);
Clearfield[Clearfield.length] = createMarker(new GPoint(-78.42823792,41.03327942),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Clearfield County Ctc",'Clearfield=' + Clearfield.length);
Clearfield[Clearfield.length] = createMarker(new GPoint(-78.43821716,41.03623962),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clearfield Elementary School",'Clearfield=' + Clearfield.length);
Curwensville[Curwensville.length] = createMarker(new GPoint(-78.52095795,40.96823120),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Curwensville Area Elementary School",'Curwensville=' + Curwensville.length);
Curwensville[Curwensville.length] = createMarker(new GPoint(-78.52095795,40.96823120),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Curwensville Area Junior Senior High School",'Curwensville=' + Curwensville.length);
Du_Bois[Du_Bois.length] = createMarker(new GPoint(-78.75831604,41.12171555),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Dubois Area Middle School",'Du_Bois=' + Du_Bois.length);
Du_Bois[Du_Bois.length] = createMarker(new GPoint(-78.74485779,41.12606430),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Dubois Area Senior High School",'Du_Bois=' + Du_Bois.length);
Clearfield[Clearfield.length] = createMarker(new GPoint(-78.43869781,41.02809906),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Girard Elementary School",'Clearfield=' + Clearfield.length);
Frenchville[Frenchville.length] = createMarker(new GPoint(-78.28337860,41.08316040),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Girard-goshen Elementary School",'Frenchville=' + Frenchville.length);
Clearfield[Clearfield.length] = createMarker(new GPoint(-78.43869781,41.02809906),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Goshen Elementary School",'Clearfield=' + Clearfield.length);
Westover[Westover.length] = createMarker(new GPoint(-78.73300171,40.77190018),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Harmony Area Elementary School",'Westover=' + Westover.length);
Westover[Westover.length] = createMarker(new GPoint(-78.73300171,40.77190018),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Harmony Area High School",'Westover=' + Westover.length);
Westover[Westover.length] = createMarker(new GPoint(-78.67800400,40.74375000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Harmony Area MiddleSchool",'Westover=' + Westover.length);
Du_Bois[Du_Bois.length] = createMarker(new GPoint(-78.73310089,41.10210037),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Highland Street Elementary School",'Du_Bois=' + Du_Bois.length);
Du_Bois[Du_Bois.length] = createMarker(new GPoint(-78.75942993,41.12994766),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Juniata Elementary School",'Du_Bois=' + Du_Bois.length);
Luthersburg[Luthersburg.length] = createMarker(new GPoint(-78.71923065,41.05329895),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Luthersburg Elementary School",'Luthersburg=' + Luthersburg.length);
Houtzdale[Houtzdale.length] = createMarker(new GPoint(-78.38449860,40.82830048),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Moshannon Valley Elementary School",'Houtzdale=' + Houtzdale.length);
Houtzdale[Houtzdale.length] = createMarker(new GPoint(-78.38449860,40.82830048),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Moshannon Valley Junior Senior High School",'Houtzdale=' + Houtzdale.length);
Philipsburg[Philipsburg.length] = createMarker(new GPoint(-78.23574829,40.88776398),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("North Lincoln Hill Elementary School",'Philipsburg=' + Philipsburg.length);
Du_Bois[Du_Bois.length] = createMarker(new GPoint(-78.75335693,41.13037872),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Oklahoma Elementary School",'Du_Bois=' + Du_Bois.length);
Osceola_Mills[Osceola_Mills.length] = createMarker(new GPoint(-78.27332306,40.85203934),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Osceola Mills Elementary School",'Osceola_Mills=' + Osceola_Mills.length);
Penfield[Penfield.length] = createMarker(new GPoint(-78.56839752,41.20909882),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Penfield Elementary School",'Penfield=' + Penfield.length);
Grampian[Grampian.length] = createMarker(new GPoint(-78.61849976,40.96760178),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Penn-grampian Elementary School",'Grampian=' + Grampian.length);
Philipsburg[Philipsburg.length] = createMarker(new GPoint(-78.21575165,40.89979172),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Philipsburg Elementary School",'Philipsburg=' + Philipsburg.length);
Mahaffey[Mahaffey.length] = createMarker(new GPoint(-78.79868317,40.86701965),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Purchase Line North Elementary School",'Mahaffey=' + Mahaffey.length);
Wallaceton[Wallaceton.length] = createMarker(new GPoint(-78.28678131,40.95806122),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wallaceton-boggs Elementary School",'Wallaceton=' + Wallaceton.length);
Du_Bois[Du_Bois.length] = createMarker(new GPoint(-78.77426910,41.10765457),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wasson Avenue Elementary School",'Du_Bois=' + Du_Bois.length);
Morrisdale[Morrisdale.length] = createMarker(new GPoint(-78.20480347,40.98120117),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("West Branch Area Elementary School",'Morrisdale=' + Morrisdale.length);
Morrisdale[Morrisdale.length] = createMarker(new GPoint(-78.20480347,40.98120117),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West Branch Area Junior Senior High School",'Morrisdale=' + Morrisdale.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(Bigler);
map.removeOverlays(Clearfield);
map.removeOverlays(Curwensville);
map.removeOverlays(Du_Bois);
map.removeOverlays(Frenchville);
map.removeOverlays(Grampian);
map.removeOverlays(Houtzdale);
map.removeOverlays(Luthersburg);
map.removeOverlays(Mahaffey);
map.removeOverlays(Morrisdale);
map.removeOverlays(Osceola_Mills);
map.removeOverlays(Penfield);
map.removeOverlays(Philipsburg);
map.removeOverlays(Wallaceton);
map.removeOverlays(Westover);
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(Bigler);map.removeOverlays(Bigler);
map.removeOverlays(Clearfield);
map.removeOverlays(Curwensville);
map.removeOverlays(Du_Bois);
map.removeOverlays(Frenchville);
map.removeOverlays(Grampian);
map.removeOverlays(Houtzdale);
map.removeOverlays(Luthersburg);
map.removeOverlays(Mahaffey);
map.removeOverlays(Morrisdale);
map.removeOverlays(Osceola_Mills);
map.removeOverlays(Penfield);
map.removeOverlays(Philipsburg);
map.removeOverlays(Wallaceton);
map.removeOverlays(Westover);
map.addOverlays(Bigler);
centerByArray(Bigler, false, false);
cntMarker += Bigler.length;
map.addOverlays(Clearfield);
centerByArray(Clearfield, false, false);
cntMarker += Clearfield.length;
map.addOverlays(Curwensville);
centerByArray(Curwensville, false, false);
cntMarker += Curwensville.length;
map.addOverlays(Du_Bois);
centerByArray(Du_Bois, false, false);
cntMarker += Du_Bois.length;
map.addOverlays(Frenchville);
centerByArray(Frenchville, false, false);
cntMarker += Frenchville.length;
map.addOverlays(Grampian);
centerByArray(Grampian, false, false);
cntMarker += Grampian.length;
map.addOverlays(Houtzdale);
centerByArray(Houtzdale, false, false);
cntMarker += Houtzdale.length;
map.addOverlays(Luthersburg);
centerByArray(Luthersburg, false, false);
cntMarker += Luthersburg.length;
map.addOverlays(Mahaffey);
centerByArray(Mahaffey, false, false);
cntMarker += Mahaffey.length;
map.addOverlays(Morrisdale);
centerByArray(Morrisdale, false, false);
cntMarker += Morrisdale.length;
map.addOverlays(Osceola_Mills);
centerByArray(Osceola_Mills, false, false);
cntMarker += Osceola_Mills.length;
map.addOverlays(Penfield);
centerByArray(Penfield, false, false);
cntMarker += Penfield.length;
map.addOverlays(Philipsburg);
centerByArray(Philipsburg, false, false);
cntMarker += Philipsburg.length;
map.addOverlays(Wallaceton);
centerByArray(Wallaceton, false, false);
cntMarker += Wallaceton.length;
map.addOverlays(Westover);
centerByArray(Westover, false, false);
cntMarker += Westover.length;
centerByArray(Bigler,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');
}
}