function addMarkers()
{
mySelect = document.getElementById('selection');
Ashland = [];Sullivan = [];Loudonville = [];Hayesville = [];Jeromesville = [];Perrysville = [];Nova = [];Nankin = [];Polk = [];mySelect.options[mySelect.options.length] = new Option("Ashland schools",'all=Ashland');
mySelect.options[mySelect.options.length] = new Option("Hayesville schools",'all=Hayesville');
mySelect.options[mySelect.options.length] = new Option("Jeromesville schools",'all=Jeromesville');
mySelect.options[mySelect.options.length] = new Option("Loudonville schools",'all=Loudonville');
mySelect.options[mySelect.options.length] = new Option("Nankin schools",'all=Nankin');
mySelect.options[mySelect.options.length] = new Option("Nova schools",'all=Nova');
mySelect.options[mySelect.options.length] = new Option("Perrysville schools",'all=Perrysville');
mySelect.options[mySelect.options.length] = new Option("Polk schools",'all=Polk');
mySelect.options[mySelect.options.length] = new Option("Sullivan schools",'all=Sullivan');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Ashland[Ashland.length] = createMarker(new GPoint(-82.31137848,40.86689758),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Alternative High School",'Ashland=' + Ashland.length);
Ashland[Ashland.length] = createMarker(new GPoint(-82.32253265,40.85459518),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ashland High School",'Ashland=' + Ashland.length);
Ashland[Ashland.length] = createMarker(new GPoint(-82.31792450,40.87047195),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Ashland Middle School",'Ashland=' + Ashland.length);
Ashland[Ashland.length] = createMarker(new GPoint(-82.26915741,40.80353928),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ashland-w Holmes Career Center",'Ashland=' + Ashland.length);
Sullivan[Sullivan.length] = createMarker(new GPoint(-82.22299957,41.03599930),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Black River Education Center Elementary School",'Sullivan=' + Sullivan.length);
Sullivan[Sullivan.length] = createMarker(new GPoint(-82.17797852,41.05816269),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Black River Education Center Middle School",'Sullivan=' + Sullivan.length);
Sullivan[Sullivan.length] = createMarker(new GPoint(-82.17510986,41.05816269),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Black River High School",'Sullivan=' + Sullivan.length);
Loudonville[Loudonville.length] = createMarker(new GPoint(-82.23152161,40.63536453),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Budd Elementary School",'Loudonville=' + Loudonville.length);
Ashland[Ashland.length] = createMarker(new GPoint(-82.36065674,40.88130569),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Crestview Elementary School",'Ashland=' + Ashland.length);
Ashland[Ashland.length] = createMarker(new GPoint(-82.36065674,40.88130569),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Crestview High School",'Ashland=' + Ashland.length);
Ashland[Ashland.length] = createMarker(new GPoint(-82.36065674,40.88130569),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Crestview Middle School",'Ashland=' + Ashland.length);
Ashland[Ashland.length] = createMarker(new GPoint(-82.32848358,40.87915421),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Edison Elementary School",'Ashland=' + Ashland.length);
Hayesville[Hayesville.length] = createMarker(new GPoint(-82.26602173,40.77310181),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hillsdale Elementary School",'Hayesville=' + Hayesville.length);
Jeromesville[Jeromesville.length] = createMarker(new GPoint(-82.21053314,40.78436279),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hillsdale High School",'Jeromesville=' + Jeromesville.length);
Jeromesville[Jeromesville.length] = createMarker(new GPoint(-82.18679810,40.79700089),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Hillsdale Middle School",'Jeromesville=' + Jeromesville.length);
Ashland[Ashland.length] = createMarker(new GPoint(-82.31652832,40.87703705),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Ashland=' + Ashland.length);
Loudonville[Loudonville.length] = createMarker(new GPoint(-82.24141693,40.63842773),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Loudonville High School",'Loudonville=' + Loudonville.length);
Perrysville[Perrysville.length] = createMarker(new GPoint(-82.31829834,40.65890121),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Louis Bromfield (mojcf) High School",'Perrysville=' + Perrysville.length);
Ashland[Ashland.length] = createMarker(new GPoint(-82.31534400,40.86865000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mapleton Elementary School",'Ashland=' + Ashland.length);
Ashland[Ashland.length] = createMarker(new GPoint(-82.28177643,40.96624756),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mapleton High School",'Ashland=' + Ashland.length);
Nova[Nova.length] = createMarker(new GPoint(-82.33270264,41.02130127),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mapleton Middle School",'Nova=' + Nova.length);
Loudonville[Loudonville.length] = createMarker(new GPoint(-82.23152161,40.63416290),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mcmullen Elementary School",'Loudonville=' + Loudonville.length);
Ashland[Ashland.length] = createMarker(new GPoint(-82.26176453,40.85722351),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Montgomery Elementary School",'Ashland=' + Ashland.length);
Nankin[Nankin.length] = createMarker(new GPoint(-82.28189850,40.92129898),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Nankin Elementary School",'Nankin=' + Nankin.length);
Ashland[Ashland.length] = createMarker(new GPoint(-82.30384827,40.86733246),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Osborn Elementary School",'Ashland=' + Ashland.length);
Perrysville[Perrysville.length] = createMarker(new GPoint(-82.32559967,40.65850067),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Perrysville Junior High School",'Perrysville=' + Perrysville.length);
Polk[Polk.length] = createMarker(new GPoint(-82.20639801,40.92860031),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Polk Elementary School",'Polk=' + Polk.length);
Ashland[Ashland.length] = createMarker(new GPoint(-82.32843781,40.85786438),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Taft Elementary School",'Ashland=' + Ashland.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(Ashland);
map.removeOverlays(Hayesville);
map.removeOverlays(Jeromesville);
map.removeOverlays(Loudonville);
map.removeOverlays(Nankin);
map.removeOverlays(Nova);
map.removeOverlays(Perrysville);
map.removeOverlays(Polk);
map.removeOverlays(Sullivan);
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(Ashland);map.removeOverlays(Ashland);
map.removeOverlays(Hayesville);
map.removeOverlays(Jeromesville);
map.removeOverlays(Loudonville);
map.removeOverlays(Nankin);
map.removeOverlays(Nova);
map.removeOverlays(Perrysville);
map.removeOverlays(Polk);
map.removeOverlays(Sullivan);
map.addOverlays(Ashland);
centerByArray(Ashland, false, false);
cntMarker += Ashland.length;
map.addOverlays(Hayesville);
centerByArray(Hayesville, false, false);
cntMarker += Hayesville.length;
map.addOverlays(Jeromesville);
centerByArray(Jeromesville, false, false);
cntMarker += Jeromesville.length;
map.addOverlays(Loudonville);
centerByArray(Loudonville, false, false);
cntMarker += Loudonville.length;
map.addOverlays(Nankin);
centerByArray(Nankin, false, false);
cntMarker += Nankin.length;
map.addOverlays(Nova);
centerByArray(Nova, false, false);
cntMarker += Nova.length;
map.addOverlays(Perrysville);
centerByArray(Perrysville, false, false);
cntMarker += Perrysville.length;
map.addOverlays(Polk);
centerByArray(Polk, false, false);
cntMarker += Polk.length;
map.addOverlays(Sullivan);
centerByArray(Sullivan, false, false);
cntMarker += Sullivan.length;
centerByArray(Ashland,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');
}
}