function addMarkers()
{
mySelect = document.getElementById('selection');
South_Webster = [];Portsmouth = [];New_Boston = [];Franklin_Furnace = [];Sciotoville = [];Minford = [];Mc_Dermott = [];West_Portsmouth = [];Lucasville = [];Wheelersburg = [];mySelect.options[mySelect.options.length] = new Option("Franklin Furnace schools",'all=Franklin_Furnace');
mySelect.options[mySelect.options.length] = new Option("Lucasville schools",'all=Lucasville');
mySelect.options[mySelect.options.length] = new Option("Mc Dermott schools",'all=Mc_Dermott');
mySelect.options[mySelect.options.length] = new Option("Minford schools",'all=Minford');
mySelect.options[mySelect.options.length] = new Option("New Boston schools",'all=New_Boston');
mySelect.options[mySelect.options.length] = new Option("Portsmouth schools",'all=Portsmouth');
mySelect.options[mySelect.options.length] = new Option("Sciotoville schools",'all=Sciotoville');
mySelect.options[mySelect.options.length] = new Option("South Webster schools",'all=South_Webster');
mySelect.options[mySelect.options.length] = new Option("West Portsmouth schools",'all=West_Portsmouth');
mySelect.options[mySelect.options.length] = new Option("Wheelersburg schools",'all=Wheelersburg');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
South_Webster[South_Webster.length] = createMarker(new GPoint(-82.72229767,38.81610107),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bloom-vernon Elementary School",'South_Webster=' + South_Webster.length);
Portsmouth[Portsmouth.length] = createMarker(new GPoint(-82.98238373,38.80441666),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Clay High School",'Portsmouth=' + Portsmouth.length);
New_Boston[New_Boston.length] = createMarker(new GPoint(-82.93576813,38.75428391),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Glenwood High School",'New_Boston=' + New_Boston.length);
Franklin_Furnace[Franklin_Furnace.length] = createMarker(new GPoint(-82.84530640,38.61716461),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Green Elementary School",'Franklin_Furnace=' + Franklin_Furnace.length);
Franklin_Furnace[Franklin_Furnace.length] = createMarker(new GPoint(-82.84273529,38.61725998),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Green High School",'Franklin_Furnace=' + Franklin_Furnace.length);
Franklin_Furnace[Franklin_Furnace.length] = createMarker(new GPoint(-82.84530640,38.61716461),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Green Primary Elementary School",'Franklin_Furnace=' + Franklin_Furnace.length);
Sciotoville[Sciotoville.length] = createMarker(new GPoint(-82.88401794,38.76757050),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Harding Elementary School",'Sciotoville=' + Sciotoville.length);
Portsmouth[Portsmouth.length] = createMarker(new GPoint(-82.97837830,38.74270248),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Highland Elementary School",'Portsmouth=' + Portsmouth.length);
Portsmouth[Portsmouth.length] = createMarker(new GPoint(-82.98974609,38.74710846),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Portsmouth=' + Portsmouth.length);
Portsmouth[Portsmouth.length] = createMarker(new GPoint(-82.97883606,38.74770355),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mckinley Elementary School",'Portsmouth=' + Portsmouth.length);
Minford[Minford.length] = createMarker(new GPoint(-82.85874900,38.86041800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Minford High School",'Minford=' + Minford.length);
Minford[Minford.length] = createMarker(new GPoint(-82.84269714,38.87730026),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Minford Middle School",'Minford=' + Minford.length);
Minford[Minford.length] = createMarker(new GPoint(-82.84269714,38.87730026),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Minford Primary Elementary School",'Minford=' + Minford.length);
Mc_Dermott[Mc_Dermott.length] = createMarker(new GPoint(-83.08438873,38.87717056),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Northwest Elementary School",'Mc_Dermott=' + Mc_Dermott.length);
Mc_Dermott[Mc_Dermott.length] = createMarker(new GPoint(-83.08161926,38.87908173),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northwest High School",'Mc_Dermott=' + Mc_Dermott.length);
Mc_Dermott[Mc_Dermott.length] = createMarker(new GPoint(-83.08484650,38.88097382),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Northwest Middle School",'Mc_Dermott=' + Mc_Dermott.length);
New_Boston[New_Boston.length] = createMarker(new GPoint(-82.93289185,38.75811386),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Oak Intermediate Elementary School",'New_Boston=' + New_Boston.length);
Portsmouth[Portsmouth.length] = createMarker(new GPoint(-82.99047852,38.73464966),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Portsmouth High School",'Portsmouth=' + Portsmouth.length);
West_Portsmouth[West_Portsmouth.length] = createMarker(new GPoint(-83.05095673,38.71837997),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Portsmouth West Elementary School",'West_Portsmouth=' + West_Portsmouth.length);
West_Portsmouth[West_Portsmouth.length] = createMarker(new GPoint(-83.05095673,38.71837997),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Portsmouth West High School",'West_Portsmouth=' + West_Portsmouth.length);
West_Portsmouth[West_Portsmouth.length] = createMarker(new GPoint(-83.03607178,38.75967026),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Portsmouth West Middle School",'West_Portsmouth=' + West_Portsmouth.length);
Portsmouth[Portsmouth.length] = createMarker(new GPoint(-82.98230743,38.75893784),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Roosevelt Elementary School",'Portsmouth=' + Portsmouth.length);
Portsmouth[Portsmouth.length] = createMarker(new GPoint(-82.97315216,38.78620911),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Rosemount Elementary School",'Portsmouth=' + Portsmouth.length);
Portsmouth[Portsmouth.length] = createMarker(new GPoint(-82.93980408,38.82012558),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Rubyville Elementary School",'Portsmouth=' + Portsmouth.length);
Lucasville[Lucasville.length] = createMarker(new GPoint(-82.97811890,38.85472870),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Scioto County High School",'Lucasville=' + Lucasville.length);
Portsmouth[Portsmouth.length] = createMarker(new GPoint(-82.88919067,38.75790024),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sciotoville High School",'Portsmouth=' + Portsmouth.length);
South_Webster[South_Webster.length] = createMarker(new GPoint(-82.72666200,38.81347000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Webster Jr/sr High School",'South_Webster=' + South_Webster.length);
New_Boston[New_Boston.length] = createMarker(new GPoint(-82.93927002,38.74903107),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Stanton Primary Elementary School",'New_Boston=' + New_Boston.length);
Franklin_Furnace[Franklin_Furnace.length] = createMarker(new GPoint(-82.83180237,38.64450073),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tecumseh (orvjcf)",'Franklin_Furnace=' + Franklin_Furnace.length);
Portsmouth[Portsmouth.length] = createMarker(new GPoint(-82.98899078,38.73310852),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("U S Grant Middle School",'Portsmouth=' + Portsmouth.length);
Lucasville[Lucasville.length] = createMarker(new GPoint(-82.99269867,38.88539886),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Valley Elementary School",'Lucasville=' + Lucasville.length);
Lucasville[Lucasville.length] = createMarker(new GPoint(-82.99269867,38.88539886),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Valley High School",'Lucasville=' + Lucasville.length);
Lucasville[Lucasville.length] = createMarker(new GPoint(-82.97872925,38.88038254),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Valley Middle School",'Lucasville=' + Lucasville.length);
Wheelersburg[Wheelersburg.length] = createMarker(new GPoint(-82.83776093,38.74088669),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wheelersburg Elementary School",'Wheelersburg=' + Wheelersburg.length);
Wheelersburg[Wheelersburg.length] = createMarker(new GPoint(-82.85309601,38.72553635),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wheelersburg High School",'Wheelersburg=' + Wheelersburg.length);
Wheelersburg[Wheelersburg.length] = createMarker(new GPoint(-82.83776093,38.74088669),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Wheelersburg Middle School",'Wheelersburg=' + Wheelersburg.length);
Portsmouth[Portsmouth.length] = createMarker(new GPoint(-82.97757721,38.73460770),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wilson Elementary School",'Portsmouth=' + Portsmouth.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(Franklin_Furnace);
map.removeOverlays(Lucasville);
map.removeOverlays(Mc_Dermott);
map.removeOverlays(Minford);
map.removeOverlays(New_Boston);
map.removeOverlays(Portsmouth);
map.removeOverlays(Sciotoville);
map.removeOverlays(South_Webster);
map.removeOverlays(West_Portsmouth);
map.removeOverlays(Wheelersburg);
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(South_Webster);map.removeOverlays(Franklin_Furnace);
map.removeOverlays(Lucasville);
map.removeOverlays(Mc_Dermott);
map.removeOverlays(Minford);
map.removeOverlays(New_Boston);
map.removeOverlays(Portsmouth);
map.removeOverlays(Sciotoville);
map.removeOverlays(South_Webster);
map.removeOverlays(West_Portsmouth);
map.removeOverlays(Wheelersburg);
map.addOverlays(Franklin_Furnace);
centerByArray(Franklin_Furnace, false, false);
cntMarker += Franklin_Furnace.length;
map.addOverlays(Lucasville);
centerByArray(Lucasville, false, false);
cntMarker += Lucasville.length;
map.addOverlays(Mc_Dermott);
centerByArray(Mc_Dermott, false, false);
cntMarker += Mc_Dermott.length;
map.addOverlays(Minford);
centerByArray(Minford, false, false);
cntMarker += Minford.length;
map.addOverlays(New_Boston);
centerByArray(New_Boston, false, false);
cntMarker += New_Boston.length;
map.addOverlays(Portsmouth);
centerByArray(Portsmouth, false, false);
cntMarker += Portsmouth.length;
map.addOverlays(Sciotoville);
centerByArray(Sciotoville, false, false);
cntMarker += Sciotoville.length;
map.addOverlays(South_Webster);
centerByArray(South_Webster, false, false);
cntMarker += South_Webster.length;
map.addOverlays(West_Portsmouth);
centerByArray(West_Portsmouth, false, false);
cntMarker += West_Portsmouth.length;
map.addOverlays(Wheelersburg);
centerByArray(Wheelersburg, false, false);
cntMarker += Wheelersburg.length;
centerByArray(South_Webster,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');
}
}