function addMarkers()
{
mySelect = document.getElementById('selection');
Amelia = [];Batavia = [];Bethel = [];Milford = [];Owensville = [];Felicity = [];Williamsburg = [];Goshen = [];Loveland = [];New_Richmond = [];mySelect.options[mySelect.options.length] = new Option("Amelia schools",'all=Amelia');
mySelect.options[mySelect.options.length] = new Option("Batavia schools",'all=Batavia');
mySelect.options[mySelect.options.length] = new Option("Bethel schools",'all=Bethel');
mySelect.options[mySelect.options.length] = new Option("Felicity schools",'all=Felicity');
mySelect.options[mySelect.options.length] = new Option("Goshen schools",'all=Goshen');
mySelect.options[mySelect.options.length] = new Option("Loveland schools",'all=Loveland');
mySelect.options[mySelect.options.length] = new Option("Milford schools",'all=Milford');
mySelect.options[mySelect.options.length] = new Option("New Richmond schools",'all=New_Richmond');
mySelect.options[mySelect.options.length] = new Option("Owensville schools",'all=Owensville');
mySelect.options[mySelect.options.length] = new Option("Williamsburg schools",'all=Williamsburg');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Amelia[Amelia.length] = createMarker(new GPoint(-84.21605682,39.02662277),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Amelia Elementary School",'Amelia=' + Amelia.length);
Batavia[Batavia.length] = createMarker(new GPoint(-84.23351288,39.06431580),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Amelia High School",'Batavia=' + Batavia.length);
Batavia[Batavia.length] = createMarker(new GPoint(-84.23422241,39.06450653),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Amelia Middle School",'Batavia=' + Batavia.length);
Batavia[Batavia.length] = createMarker(new GPoint(-84.13607788,39.12154770),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Batavia Elementary School",'Batavia=' + Batavia.length);
Batavia[Batavia.length] = createMarker(new GPoint(-84.12971497,39.07107162),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Batavia High School",'Batavia=' + Batavia.length);
Batavia[Batavia.length] = createMarker(new GPoint(-84.18261719,39.07004547),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Batavia Middle School",'Batavia=' + Batavia.length);
Bethel[Bethel.length] = createMarker(new GPoint(-84.06488037,38.96218872),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethel Tate High School",'Bethel=' + Bethel.length);
Bethel[Bethel.length] = createMarker(new GPoint(-84.09286499,38.96519852),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bethel-tate Middle School",'Bethel=' + Bethel.length);
Bethel[Bethel.length] = createMarker(new GPoint(-84.08885193,38.96194458),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bick Primary Elementary School",'Bethel=' + Bethel.length);
Milford[Milford.length] = createMarker(new GPoint(-84.23824310,39.21097565),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Boyd E Smith Elementary School",'Milford=' + Milford.length);
Milford[Milford.length] = createMarker(new GPoint(-84.22308350,39.17905045),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Charles L Seipelt Elementary School",'Milford=' + Milford.length);
Batavia[Batavia.length] = createMarker(new GPoint(-84.10286713,39.12909317),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clermont Northeastern Early Childhood Education Ce Elementary School",'Batavia=' + Batavia.length);
Owensville[Owensville.length] = createMarker(new GPoint(-84.13719940,39.12739944),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clermont Northeastern Elementary School",'Owensville=' + Owensville.length);
Batavia[Batavia.length] = createMarker(new GPoint(-84.09337616,39.16355896),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Clermont Northeastern High School",'Batavia=' + Batavia.length);
Batavia[Batavia.length] = createMarker(new GPoint(-84.09334564,39.16386795),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Clermont Northeastern Middle School",'Batavia=' + Batavia.length);
Felicity[Felicity.length] = createMarker(new GPoint(-84.13904572,38.79241562),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Felicity-franklin Local High School",'Felicity=' + Felicity.length);
Felicity[Felicity.length] = createMarker(new GPoint(-84.13904572,38.79241562),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Felicity-franklin Local School",'Felicity=' + Felicity.length);
Felicity[Felicity.length] = createMarker(new GPoint(-84.13904572,38.79241562),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Felicity-franklin Middle School",'Felicity=' + Felicity.length);
Williamsburg[Williamsburg.length] = createMarker(new GPoint(-84.05684662,39.05603790),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Genesis Center For Learning",'Williamsburg=' + Williamsburg.length);
Goshen[Goshen.length] = createMarker(new GPoint(-84.15415955,39.22732162),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Goshen High School",'Goshen=' + Goshen.length);
Goshen[Goshen.length] = createMarker(new GPoint(-84.15299988,39.22679901),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Goshen Middle School",'Goshen=' + Goshen.length);
Bethel[Bethel.length] = createMarker(new GPoint(-84.08757019,38.96188736),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hill Intermediate Elementary School",'Bethel=' + Bethel.length);
Amelia[Amelia.length] = createMarker(new GPoint(-84.19846344,39.02717590),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Holly Hill Elementary School",'Amelia=' + Amelia.length);
Milford[Milford.length] = createMarker(new GPoint(-84.29637900,39.17237500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Live Oaks Cdc High School",'Milford=' + Milford.length);
Loveland[Loveland.length] = createMarker(new GPoint(-84.25290680,39.24909210),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Loveland Early Childhood Cente Elementary School",'Loveland=' + Loveland.length);
Goshen[Goshen.length] = createMarker(new GPoint(-84.15324402,39.22698975),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Marr/cook Elementary School",'Goshen=' + Goshen.length);
Loveland[Loveland.length] = createMarker(new GPoint(-84.25943756,39.22750092),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mccormick Elementary School",'Loveland=' + Loveland.length);
Milford[Milford.length] = createMarker(new GPoint(-84.24235535,39.19327927),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Meadowview Elementary School",'Milford=' + Milford.length);
Milford[Milford.length] = createMarker(new GPoint(-84.23564148,39.18238449),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Milford Junior High School",'Milford=' + Milford.length);
Milford[Milford.length] = createMarker(new GPoint(-84.29055023,39.17760468),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Milford Main Middle School",'Milford=' + Milford.length);
Milford[Milford.length] = createMarker(new GPoint(-84.24205780,39.17564774),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Milford Senior High School",'Milford=' + Milford.length);
New_Richmond[New_Richmond.length] = createMarker(new GPoint(-84.20397949,38.92935944),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Monroe Elementary School",'New_Richmond=' + New_Richmond.length);
Milford[Milford.length] = createMarker(new GPoint(-84.22145844,39.19412231),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mulberry Elementary School",'Milford=' + Milford.length);
New_Richmond[New_Richmond.length] = createMarker(new GPoint(-84.26717377,38.95466232),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("New Richmond Elementary School",'New_Richmond=' + New_Richmond.length);
New_Richmond[New_Richmond.length] = createMarker(new GPoint(-84.26824951,38.95476151),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Richmond High School",'New_Richmond=' + New_Richmond.length);
New_Richmond[New_Richmond.length] = createMarker(new GPoint(-84.26797485,38.95476151),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("New Richmond Middle School",'New_Richmond=' + New_Richmond.length);
Milford[Milford.length] = createMarker(new GPoint(-84.28949738,39.15596771),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pattison Elementary School",'Milford=' + Milford.length);
Milford[Milford.length] = createMarker(new GPoint(-84.36351776,39.18201447),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Sellman Middle School",'Milford=' + Milford.length);
Goshen[Goshen.length] = createMarker(new GPoint(-84.15299988,39.22679901),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Spaulding Elementary School",'Goshen=' + Goshen.length);
Bethel[Bethel.length] = createMarker(new GPoint(-84.08553314,38.96401215),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("U S Grant High School",'Bethel=' + Bethel.length);
Milford[Milford.length] = createMarker(new GPoint(-84.19481659,39.16651535),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West Broad Street Elementary School",'Milford=' + Milford.length);
Williamsburg[Williamsburg.length] = createMarker(new GPoint(-84.06208801,39.05672455),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Williamsburg Elementary School",'Williamsburg=' + Williamsburg.length);
Williamsburg[Williamsburg.length] = createMarker(new GPoint(-84.06561279,39.05060196),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Williamsburg High School",'Williamsburg=' + Williamsburg.length);
Batavia[Batavia.length] = createMarker(new GPoint(-84.24459076,39.09860611),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Willowville Elementary School",'Batavia=' + Batavia.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(Amelia);
map.removeOverlays(Batavia);
map.removeOverlays(Bethel);
map.removeOverlays(Felicity);
map.removeOverlays(Goshen);
map.removeOverlays(Loveland);
map.removeOverlays(Milford);
map.removeOverlays(New_Richmond);
map.removeOverlays(Owensville);
map.removeOverlays(Williamsburg);
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(Amelia);map.removeOverlays(Amelia);
map.removeOverlays(Batavia);
map.removeOverlays(Bethel);
map.removeOverlays(Felicity);
map.removeOverlays(Goshen);
map.removeOverlays(Loveland);
map.removeOverlays(Milford);
map.removeOverlays(New_Richmond);
map.removeOverlays(Owensville);
map.removeOverlays(Williamsburg);
map.addOverlays(Amelia);
centerByArray(Amelia, false, false);
cntMarker += Amelia.length;
map.addOverlays(Batavia);
centerByArray(Batavia, false, false);
cntMarker += Batavia.length;
map.addOverlays(Bethel);
centerByArray(Bethel, false, false);
cntMarker += Bethel.length;
map.addOverlays(Felicity);
centerByArray(Felicity, false, false);
cntMarker += Felicity.length;
map.addOverlays(Goshen);
centerByArray(Goshen, false, false);
cntMarker += Goshen.length;
map.addOverlays(Loveland);
centerByArray(Loveland, false, false);
cntMarker += Loveland.length;
map.addOverlays(Milford);
centerByArray(Milford, false, false);
cntMarker += Milford.length;
map.addOverlays(New_Richmond);
centerByArray(New_Richmond, false, false);
cntMarker += New_Richmond.length;
map.addOverlays(Owensville);
centerByArray(Owensville, false, false);
cntMarker += Owensville.length;
map.addOverlays(Williamsburg);
centerByArray(Williamsburg, false, false);
cntMarker += Williamsburg.length;
centerByArray(Amelia,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');
}
}