function addMarkers()
{
mySelect = document.getElementById('selection');
Piqua = [];Tipp_City = [];Bradford = [];Troy = [];Covington = [];Casstown = [];Fletcher = [];West_Milton = [];Pleasant_Hill = [];mySelect.options[mySelect.options.length] = new Option("Bradford schools",'all=Bradford');
mySelect.options[mySelect.options.length] = new Option("Casstown schools",'all=Casstown');
mySelect.options[mySelect.options.length] = new Option("Covington schools",'all=Covington');
mySelect.options[mySelect.options.length] = new Option("Fletcher schools",'all=Fletcher');
mySelect.options[mySelect.options.length] = new Option("Piqua schools",'all=Piqua');
mySelect.options[mySelect.options.length] = new Option("Pleasant Hill schools",'all=Pleasant_Hill');
mySelect.options[mySelect.options.length] = new Option("Tipp City schools",'all=Tipp_City');
mySelect.options[mySelect.options.length] = new Option("Troy schools",'all=Troy');
mySelect.options[mySelect.options.length] = new Option("West Milton schools",'all=West_Milton');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Piqua[Piqua.length] = createMarker(new GPoint(-84.23912811,40.14028931),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bennett Intermediate Elementary School",'Piqua=' + Piqua.length);
Tipp_City[Tipp_City.length] = createMarker(new GPoint(-84.08551788,39.91844940),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bethel Elementary School",'Tipp_City=' + Tipp_City.length);
Tipp_City[Tipp_City.length] = createMarker(new GPoint(-84.08551788,39.91844940),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethel High School",'Tipp_City=' + Tipp_City.length);
Tipp_City[Tipp_City.length] = createMarker(new GPoint(-84.08551788,39.91844940),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bethel Junior High School",'Tipp_City=' + Tipp_City.length);
Bradford[Bradford.length] = createMarker(new GPoint(-84.48470306,40.16640091),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bradford Central Elementary School",'Bradford=' + Bradford.length);
Bradford[Bradford.length] = createMarker(new GPoint(-84.48470306,40.16640091),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bradford High School",'Bradford=' + Bradford.length);
Tipp_City[Tipp_City.length] = createMarker(new GPoint(-84.17441559,39.95920563),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Broadway Elementary School",'Tipp_City=' + Tipp_City.length);
Troy[Troy.length] = createMarker(new GPoint(-84.26165009,40.03937149),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Concord Elementary School",'Troy=' + Troy.length);
Troy[Troy.length] = createMarker(new GPoint(-84.18574524,40.04648972),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cookson Elementary School",'Troy=' + Troy.length);
Covington[Covington.length] = createMarker(new GPoint(-84.34526825,40.12046432),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Covington Elementary School",'Covington=' + Covington.length);
Covington[Covington.length] = createMarker(new GPoint(-84.34362030,40.12046432),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Covington High School",'Covington=' + Covington.length);
Covington[Covington.length] = createMarker(new GPoint(-84.35028076,40.11834335),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Covington Middle School",'Covington=' + Covington.length);
Piqua[Piqua.length] = createMarker(new GPoint(-84.25424300,40.13893000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Favorite Hill Primary Elementary School",'Piqua=' + Piqua.length);
Troy[Troy.length] = createMarker(new GPoint(-84.20059967,40.03599548),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Forest",'Troy=' + Troy.length);
Troy[Troy.length] = createMarker(new GPoint(-84.21807861,40.04126740),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Heywood Elementary School",'Troy=' + Troy.length);
Piqua[Piqua.length] = createMarker(new GPoint(-84.26102448,40.14780426),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("High Street Primary Elementary School",'Piqua=' + Piqua.length);
Troy[Troy.length] = createMarker(new GPoint(-84.22171783,40.05581665),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hook Elementary School",'Troy=' + Troy.length);
Troy[Troy.length] = createMarker(new GPoint(-84.20874023,40.03540421),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kyle Elementary School",'Troy=' + Troy.length);
Tipp_City[Tipp_City.length] = createMarker(new GPoint(-84.17441559,39.95920563),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("L.t. Ball Intermediate School",'Tipp_City=' + Tipp_City.length);
Casstown[Casstown.length] = createMarker(new GPoint(-84.11682129,40.08377457),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Miami East High School",'Casstown=' + Casstown.length);
Casstown[Casstown.length] = createMarker(new GPoint(-84.12259674,40.05456161),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Miami East Intermediate Middle School",'Casstown=' + Casstown.length);
Casstown[Casstown.length] = createMarker(new GPoint(-84.19555664,40.07449722),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Miami East Junior High School",'Casstown=' + Casstown.length);
Fletcher[Fletcher.length] = createMarker(new GPoint(-84.11981964,40.14550018),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Miami East North Elementary School",'Fletcher=' + Fletcher.length);
Casstown[Casstown.length] = createMarker(new GPoint(-84.09755707,39.99922562),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Miami East South Elementary School",'Casstown=' + Casstown.length);
West_Milton[West_Milton.length] = createMarker(new GPoint(-84.33276367,39.95933533),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Milton-union Elementary School",'West_Milton=' + West_Milton.length);
West_Milton[West_Milton.length] = createMarker(new GPoint(-84.32932281,39.95974731),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Milton-union High School",'West_Milton=' + West_Milton.length);
West_Milton[West_Milton.length] = createMarker(new GPoint(-84.33451843,39.95755768),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Milton-union Middle School",'West_Milton=' + West_Milton.length);
Tipp_City[Tipp_City.length] = createMarker(new GPoint(-84.18155670,39.96768188),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Nevin Coppock Elementary School",'Tipp_City=' + Tipp_City.length);
Pleasant_Hill[Pleasant_Hill.length] = createMarker(new GPoint(-84.34899902,40.05089951),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Newton Elementary School",'Pleasant_Hill=' + Pleasant_Hill.length);
Pleasant_Hill[Pleasant_Hill.length] = createMarker(new GPoint(-84.34899902,40.05089951),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Newton High School",'Pleasant_Hill=' + Pleasant_Hill.length);
Piqua[Piqua.length] = createMarker(new GPoint(-84.24871063,40.15407181),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Nicklin Learning Center Elementary School",'Piqua=' + Piqua.length);
Piqua[Piqua.length] = createMarker(new GPoint(-84.20584869,40.16337585),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Piqua High School",'Piqua=' + Piqua.length);
Piqua[Piqua.length] = createMarker(new GPoint(-84.20584869,40.16337585),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Piqua Junior High School",'Piqua=' + Piqua.length);
Piqua[Piqua.length] = createMarker(new GPoint(-84.19504547,40.14987183),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Springcreek Primary Elementary School",'Piqua=' + Piqua.length);
Tipp_City[Tipp_City.length] = createMarker(new GPoint(-84.18238068,39.96911621),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tippecanoe High School",'Tipp_City=' + Tipp_City.length);
Tipp_City[Tipp_City.length] = createMarker(new GPoint(-84.18292999,39.97007370),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Tippecanoe Middle School",'Tipp_City=' + Tipp_City.length);
Troy[Troy.length] = createMarker(new GPoint(-84.19989777,40.04412460),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Troy High School",'Troy=' + Troy.length);
Troy[Troy.length] = createMarker(new GPoint(-84.19956207,40.05116272),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Troy Junior High School",'Troy=' + Troy.length);
Piqua[Piqua.length] = createMarker(new GPoint(-84.21446991,40.16240311),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Upper Valley High School",'Piqua=' + Piqua.length);
Troy[Troy.length] = createMarker(new GPoint(-84.19712830,40.03700638),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Van Cleve Elementary School",'Troy=' + Troy.length);
Piqua[Piqua.length] = createMarker(new GPoint(-84.26927948,40.15250397),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Washington Intermediate Elementary School",'Piqua=' + Piqua.length);
Piqua[Piqua.length] = createMarker(new GPoint(-84.25000000,40.15687561),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Wilder Intermediate Elementary School",'Piqua=' + Piqua.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(Bradford);
map.removeOverlays(Casstown);
map.removeOverlays(Covington);
map.removeOverlays(Fletcher);
map.removeOverlays(Piqua);
map.removeOverlays(Pleasant_Hill);
map.removeOverlays(Tipp_City);
map.removeOverlays(Troy);
map.removeOverlays(West_Milton);
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(Piqua);map.removeOverlays(Bradford);
map.removeOverlays(Casstown);
map.removeOverlays(Covington);
map.removeOverlays(Fletcher);
map.removeOverlays(Piqua);
map.removeOverlays(Pleasant_Hill);
map.removeOverlays(Tipp_City);
map.removeOverlays(Troy);
map.removeOverlays(West_Milton);
map.addOverlays(Bradford);
centerByArray(Bradford, false, false);
cntMarker += Bradford.length;
map.addOverlays(Casstown);
centerByArray(Casstown, false, false);
cntMarker += Casstown.length;
map.addOverlays(Covington);
centerByArray(Covington, false, false);
cntMarker += Covington.length;
map.addOverlays(Fletcher);
centerByArray(Fletcher, false, false);
cntMarker += Fletcher.length;
map.addOverlays(Piqua);
centerByArray(Piqua, false, false);
cntMarker += Piqua.length;
map.addOverlays(Pleasant_Hill);
centerByArray(Pleasant_Hill, false, false);
cntMarker += Pleasant_Hill.length;
map.addOverlays(Tipp_City);
centerByArray(Tipp_City, false, false);
cntMarker += Tipp_City.length;
map.addOverlays(Troy);
centerByArray(Troy, false, false);
cntMarker += Troy.length;
map.addOverlays(West_Milton);
centerByArray(West_Milton, false, false);
cntMarker += West_Milton.length;
centerByArray(Piqua,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');
}
}