function addMarkers()
{
mySelect = document.getElementById('selection');
Linesville = [];Cambridge_Springs = [];Titusville = [];Cochranton = [];Conneaut_Lake = [];Conneautville = [];Meadville = [];Saegertown = [];Jamestown = [];Townville = [];Guys_Mills = [];mySelect.options[mySelect.options.length] = new Option("Cambridge Springs schools",'all=Cambridge_Springs');
mySelect.options[mySelect.options.length] = new Option("Cochranton schools",'all=Cochranton');
mySelect.options[mySelect.options.length] = new Option("Conneaut Lake schools",'all=Conneaut_Lake');
mySelect.options[mySelect.options.length] = new Option("Conneautville schools",'all=Conneautville');
mySelect.options[mySelect.options.length] = new Option("Guys Mills schools",'all=Guys_Mills');
mySelect.options[mySelect.options.length] = new Option("Jamestown schools",'all=Jamestown');
mySelect.options[mySelect.options.length] = new Option("Linesville schools",'all=Linesville');
mySelect.options[mySelect.options.length] = new Option("Meadville schools",'all=Meadville');
mySelect.options[mySelect.options.length] = new Option("Saegertown schools",'all=Saegertown');
mySelect.options[mySelect.options.length] = new Option("Titusville schools",'all=Titusville');
mySelect.options[mySelect.options.length] = new Option("Townville schools",'all=Townville');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Linesville[Linesville.length] = createMarker(new GPoint(-80.41851807,41.65473557),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Alice Schafer Elementary School",'Linesville=' + Linesville.length);
Cambridge_Springs[Cambridge_Springs.length] = createMarker(new GPoint(-80.06545258,41.79952621),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cambridge Springs Elementary School",'Cambridge_Springs=' + Cambridge_Springs.length);
Cambridge_Springs[Cambridge_Springs.length] = createMarker(new GPoint(-80.06266022,41.80199814),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cambridge Springs Junior Senior High School",'Cambridge_Springs=' + Cambridge_Springs.length);
Titusville[Titusville.length] = createMarker(new GPoint(-79.76841736,41.58631897),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cherrytree Elementary School",'Titusville=' + Titusville.length);
Cochranton[Cochranton.length] = createMarker(new GPoint(-80.04092407,41.51105118),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cochranton Elementary School",'Cochranton=' + Cochranton.length);
Cochranton[Cochranton.length] = createMarker(new GPoint(-80.04070282,41.52199936),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cochranton Junior Senior High School",'Cochranton=' + Cochranton.length);
Conneaut_Lake[Conneaut_Lake.length] = createMarker(new GPoint(-80.32880402,41.60887527),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Conneaut Lake High School",'Conneaut_Lake=' + Conneaut_Lake.length);
Conneaut_Lake[Conneaut_Lake.length] = createMarker(new GPoint(-80.30799866,41.60459900),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Conneaut Lake-sadsbury Elementary School",'Conneaut_Lake=' + Conneaut_Lake.length);
Conneautville[Conneautville.length] = createMarker(new GPoint(-80.36428070,41.77869415),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Conneaut Valley Elementary School",'Conneautville=' + Conneautville.length);
Conneautville[Conneautville.length] = createMarker(new GPoint(-80.36411285,41.77599335),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Conneaut Valley High School",'Conneautville=' + Conneautville.length);
Meadville[Meadville.length] = createMarker(new GPoint(-80.15470123,41.63119888),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Crawford County Avts",'Meadville=' + Meadville.length);
Saegertown[Saegertown.length] = createMarker(new GPoint(-80.21965790,41.80026627),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cussewago Elementary School",'Saegertown=' + Saegertown.length);
Titusville[Titusville.length] = createMarker(new GPoint(-79.66839600,41.63086319),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Early Childhood Learning Center",'Titusville=' + Titusville.length);
Meadville[Meadville.length] = createMarker(new GPoint(-80.13829803,41.63681793),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("East End Elementary School",'Meadville=' + Meadville.length);
Meadville[Meadville.length] = createMarker(new GPoint(-80.13521576,41.66649246),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("First District Elementary School",'Meadville=' + Meadville.length);
Conneaut_Lake[Conneaut_Lake.length] = createMarker(new GPoint(-80.29351807,41.57840347),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Greenwood Elementary School",'Conneaut_Lake=' + Conneaut_Lake.length);
Titusville[Titusville.length] = createMarker(new GPoint(-79.72013092,41.64551926),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hydetown Elementary School",'Titusville=' + Titusville.length);
Jamestown[Jamestown.length] = createMarker(new GPoint(-80.47070312,41.52259827),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jamestown Area Elementary School",'Jamestown=' + Jamestown.length);
Linesville[Linesville.length] = createMarker(new GPoint(-80.41906738,41.65473557),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Linesville-conneaut-summit High School",'Linesville=' + Linesville.length);
Titusville[Titusville.length] = createMarker(new GPoint(-79.67382812,41.62816238),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Main Street Elementary School",'Titusville=' + Titusville.length);
Townville[Townville.length] = createMarker(new GPoint(-79.89334106,41.68476486),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Maplewood Elementary School",'Townville=' + Townville.length);
Guys_Mills[Guys_Mills.length] = createMarker(new GPoint(-79.91816711,41.66730118),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Maplewood Junior Senior High School",'Guys_Mills=' + Guys_Mills.length);
Meadville[Meadville.length] = createMarker(new GPoint(-80.12847137,41.63554001),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Meadville Area Senior High School",'Meadville=' + Meadville.length);
Meadville[Meadville.length] = createMarker(new GPoint(-80.12645721,41.63517380),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Meadville Middle School",'Meadville=' + Meadville.length);
Meadville[Meadville.length] = createMarker(new GPoint(-80.13674164,41.62098312),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Neason Hill Elementary School",'Meadville=' + Meadville.length);
Saegertown[Saegertown.length] = createMarker(new GPoint(-80.16603088,41.72456360),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Saegertown Elementary School",'Saegertown=' + Saegertown.length);
Saegertown[Saegertown.length] = createMarker(new GPoint(-80.16522217,41.71991348),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Saegertown Junior Senior High School",'Saegertown=' + Saegertown.length);
Meadville[Meadville.length] = createMarker(new GPoint(-80.15346527,41.63007736),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Second District Elementary School",'Meadville=' + Meadville.length);
Titusville[Titusville.length] = createMarker(new GPoint(-79.72628021,41.65159988),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Titusville Middle School",'Titusville=' + Titusville.length);
Titusville[Titusville.length] = createMarker(new GPoint(-79.66938782,41.62964630),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Titusville Senior High School",'Titusville=' + Titusville.length);
Meadville[Meadville.length] = createMarker(new GPoint(-80.23680115,41.63288879),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("West End Elementary School",'Meadville=' + Meadville.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(Cambridge_Springs);
map.removeOverlays(Cochranton);
map.removeOverlays(Conneaut_Lake);
map.removeOverlays(Conneautville);
map.removeOverlays(Guys_Mills);
map.removeOverlays(Jamestown);
map.removeOverlays(Linesville);
map.removeOverlays(Meadville);
map.removeOverlays(Saegertown);
map.removeOverlays(Titusville);
map.removeOverlays(Townville);
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(Linesville);map.removeOverlays(Cambridge_Springs);
map.removeOverlays(Cochranton);
map.removeOverlays(Conneaut_Lake);
map.removeOverlays(Conneautville);
map.removeOverlays(Guys_Mills);
map.removeOverlays(Jamestown);
map.removeOverlays(Linesville);
map.removeOverlays(Meadville);
map.removeOverlays(Saegertown);
map.removeOverlays(Titusville);
map.removeOverlays(Townville);
map.addOverlays(Cambridge_Springs);
centerByArray(Cambridge_Springs, false, false);
cntMarker += Cambridge_Springs.length;
map.addOverlays(Cochranton);
centerByArray(Cochranton, false, false);
cntMarker += Cochranton.length;
map.addOverlays(Conneaut_Lake);
centerByArray(Conneaut_Lake, false, false);
cntMarker += Conneaut_Lake.length;
map.addOverlays(Conneautville);
centerByArray(Conneautville, false, false);
cntMarker += Conneautville.length;
map.addOverlays(Guys_Mills);
centerByArray(Guys_Mills, false, false);
cntMarker += Guys_Mills.length;
map.addOverlays(Jamestown);
centerByArray(Jamestown, false, false);
cntMarker += Jamestown.length;
map.addOverlays(Linesville);
centerByArray(Linesville, false, false);
cntMarker += Linesville.length;
map.addOverlays(Meadville);
centerByArray(Meadville, false, false);
cntMarker += Meadville.length;
map.addOverlays(Saegertown);
centerByArray(Saegertown, false, false);
cntMarker += Saegertown.length;
map.addOverlays(Titusville);
centerByArray(Titusville, false, false);
cntMarker += Titusville.length;
map.addOverlays(Townville);
centerByArray(Townville, false, false);
cntMarker += Townville.length;
centerByArray(Linesville,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');
}
}