function addMarkers()
{
mySelect = document.getElementById('selection');
Lewis_Center = [];Sunbury = [];Ashley = [];Delaware = [];Radnor = [];Ostrander = [];Dublin = [];Galena = [];Powell = [];Westerville = [];mySelect.options[mySelect.options.length] = new Option("Ashley schools",'all=Ashley');
mySelect.options[mySelect.options.length] = new Option("Delaware schools",'all=Delaware');
mySelect.options[mySelect.options.length] = new Option("Dublin schools",'all=Dublin');
mySelect.options[mySelect.options.length] = new Option("Galena schools",'all=Galena');
mySelect.options[mySelect.options.length] = new Option("Lewis Center schools",'all=Lewis_Center');
mySelect.options[mySelect.options.length] = new Option("Ostrander schools",'all=Ostrander');
mySelect.options[mySelect.options.length] = new Option("Powell schools",'all=Powell');
mySelect.options[mySelect.options.length] = new Option("Radnor schools",'all=Radnor');
mySelect.options[mySelect.options.length] = new Option("Sunbury schools",'all=Sunbury');
mySelect.options[mySelect.options.length] = new Option("Westerville schools",'all=Westerville');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Lewis_Center[Lewis_Center.length] = createMarker(new GPoint(-82.99207306,40.18921280),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Alum Creek Elementary School",'Lewis_Center=' + Lewis_Center.length);
Lewis_Center[Lewis_Center.length] = createMarker(new GPoint(-83.00569916,40.21729660),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Arrowhead Elementary School",'Lewis_Center=' + Lewis_Center.length);
Sunbury[Sunbury.length] = createMarker(new GPoint(-82.86443329,40.23270035),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Big Walnut Elementary School",'Sunbury=' + Sunbury.length);
Sunbury[Sunbury.length] = createMarker(new GPoint(-82.85369873,40.26250076),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Big Walnut High School",'Sunbury=' + Sunbury.length);
Sunbury[Sunbury.length] = createMarker(new GPoint(-82.85369873,40.26250076),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Big Walnut Middle School",'Sunbury=' + Sunbury.length);
Ashley[Ashley.length] = createMarker(new GPoint(-82.96499634,40.41170120),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Buckeye Valley East Elementary School",'Ashley=' + Ashley.length);
Delaware[Delaware.length] = createMarker(new GPoint(-83.09247589,40.35038376),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Buckeye Valley Local High School",'Delaware=' + Delaware.length);
Delaware[Delaware.length] = createMarker(new GPoint(-83.08804321,40.35018539),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Buckeye Valley Local Middle School",'Delaware=' + Delaware.length);
Radnor[Radnor.length] = createMarker(new GPoint(-83.14929199,40.38084412),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Buckeye Valley North Elementary School",'Radnor=' + Radnor.length);
Ostrander[Ostrander.length] = createMarker(new GPoint(-83.20269775,40.27429962),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Buckeye Valley West Elementary School",'Ostrander=' + Ostrander.length);
Delaware[Delaware.length] = createMarker(new GPoint(-83.07206726,40.31005096),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("David Smith Elementary School",'Delaware=' + Delaware.length);
Dublin[Dublin.length] = createMarker(new GPoint(-83.16794586,40.14876175),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Deer Run Elementary School",'Dublin=' + Dublin.length);
Delaware[Delaware.length] = createMarker(new GPoint(-83.02630615,40.30153656),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Delaware Area Career Center North Campus",'Delaware=' + Delaware.length);
Delaware[Delaware.length] = createMarker(new GPoint(-83.04024506,40.23101044),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Delaware Area Career Center South Campus",'Delaware=' + Delaware.length);
Delaware[Delaware.length] = createMarker(new GPoint(-83.04024506,40.23101044),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Delaware South Campus Vocatio High School",'Delaware=' + Delaware.length);
Dublin[Dublin.length] = createMarker(new GPoint(-83.15386200,40.16100693),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Eli Pinney Elementary School",'Dublin=' + Dublin.length);
Delaware[Delaware.length] = createMarker(new GPoint(-83.06788635,40.29764175),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ervin Carlisle Elementary School",'Delaware=' + Delaware.length);
Delaware[Delaware.length] = createMarker(new GPoint(-83.07105255,40.29896927),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Frank B Willis Intermediate Middle School",'Delaware=' + Delaware.length);
Lewis_Center[Lewis_Center.length] = createMarker(new GPoint(-83.00514500,40.17960000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Glen Oak Elementary School",'Lewis_Center=' + Lewis_Center.length);
Sunbury[Sunbury.length] = createMarker(new GPoint(-82.85801697,40.24523544),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Harrison Street Elementary School",'Sunbury=' + Sunbury.length);
Galena[Galena.length] = createMarker(new GPoint(-82.82609558,40.16920471),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hylen Souders Elementary School",'Galena=' + Galena.length);
Powell[Powell.length] = createMarker(new GPoint(-83.10336304,40.19632721),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Indian Springs Elementary School",'Powell=' + Powell.length);
Delaware[Delaware.length] = createMarker(new GPoint(-83.05477905,40.29969025),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("James Conger Elementary School",'Delaware=' + Delaware.length);
Delaware[Delaware.length] = createMarker(new GPoint(-83.08803558,40.31355286),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("John C Dempsey Middle School",'Delaware=' + Delaware.length);
Delaware[Delaware.length] = createMarker(new GPoint(-83.07186890,40.29217529),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Laura Woodward Elementary School",'Delaware=' + Delaware.length);
Lewis_Center[Lewis_Center.length] = createMarker(new GPoint(-83.00441742,40.16663361),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Oak Creek Elementary School",'Lewis_Center=' + Lewis_Center.length);
Lewis_Center[Lewis_Center.length] = createMarker(new GPoint(-83.02080536,40.20022202),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Olentangy High School",'Lewis_Center=' + Lewis_Center.length);
Powell[Powell.length] = createMarker(new GPoint(-83.09943390,40.19616699),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Olentangy Liberty High School",'Powell=' + Powell.length);
Powell[Powell.length] = createMarker(new GPoint(-83.07804871,40.18461227),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Olentangy Liberty Middle School",'Powell=' + Powell.length);
Lewis_Center[Lewis_Center.length] = createMarker(new GPoint(-83.02141571,40.21322632),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Olentangy Shanahan Middle School",'Lewis_Center=' + Lewis_Center.length);
Delaware[Delaware.length] = createMarker(new GPoint(-83.09419250,40.29810715),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Robert F Schultz Elementary School",'Delaware=' + Delaware.length);
Delaware[Delaware.length] = createMarker(new GPoint(-83.07819366,40.31109238),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rutherford B Hayes High School",'Delaware=' + Delaware.length);
Powell[Powell.length] = createMarker(new GPoint(-83.08513641,40.16244507),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Scioto Ridge Elementary School",'Powell=' + Powell.length);
Delaware[Delaware.length] = createMarker(new GPoint(-83.14214200,40.19612000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Scioto River (sjcf)",'Delaware=' + Delaware.length);
Lewis_Center[Lewis_Center.length] = createMarker(new GPoint(-83.02037048,40.21325684),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Shanahan Elementary School",'Lewis_Center=' + Lewis_Center.length);
Delaware[Delaware.length] = createMarker(new GPoint(-83.08912600,40.31270000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Technology Center Junior High School",'Delaware=' + Delaware.length);
Lewis_Center[Lewis_Center.length] = createMarker(new GPoint(-82.99949646,40.17425919),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Third Middle School Middle School",'Lewis_Center=' + Lewis_Center.length);
Powell[Powell.length] = createMarker(new GPoint(-83.07754517,40.14524078),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Tyler Run Elementary School",'Powell=' + Powell.length);
Galena[Galena.length] = createMarker(new GPoint(-82.93855286,40.18268585),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Walnut Creek Elementary School",'Galena=' + Galena.length);
Westerville[Westerville.length] = createMarker(new GPoint(-82.89736938,40.13201904),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Westerville-north High School",'Westerville=' + Westerville.length);
Dublin[Dublin.length] = createMarker(new GPoint(-83.16502380,40.14710236),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Willard Grizzell Middle School",'Dublin=' + Dublin.length);
Delaware[Delaware.length] = createMarker(new GPoint(-83.07392120,40.29249954),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("William K Willis (rjcf) High School",'Delaware=' + Delaware.length);
Powell[Powell.length] = createMarker(new GPoint(-83.07817841,40.18213654),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wyandot Run Elementary School",'Powell=' + Powell.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(Ashley);
map.removeOverlays(Delaware);
map.removeOverlays(Dublin);
map.removeOverlays(Galena);
map.removeOverlays(Lewis_Center);
map.removeOverlays(Ostrander);
map.removeOverlays(Powell);
map.removeOverlays(Radnor);
map.removeOverlays(Sunbury);
map.removeOverlays(Westerville);
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(Lewis_Center);map.removeOverlays(Ashley);
map.removeOverlays(Delaware);
map.removeOverlays(Dublin);
map.removeOverlays(Galena);
map.removeOverlays(Lewis_Center);
map.removeOverlays(Ostrander);
map.removeOverlays(Powell);
map.removeOverlays(Radnor);
map.removeOverlays(Sunbury);
map.removeOverlays(Westerville);
map.addOverlays(Ashley);
centerByArray(Ashley, false, false);
cntMarker += Ashley.length;
map.addOverlays(Delaware);
centerByArray(Delaware, false, false);
cntMarker += Delaware.length;
map.addOverlays(Dublin);
centerByArray(Dublin, false, false);
cntMarker += Dublin.length;
map.addOverlays(Galena);
centerByArray(Galena, false, false);
cntMarker += Galena.length;
map.addOverlays(Lewis_Center);
centerByArray(Lewis_Center, false, false);
cntMarker += Lewis_Center.length;
map.addOverlays(Ostrander);
centerByArray(Ostrander, false, false);
cntMarker += Ostrander.length;
map.addOverlays(Powell);
centerByArray(Powell, false, false);
cntMarker += Powell.length;
map.addOverlays(Radnor);
centerByArray(Radnor, false, false);
cntMarker += Radnor.length;
map.addOverlays(Sunbury);
centerByArray(Sunbury, false, false);
cntMarker += Sunbury.length;
map.addOverlays(Westerville);
centerByArray(Westerville, false, false);
cntMarker += Westerville.length;
centerByArray(Lewis_Center,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');
}
}