function addMarkers()
{
mySelect = document.getElementById('selection');
Convoy = [];Van_Wert = [];Delphos = [];Ohio_City = [];Willshire = [];Spencerville = [];mySelect.options[mySelect.options.length] = new Option("Convoy schools",'all=Convoy');
mySelect.options[mySelect.options.length] = new Option("Delphos schools",'all=Delphos');
mySelect.options[mySelect.options.length] = new Option("Ohio City schools",'all=Ohio_City');
mySelect.options[mySelect.options.length] = new Option("Spencerville schools",'all=Spencerville');
mySelect.options[mySelect.options.length] = new Option("Van Wert schools",'all=Van_Wert');
mySelect.options[mySelect.options.length] = new Option("Willshire schools",'all=Willshire');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Convoy[Convoy.length] = createMarker(new GPoint(-84.70729400,40.91710500),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Crestview Elementary School",'Convoy=' + Convoy.length);
Convoy[Convoy.length] = createMarker(new GPoint(-84.70177460,40.91676331),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Crestview High School",'Convoy=' + Convoy.length);
Van_Wert[Van_Wert.length] = createMarker(new GPoint(-84.57828522,40.86553574),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Franklin Elementary School",'Van_Wert=' + Van_Wert.length);
Van_Wert[Van_Wert.length] = createMarker(new GPoint(-84.57715607,40.87571335),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Horace Mann Elementary School",'Van_Wert=' + Van_Wert.length);
Van_Wert[Van_Wert.length] = createMarker(new GPoint(-84.56842041,40.85834503),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'Van_Wert=' + Van_Wert.length);
Delphos[Delphos.length] = createMarker(new GPoint(-84.34233856,40.84422684),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Jefferson Middle School",'Delphos=' + Delphos.length);
Van_Wert[Van_Wert.length] = createMarker(new GPoint(-84.51535034,40.85203552),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lincolnview Elementary School",'Van_Wert=' + Van_Wert.length);
Van_Wert[Van_Wert.length] = createMarker(new GPoint(-84.51535034,40.85203552),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lincolnview Jr/sr High School",'Van_Wert=' + Van_Wert.length);
Van_Wert[Van_Wert.length] = createMarker(new GPoint(-84.52986145,40.87784195),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lincolnview Langley",'Van_Wert=' + Van_Wert.length);
Van_Wert[Van_Wert.length] = createMarker(new GPoint(-84.58300018,40.87459946),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lincolnview Marsh",'Van_Wert=' + Van_Wert.length);
Ohio_City[Ohio_City.length] = createMarker(new GPoint(-84.62281799,40.76935577),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ohio City Elementary School",'Ohio_City=' + Ohio_City.length);
Willshire[Willshire.length] = createMarker(new GPoint(-84.78977966,40.74533463),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Parkway Middle School",'Willshire=' + Willshire.length);
Spencerville[Spencerville.length] = createMarker(new GPoint(-84.41601562,40.74602890),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Spencerville Jennings Elementary School",'Spencerville=' + Spencerville.length);
Van_Wert[Van_Wert.length] = createMarker(new GPoint(-84.58441925,40.86753845),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Van Wert High School",'Van_Wert=' + Van_Wert.length);
Van_Wert[Van_Wert.length] = createMarker(new GPoint(-84.58639526,40.86752319),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Van Wert Middle School",'Van_Wert=' + Van_Wert.length);
Van_Wert[Van_Wert.length] = createMarker(new GPoint(-84.57171631,40.88050842),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Vantage Career Center",'Van_Wert=' + Van_Wert.length);
Van_Wert[Van_Wert.length] = createMarker(new GPoint(-84.59438324,40.86723709),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Washington Elementary School",'Van_Wert=' + Van_Wert.length);
Van_Wert[Van_Wert.length] = createMarker(new GPoint(-84.57801819,40.87608337),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wb Esc Student Learning Center",'Van_Wert=' + Van_Wert.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(Convoy);
map.removeOverlays(Delphos);
map.removeOverlays(Ohio_City);
map.removeOverlays(Spencerville);
map.removeOverlays(Van_Wert);
map.removeOverlays(Willshire);
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(Convoy);map.removeOverlays(Convoy);
map.removeOverlays(Delphos);
map.removeOverlays(Ohio_City);
map.removeOverlays(Spencerville);
map.removeOverlays(Van_Wert);
map.removeOverlays(Willshire);
map.addOverlays(Convoy);
centerByArray(Convoy, false, false);
cntMarker += Convoy.length;
map.addOverlays(Delphos);
centerByArray(Delphos, false, false);
cntMarker += Delphos.length;
map.addOverlays(Ohio_City);
centerByArray(Ohio_City, false, false);
cntMarker += Ohio_City.length;
map.addOverlays(Spencerville);
centerByArray(Spencerville, false, false);
cntMarker += Spencerville.length;
map.addOverlays(Van_Wert);
centerByArray(Van_Wert, false, false);
cntMarker += Van_Wert.length;
map.addOverlays(Willshire);
centerByArray(Willshire, false, false);
cntMarker += Willshire.length;
centerByArray(Convoy,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');
}
}