function addMarkers()
{
mySelect = document.getElementById('selection');
Baltic = [];Bolivar = [];New_Philadelphia = [];Magnolia = [];Uhrichsville = [];Dennison = [];Dover = [];Dundee = [];Newcomerstown = [];Sugarcreek = [];Gnadenhutten = [];Tuscarawas = [];Midvale = [];Mineral_City = [];Port_Washington = [];Strasburg = [];Zoarville = [];mySelect.options[mySelect.options.length] = new Option("Baltic schools",'all=Baltic');
mySelect.options[mySelect.options.length] = new Option("Bolivar schools",'all=Bolivar');
mySelect.options[mySelect.options.length] = new Option("Dennison schools",'all=Dennison');
mySelect.options[mySelect.options.length] = new Option("Dover schools",'all=Dover');
mySelect.options[mySelect.options.length] = new Option("Dundee schools",'all=Dundee');
mySelect.options[mySelect.options.length] = new Option("Gnadenhutten schools",'all=Gnadenhutten');
mySelect.options[mySelect.options.length] = new Option("Magnolia schools",'all=Magnolia');
mySelect.options[mySelect.options.length] = new Option("Midvale schools",'all=Midvale');
mySelect.options[mySelect.options.length] = new Option("Mineral City schools",'all=Mineral_City');
mySelect.options[mySelect.options.length] = new Option("New Philadelphia schools",'all=New_Philadelphia');
mySelect.options[mySelect.options.length] = new Option("Newcomerstown schools",'all=Newcomerstown');
mySelect.options[mySelect.options.length] = new Option("Port Washington schools",'all=Port_Washington');
mySelect.options[mySelect.options.length] = new Option("Strasburg schools",'all=Strasburg');
mySelect.options[mySelect.options.length] = new Option("Sugarcreek schools",'all=Sugarcreek');
mySelect.options[mySelect.options.length] = new Option("Tuscarawas schools",'all=Tuscarawas');
mySelect.options[mySelect.options.length] = new Option("Uhrichsville schools",'all=Uhrichsville');
mySelect.options[mySelect.options.length] = new Option("Zoarville schools",'all=Zoarville');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Baltic[Baltic.length] = createMarker(new GPoint(-81.70539856,40.44369888),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Baltic Elementary School",'Baltic=' + Baltic.length);
Bolivar[Bolivar.length] = createMarker(new GPoint(-81.44920349,40.63639832),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bolivar Elementary School",'Bolivar=' + Bolivar.length);
New_Philadelphia[New_Philadelphia.length] = createMarker(new GPoint(-81.40190125,40.46887589),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Buckeye Career Center",'New_Philadelphia=' + New_Philadelphia.length);
Magnolia[Magnolia.length] = createMarker(new GPoint(-81.34852600,40.63856125),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cardinal Digital Academy, Inc",'Magnolia=' + Magnolia.length);
New_Philadelphia[New_Philadelphia.length] = createMarker(new GPoint(-81.44583130,40.49304962),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'New_Philadelphia=' + New_Philadelphia.length);
Uhrichsville[Uhrichsville.length] = createMarker(new GPoint(-81.38188934,40.39179993),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Claymont High School",'Uhrichsville=' + Uhrichsville.length);
Dennison[Dennison.length] = createMarker(new GPoint(-81.33383942,40.39433670),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Claymont Intermediate Elementary School",'Dennison=' + Dennison.length);
Uhrichsville[Uhrichsville.length] = createMarker(new GPoint(-81.34534454,40.39426422),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Claymont Junior High School",'Uhrichsville=' + Uhrichsville.length);
Dover[Dover.length] = createMarker(new GPoint(-81.48474884,40.53276825),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dover Avenue Elementary School",'Dover=' + Dover.length);
Dover[Dover.length] = createMarker(new GPoint(-81.48053741,40.52348709),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Dover High School",'Dover=' + Dover.length);
Dover[Dover.length] = createMarker(new GPoint(-81.48966980,40.54139328),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Dover Middle School",'Dover=' + Dover.length);
Dundee[Dundee.length] = createMarker(new GPoint(-81.64640045,40.61119843),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dundee Elementary School",'Dundee=' + Dundee.length);
Newcomerstown[Newcomerstown.length] = createMarker(new GPoint(-81.60405731,40.27510071),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("East Elementary School",'Newcomerstown=' + Newcomerstown.length);
New_Philadelphia[New_Philadelphia.length] = createMarker(new GPoint(-81.43553925,40.48854065),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("East Elementary School",'New_Philadelphia=' + New_Philadelphia.length);
Dover[Dover.length] = createMarker(new GPoint(-81.46866608,40.52882385),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("East Elementary School",'Dover=' + Dover.length);
Uhrichsville[Uhrichsville.length] = createMarker(new GPoint(-81.34124756,40.40108109),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Eastport Avenue Elementary School",'Uhrichsville=' + Uhrichsville.length);
Sugarcreek[Sugarcreek.length] = createMarker(new GPoint(-81.63990021,40.50781250),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Garaway High School",'Sugarcreek=' + Sugarcreek.length);
Gnadenhutten[Gnadenhutten.length] = createMarker(new GPoint(-81.43489838,40.36709976),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Indian Valley High School",'Gnadenhutten=' + Gnadenhutten.length);
Tuscarawas[Tuscarawas.length] = createMarker(new GPoint(-81.40270233,40.39720154),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Indian Valley Middle School",'Tuscarawas=' + Tuscarawas.length);
New_Philadelphia[New_Philadelphia.length] = createMarker(new GPoint(-81.45106506,40.49425507),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Joseph Welty Middle School",'New_Philadelphia=' + New_Philadelphia.length);
Midvale[Midvale.length] = createMarker(new GPoint(-81.37200165,40.43659973),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Midvale Elementary School",'Midvale=' + Midvale.length);
Sugarcreek[Sugarcreek.length] = createMarker(new GPoint(-81.65139008,40.50679398),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Miller Avenue Elementary School",'Sugarcreek=' + Sugarcreek.length);
Mineral_City[Mineral_City.length] = createMarker(new GPoint(-81.36101532,40.60341644),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mineral City Elementary School",'Mineral_City=' + Mineral_City.length);
Mineral_City[Mineral_City.length] = createMarker(new GPoint(-81.30107880,40.54260254),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("New Cumberland Elementary School",'Mineral_City=' + Mineral_City.length);
New_Philadelphia[New_Philadelphia.length] = createMarker(new GPoint(-81.45036316,40.49381256),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Philadelphia High School",'New_Philadelphia=' + New_Philadelphia.length);
Newcomerstown[Newcomerstown.length] = createMarker(new GPoint(-81.61264038,40.26453018),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Newcomerstown High School",'Newcomerstown=' + Newcomerstown.length);
Newcomerstown[Newcomerstown.length] = createMarker(new GPoint(-81.60942841,40.27051926),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Newcomerstown Middle School",'Newcomerstown=' + Newcomerstown.length);
Dennison[Dennison.length] = createMarker(new GPoint(-81.32134247,40.39302826),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Park Elementary School",'Dennison=' + Dennison.length);
Port_Washington[Port_Washington.length] = createMarker(new GPoint(-81.50520325,40.31579971),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Port Washington Elementary School",'Port_Washington=' + Port_Washington.length);
New_Philadelphia[New_Philadelphia.length] = createMarker(new GPoint(-81.44957000,40.48846300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Quaker Digital Academy",'New_Philadelphia=' + New_Philadelphia.length);
Sugarcreek[Sugarcreek.length] = createMarker(new GPoint(-81.63021088,40.44976044),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ragersville Elementary School",'Sugarcreek=' + Sugarcreek.length);
Magnolia[Magnolia.length] = createMarker(new GPoint(-81.34852600,40.63856125),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sandy Valley High School",'Magnolia=' + Magnolia.length);
New_Philadelphia[New_Philadelphia.length] = createMarker(new GPoint(-81.44973755,40.46904373),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South Elementary School",'New_Philadelphia=' + New_Philadelphia.length);
Dover[Dover.length] = createMarker(new GPoint(-81.46440887,40.51263428),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South Elementary School",'Dover=' + Dover.length);
Strasburg[Strasburg.length] = createMarker(new GPoint(-81.53033447,40.59703827),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Strasburg-franklin Elementary School",'Strasburg=' + Strasburg.length);
Strasburg[Strasburg.length] = createMarker(new GPoint(-81.53033447,40.59703827),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Strasburg-franklin High School",'Strasburg=' + Strasburg.length);
Uhrichsville[Uhrichsville.length] = createMarker(new GPoint(-81.34932709,40.38867188),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Trenton Avenue Elementary School",'Uhrichsville=' + Uhrichsville.length);
New_Philadelphia[New_Philadelphia.length] = createMarker(new GPoint(-81.46504211,40.50116730),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Tuscarawas Avenue Elementary School",'New_Philadelphia=' + New_Philadelphia.length);
Zoarville[Zoarville.length] = createMarker(new GPoint(-81.38818359,40.59818649),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tuscarawas Valley High School",'Zoarville=' + Zoarville.length);
Zoarville[Zoarville.length] = createMarker(new GPoint(-81.38822937,40.59824753),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Tuscarawas Valley Middle School",'Zoarville=' + Zoarville.length);
Newcomerstown[Newcomerstown.length] = createMarker(new GPoint(-81.61244965,40.26633835),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("West Elementary School",'Newcomerstown=' + Newcomerstown.length);
New_Philadelphia[New_Philadelphia.length] = createMarker(new GPoint(-81.45986176,40.49377060),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("West Elementary School",'New_Philadelphia=' + New_Philadelphia.length);
New_Philadelphia[New_Philadelphia.length] = createMarker(new GPoint(-81.49729156,40.46850586),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("York Elementary School",'New_Philadelphia=' + New_Philadelphia.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(Baltic);
map.removeOverlays(Bolivar);
map.removeOverlays(Dennison);
map.removeOverlays(Dover);
map.removeOverlays(Dundee);
map.removeOverlays(Gnadenhutten);
map.removeOverlays(Magnolia);
map.removeOverlays(Midvale);
map.removeOverlays(Mineral_City);
map.removeOverlays(New_Philadelphia);
map.removeOverlays(Newcomerstown);
map.removeOverlays(Port_Washington);
map.removeOverlays(Strasburg);
map.removeOverlays(Sugarcreek);
map.removeOverlays(Tuscarawas);
map.removeOverlays(Uhrichsville);
map.removeOverlays(Zoarville);
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(Baltic);map.removeOverlays(Baltic);
map.removeOverlays(Bolivar);
map.removeOverlays(Dennison);
map.removeOverlays(Dover);
map.removeOverlays(Dundee);
map.removeOverlays(Gnadenhutten);
map.removeOverlays(Magnolia);
map.removeOverlays(Midvale);
map.removeOverlays(Mineral_City);
map.removeOverlays(New_Philadelphia);
map.removeOverlays(Newcomerstown);
map.removeOverlays(Port_Washington);
map.removeOverlays(Strasburg);
map.removeOverlays(Sugarcreek);
map.removeOverlays(Tuscarawas);
map.removeOverlays(Uhrichsville);
map.removeOverlays(Zoarville);
map.addOverlays(Baltic);
centerByArray(Baltic, false, false);
cntMarker += Baltic.length;
map.addOverlays(Bolivar);
centerByArray(Bolivar, false, false);
cntMarker += Bolivar.length;
map.addOverlays(Dennison);
centerByArray(Dennison, false, false);
cntMarker += Dennison.length;
map.addOverlays(Dover);
centerByArray(Dover, false, false);
cntMarker += Dover.length;
map.addOverlays(Dundee);
centerByArray(Dundee, false, false);
cntMarker += Dundee.length;
map.addOverlays(Gnadenhutten);
centerByArray(Gnadenhutten, false, false);
cntMarker += Gnadenhutten.length;
map.addOverlays(Magnolia);
centerByArray(Magnolia, false, false);
cntMarker += Magnolia.length;
map.addOverlays(Midvale);
centerByArray(Midvale, false, false);
cntMarker += Midvale.length;
map.addOverlays(Mineral_City);
centerByArray(Mineral_City, false, false);
cntMarker += Mineral_City.length;
map.addOverlays(New_Philadelphia);
centerByArray(New_Philadelphia, false, false);
cntMarker += New_Philadelphia.length;
map.addOverlays(Newcomerstown);
centerByArray(Newcomerstown, false, false);
cntMarker += Newcomerstown.length;
map.addOverlays(Port_Washington);
centerByArray(Port_Washington, false, false);
cntMarker += Port_Washington.length;
map.addOverlays(Strasburg);
centerByArray(Strasburg, false, false);
cntMarker += Strasburg.length;
map.addOverlays(Sugarcreek);
centerByArray(Sugarcreek, false, false);
cntMarker += Sugarcreek.length;
map.addOverlays(Tuscarawas);
centerByArray(Tuscarawas, false, false);
cntMarker += Tuscarawas.length;
map.addOverlays(Uhrichsville);
centerByArray(Uhrichsville, false, false);
cntMarker += Uhrichsville.length;
map.addOverlays(Zoarville);
centerByArray(Zoarville, false, false);
cntMarker += Zoarville.length;
centerByArray(Baltic,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');
}
}