function addMarkers()
{
mySelect = document.getElementById('selection');
Bellefontaine = [];Huntsville = [];Lewistown = [];Lakeview = [];De_Graff = [];West_Liberty = [];mySelect.options[mySelect.options.length] = new Option("Bellefontaine schools",'all=Bellefontaine');
mySelect.options[mySelect.options.length] = new Option("De Graff schools",'all=De_Graff');
mySelect.options[mySelect.options.length] = new Option("Huntsville schools",'all=Huntsville');
mySelect.options[mySelect.options.length] = new Option("Lakeview schools",'all=Lakeview');
mySelect.options[mySelect.options.length] = new Option("Lewistown schools",'all=Lewistown');
mySelect.options[mySelect.options.length] = new Option("West Liberty schools",'all=West_Liberty');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Bellefontaine[Bellefontaine.length] = createMarker(new GPoint(-83.75288391,40.34643555),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bellefontaine High School",'Bellefontaine=' + Bellefontaine.length);
Bellefontaine[Bellefontaine.length] = createMarker(new GPoint(-83.75519562,40.36664581),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bellefontaine Middle School",'Bellefontaine=' + Bellefontaine.length);
Bellefontaine[Bellefontaine.length] = createMarker(new GPoint(-83.65827179,40.41109085),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Benjamin Logan Elementary School",'Bellefontaine=' + Bellefontaine.length);
Bellefontaine[Bellefontaine.length] = createMarker(new GPoint(-83.65666962,40.40650177),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Benjamin Logan High School",'Bellefontaine=' + Bellefontaine.length);
Bellefontaine[Bellefontaine.length] = createMarker(new GPoint(-83.65818787,40.41147995),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Benjamin Logan Middle School",'Bellefontaine=' + Bellefontaine.length);
Huntsville[Huntsville.length] = createMarker(new GPoint(-83.82520294,40.45899963),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Huntsville Elementary School",'Huntsville=' + Huntsville.length);
Lewistown[Lewistown.length] = createMarker(new GPoint(-83.90610504,40.43745422),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Indian Lake High School",'Lewistown=' + Lewistown.length);
Lewistown[Lewistown.length] = createMarker(new GPoint(-83.90469360,40.43194962),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Indian Lake Middle School",'Lewistown=' + Lewistown.length);
Lakeview[Lakeview.length] = createMarker(new GPoint(-83.90370178,40.50709915),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lakeview Elementary School",'Lakeview=' + Lakeview.length);
Bellefontaine[Bellefontaine.length] = createMarker(new GPoint(-83.74794769,40.36636734),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Northeastern Elementary School",'Bellefontaine=' + Bellefontaine.length);
Bellefontaine[Bellefontaine.length] = createMarker(new GPoint(-83.72225952,40.37169647),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ohio Hi-point High School",'Bellefontaine=' + Bellefontaine.length);
Bellefontaine[Bellefontaine.length] = createMarker(new GPoint(-83.75936890,40.34548569),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pine Avenue Elementary School",'Bellefontaine=' + Bellefontaine.length);
De_Graff[De_Graff.length] = createMarker(new GPoint(-83.91921234,40.31599808),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Riverside Elementary School",'De_Graff=' + De_Graff.length);
De_Graff[De_Graff.length] = createMarker(new GPoint(-83.91921234,40.31599808),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Riverside High School",'De_Graff=' + De_Graff.length);
Bellefontaine[Bellefontaine.length] = createMarker(new GPoint(-83.75735474,40.35351944),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Southeastern Elementary School",'Bellefontaine=' + Bellefontaine.length);
West_Liberty[West_Liberty.length] = createMarker(new GPoint(-83.75021362,40.21442413),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("West Liberty-salem Elementary School",'West_Liberty=' + West_Liberty.length);
West_Liberty[West_Liberty.length] = createMarker(new GPoint(-83.75021362,40.21442413),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West Liberty-salem Middle/high School",'West_Liberty=' + West_Liberty.length);
Bellefontaine[Bellefontaine.length] = createMarker(new GPoint(-83.77617645,40.36373520),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Western Elementary School",'Bellefontaine=' + Bellefontaine.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(Bellefontaine);
map.removeOverlays(De_Graff);
map.removeOverlays(Huntsville);
map.removeOverlays(Lakeview);
map.removeOverlays(Lewistown);
map.removeOverlays(West_Liberty);
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(Bellefontaine);map.removeOverlays(Bellefontaine);
map.removeOverlays(De_Graff);
map.removeOverlays(Huntsville);
map.removeOverlays(Lakeview);
map.removeOverlays(Lewistown);
map.removeOverlays(West_Liberty);
map.addOverlays(Bellefontaine);
centerByArray(Bellefontaine, false, false);
cntMarker += Bellefontaine.length;
map.addOverlays(De_Graff);
centerByArray(De_Graff, false, false);
cntMarker += De_Graff.length;
map.addOverlays(Huntsville);
centerByArray(Huntsville, false, false);
cntMarker += Huntsville.length;
map.addOverlays(Lakeview);
centerByArray(Lakeview, false, false);
cntMarker += Lakeview.length;
map.addOverlays(Lewistown);
centerByArray(Lewistown, false, false);
cntMarker += Lewistown.length;
map.addOverlays(West_Liberty);
centerByArray(West_Liberty, false, false);
cntMarker += West_Liberty.length;
centerByArray(Bellefontaine,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');
}
}