function addMarkers()
{
mySelect = document.getElementById('selection');
Ashville = [];Circleville = [];Derby = [];Mount_Sterling = [];New_Holland = [];Kingston = [];Commercial_Point = [];Williamsport = [];mySelect.options[mySelect.options.length] = new Option("Ashville schools",'all=Ashville');
mySelect.options[mySelect.options.length] = new Option("Circleville schools",'all=Circleville');
mySelect.options[mySelect.options.length] = new Option("Commercial Point schools",'all=Commercial_Point');
mySelect.options[mySelect.options.length] = new Option("Derby schools",'all=Derby');
mySelect.options[mySelect.options.length] = new Option("Kingston schools",'all=Kingston');
mySelect.options[mySelect.options.length] = new Option("Mount Sterling schools",'all=Mount_Sterling');
mySelect.options[mySelect.options.length] = new Option("New Holland schools",'all=New_Holland');
mySelect.options[mySelect.options.length] = new Option("Williamsport schools",'all=Williamsport');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Ashville[Ashville.length] = createMarker(new GPoint(-82.94942474,39.71511078),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ashville Elementary School",'Ashville=' + Ashville.length);
Circleville[Circleville.length] = createMarker(new GPoint(-82.93700409,39.61458969),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Atwater Elementary School",'Circleville=' + Circleville.length);
Circleville[Circleville.length] = createMarker(new GPoint(-82.92523956,39.60693359),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Circleville High School",'Circleville=' + Circleville.length);
Circleville[Circleville.length] = createMarker(new GPoint(-82.95204163,39.58761215),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Court Elementary School",'Circleville=' + Circleville.length);
Derby[Derby.length] = createMarker(new GPoint(-83.20225525,39.76522827),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Darby Elementary School",'Derby=' + Derby.length);
Circleville[Circleville.length] = createMarker(new GPoint(-82.94732666,39.59750748),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Everts Middle School",'Circleville=' + Circleville.length);
Circleville[Circleville.length] = createMarker(new GPoint(-82.84915924,39.56171417),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("George Mcdowell-exchange Junior High School",'Circleville=' + Circleville.length);
Circleville[Circleville.length] = createMarker(new GPoint(-83.01329803,39.64237976),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jackson Elementary School",'Circleville=' + Circleville.length);
Circleville[Circleville.length] = createMarker(new GPoint(-82.84925079,39.56172180),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Logan Elm High School",'Circleville=' + Circleville.length);
Mount_Sterling[Mount_Sterling.length] = createMarker(new GPoint(-83.17910004,39.67404938),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Monroe Elementary School",'Mount_Sterling=' + Mount_Sterling.length);
Circleville[Circleville.length] = createMarker(new GPoint(-82.93824768,39.59740067),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mound Elementary School",'Circleville=' + Circleville.length);
New_Holland[New_Holland.length] = createMarker(new GPoint(-83.25546265,39.55150986),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("New Holland Elementary School",'New_Holland=' + New_Holland.length);
Circleville[Circleville.length] = createMarker(new GPoint(-82.92868042,39.60632706),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Nicholas Elementary School",'Circleville=' + Circleville.length);
Circleville[Circleville.length] = createMarker(new GPoint(-82.93156433,39.51589584),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pickaway Elementary School",'Circleville=' + Circleville.length);
Circleville[Circleville.length] = createMarker(new GPoint(-82.95247650,39.59635925),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ralph C Starkey (cjcf) High School",'Circleville=' + Circleville.length);
Kingston[Kingston.length] = createMarker(new GPoint(-82.78445435,39.51393890),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Saltcreek Elementary School",'Kingston=' + Kingston.length);
Commercial_Point[Commercial_Point.length] = createMarker(new GPoint(-83.05889893,39.77000046),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Scioto Elementary School",'Commercial_Point=' + Commercial_Point.length);
Ashville[Ashville.length] = createMarker(new GPoint(-82.94329834,39.72326279),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Teays Valley High School",'Ashville=' + Ashville.length);
Ashville[Ashville.length] = createMarker(new GPoint(-82.94348907,39.72257233),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Teays Valley Middle School",'Ashville=' + Ashville.length);
Ashville[Ashville.length] = createMarker(new GPoint(-82.89280701,39.69003677),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Walnut Elementary School",'Ashville=' + Ashville.length);
Circleville[Circleville.length] = createMarker(new GPoint(-82.87886810,39.60535431),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Washington Elementary School",'Circleville=' + Circleville.length);
Williamsport[Williamsport.length] = createMarker(new GPoint(-83.11756897,39.65451050),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Westfall Elementary School",'Williamsport=' + Williamsport.length);
Williamsport[Williamsport.length] = createMarker(new GPoint(-83.11968231,39.65492249),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Westfall High School",'Williamsport=' + Williamsport.length);
Williamsport[Williamsport.length] = createMarker(new GPoint(-83.12006378,39.65399170),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Westfall Middle School",'Williamsport=' + Williamsport.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(Ashville);
map.removeOverlays(Circleville);
map.removeOverlays(Commercial_Point);
map.removeOverlays(Derby);
map.removeOverlays(Kingston);
map.removeOverlays(Mount_Sterling);
map.removeOverlays(New_Holland);
map.removeOverlays(Williamsport);
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(Ashville);map.removeOverlays(Ashville);
map.removeOverlays(Circleville);
map.removeOverlays(Commercial_Point);
map.removeOverlays(Derby);
map.removeOverlays(Kingston);
map.removeOverlays(Mount_Sterling);
map.removeOverlays(New_Holland);
map.removeOverlays(Williamsport);
map.addOverlays(Ashville);
centerByArray(Ashville, false, false);
cntMarker += Ashville.length;
map.addOverlays(Circleville);
centerByArray(Circleville, false, false);
cntMarker += Circleville.length;
map.addOverlays(Commercial_Point);
centerByArray(Commercial_Point, false, false);
cntMarker += Commercial_Point.length;
map.addOverlays(Derby);
centerByArray(Derby, false, false);
cntMarker += Derby.length;
map.addOverlays(Kingston);
centerByArray(Kingston, false, false);
cntMarker += Kingston.length;
map.addOverlays(Mount_Sterling);
centerByArray(Mount_Sterling, false, false);
cntMarker += Mount_Sterling.length;
map.addOverlays(New_Holland);
centerByArray(New_Holland, false, false);
cntMarker += New_Holland.length;
map.addOverlays(Williamsport);
centerByArray(Williamsport, false, false);
cntMarker += Williamsport.length;
centerByArray(Ashville,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');
}
}