function addMarkers()
{
mySelect = document.getElementById('selection');
Frankfort = [];Chillicothe = [];South_Salem = [];Bainbridge = [];Richmond_Dale = [];mySelect.options[mySelect.options.length] = new Option("Bainbridge schools",'all=Bainbridge');
mySelect.options[mySelect.options.length] = new Option("Chillicothe schools",'all=Chillicothe');
mySelect.options[mySelect.options.length] = new Option("Frankfort schools",'all=Frankfort');
mySelect.options[mySelect.options.length] = new Option("Richmond Dale schools",'all=Richmond_Dale');
mySelect.options[mySelect.options.length] = new Option("South Salem schools",'all=South_Salem');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Frankfort[Frankfort.length] = createMarker(new GPoint(-83.19474030,39.41341400),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Adena Elementary School",'Frankfort=' + Frankfort.length);
Frankfort[Frankfort.length] = createMarker(new GPoint(-83.19474030,39.41341400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Adena High School",'Frankfort=' + Frankfort.length);
Frankfort[Frankfort.length] = createMarker(new GPoint(-83.19474030,39.41341400),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Adena Middle School",'Frankfort=' + Frankfort.length);
Chillicothe[Chillicothe.length] = createMarker(new GPoint(-83.01428986,39.32974625),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Allen Elementary School",'Chillicothe=' + Chillicothe.length);
South_Salem[South_Salem.length] = createMarker(new GPoint(-83.26010132,39.30730057),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Buckskin Elementary School",'South_Salem=' + South_Salem.length);
Chillicothe[Chillicothe.length] = createMarker(new GPoint(-82.98236084,39.33025360),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Chillicothe=' + Chillicothe.length);
Chillicothe[Chillicothe.length] = createMarker(new GPoint(-82.98881531,39.34130478),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chillicothe High School",'Chillicothe=' + Chillicothe.length);
Chillicothe[Chillicothe.length] = createMarker(new GPoint(-82.95887756,39.33815765),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hopewell Elementary School",'Chillicothe=' + Chillicothe.length);
Chillicothe[Chillicothe.length] = createMarker(new GPoint(-83.05781555,39.24360657),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Huntington Elementary School",'Chillicothe=' + Chillicothe.length);
Chillicothe[Chillicothe.length] = createMarker(new GPoint(-83.05781555,39.24360657),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Huntington High School",'Chillicothe=' + Chillicothe.length);
Chillicothe[Chillicothe.length] = createMarker(new GPoint(-83.05781555,39.24360657),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Huntington Middle School",'Chillicothe=' + Chillicothe.length);
Chillicothe[Chillicothe.length] = createMarker(new GPoint(-83.01883698,39.36857986),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("June V Cormany Learning Cente",'Chillicothe=' + Chillicothe.length);
Bainbridge[Bainbridge.length] = createMarker(new GPoint(-83.25235748,39.24323273),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Light House Youth Center",'Bainbridge=' + Bainbridge.length);
Chillicothe[Chillicothe.length] = createMarker(new GPoint(-82.95078278,39.33097458),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mcarthur Elementary School",'Chillicothe=' + Chillicothe.length);
Chillicothe[Chillicothe.length] = createMarker(new GPoint(-82.95917511,39.33672333),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mt Logan Elementary School",'Chillicothe=' + Chillicothe.length);
Bainbridge[Bainbridge.length] = createMarker(new GPoint(-83.21543884,39.24398804),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Paint Valley Elementary School",'Bainbridge=' + Bainbridge.length);
Bainbridge[Bainbridge.length] = createMarker(new GPoint(-83.21543884,39.24398804),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Paint Valley High School",'Bainbridge=' + Bainbridge.length);
Bainbridge[Bainbridge.length] = createMarker(new GPoint(-83.21543884,39.24398804),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Paint Valley Middle School",'Bainbridge=' + Bainbridge.length);
Chillicothe[Chillicothe.length] = createMarker(new GPoint(-82.96386719,39.43980026),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pickaway-ross Ctc High School",'Chillicothe=' + Chillicothe.length);
Richmond_Dale[Richmond_Dale.length] = createMarker(new GPoint(-82.81439972,39.20370102),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Scioto Valley Intermediate Elementary School",'Richmond_Dale=' + Richmond_Dale.length);
Chillicothe[Chillicothe.length] = createMarker(new GPoint(-82.99393463,39.33913040),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Smith Middle School",'Chillicothe=' + Chillicothe.length);
Chillicothe[Chillicothe.length] = createMarker(new GPoint(-82.75209808,39.26850128),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Southeastern Elementary School",'Chillicothe=' + Chillicothe.length);
Chillicothe[Chillicothe.length] = createMarker(new GPoint(-82.81439972,39.20370102),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Southeastern High School",'Chillicothe=' + Chillicothe.length);
Chillicothe[Chillicothe.length] = createMarker(new GPoint(-82.86687469,39.19210815),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Southeastern Middle School",'Chillicothe=' + Chillicothe.length);
Chillicothe[Chillicothe.length] = createMarker(new GPoint(-82.97340393,39.33163452),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Tiffin Elementary School",'Chillicothe=' + Chillicothe.length);
Chillicothe[Chillicothe.length] = createMarker(new GPoint(-83.01883698,39.36857986),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Unioto Elementary School",'Chillicothe=' + Chillicothe.length);
Chillicothe[Chillicothe.length] = createMarker(new GPoint(-83.01883698,39.36857986),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Unioto High School",'Chillicothe=' + Chillicothe.length);
Chillicothe[Chillicothe.length] = createMarker(new GPoint(-83.01883698,39.36857986),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Unioto Junior High School",'Chillicothe=' + Chillicothe.length);
Chillicothe[Chillicothe.length] = createMarker(new GPoint(-82.97740173,39.33089828),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Western Annex",'Chillicothe=' + Chillicothe.length);
Chillicothe[Chillicothe.length] = createMarker(new GPoint(-82.99701691,39.34207535),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Worthington Elementary School",'Chillicothe=' + Chillicothe.length);
Chillicothe[Chillicothe.length] = createMarker(new GPoint(-82.93866730,39.42846680),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Zane Trace Elementary School",'Chillicothe=' + Chillicothe.length);
Chillicothe[Chillicothe.length] = createMarker(new GPoint(-82.97041600,39.33498300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Zane Trace High School",'Chillicothe=' + Chillicothe.length);
Chillicothe[Chillicothe.length] = createMarker(new GPoint(-82.93866730,39.42846680),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Zane Trace Middle School",'Chillicothe=' + Chillicothe.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(Bainbridge);
map.removeOverlays(Chillicothe);
map.removeOverlays(Frankfort);
map.removeOverlays(Richmond_Dale);
map.removeOverlays(South_Salem);
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(Frankfort);map.removeOverlays(Bainbridge);
map.removeOverlays(Chillicothe);
map.removeOverlays(Frankfort);
map.removeOverlays(Richmond_Dale);
map.removeOverlays(South_Salem);
map.addOverlays(Bainbridge);
centerByArray(Bainbridge, false, false);
cntMarker += Bainbridge.length;
map.addOverlays(Chillicothe);
centerByArray(Chillicothe, false, false);
cntMarker += Chillicothe.length;
map.addOverlays(Frankfort);
centerByArray(Frankfort, false, false);
cntMarker += Frankfort.length;
map.addOverlays(Richmond_Dale);
centerByArray(Richmond_Dale, false, false);
cntMarker += Richmond_Dale.length;
map.addOverlays(South_Salem);
centerByArray(South_Salem, false, false);
cntMarker += South_Salem.length;
centerByArray(Frankfort,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');
}
}