function addMarkers()
{
mySelect = document.getElementById('selection');
Springfield = [];Donnelsville = [];Enon = [];New_Carlisle = [];Medway = [];South_Charleston = [];South_Vienna = [];Yellow_Springs = [];mySelect.options[mySelect.options.length] = new Option("Donnelsville schools",'all=Donnelsville');
mySelect.options[mySelect.options.length] = new Option("Enon schools",'all=Enon');
mySelect.options[mySelect.options.length] = new Option("Medway schools",'all=Medway');
mySelect.options[mySelect.options.length] = new Option("New Carlisle schools",'all=New_Carlisle');
mySelect.options[mySelect.options.length] = new Option("South Charleston schools",'all=South_Charleston');
mySelect.options[mySelect.options.length] = new Option("South Vienna schools",'all=South_Vienna');
mySelect.options[mySelect.options.length] = new Option("Springfield schools",'all=Springfield');
mySelect.options[mySelect.options.length] = new Option("Yellow Springs schools",'all=Yellow_Springs');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Springfield[Springfield.length] = createMarker(new GPoint(-83.83229828,39.92468262),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Clark Middle School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.79754639,39.87060928),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clark-shawnee Kindergarten Vil Elementary School",'Springfield=' + Springfield.length);
Donnelsville[Donnelsville.length] = createMarker(new GPoint(-83.94609833,39.91820145),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Donnelsville Elementary School",'Donnelsville=' + Donnelsville.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.77595520,39.91947174),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Elmwood Center",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.80104828,39.91440582),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Emerson Elementary School",'Springfield=' + Springfield.length);
Enon[Enon.length] = createMarker(new GPoint(-83.93682098,39.87734222),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Enon Elementary School",'Enon=' + Enon.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.78856659,39.90821457),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Franklin Middle School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.82247162,39.91796875),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fulton Elementary School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.83147430,39.92299271),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Grayhill Elementary School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.89007568,39.87091827),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Greenon High School",'Springfield=' + Springfield.length);
Enon[Enon.length] = createMarker(new GPoint(-83.93705200,39.87651800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Greenon Virtual School",'Enon=' + Enon.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.80803680,39.90535355),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Hayward Middle School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.81568146,39.90875626),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Highlands Elementary School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.88464355,39.84090424),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hustead Elementary School",'Springfield=' + Springfield.length);
Enon[Enon.length] = createMarker(new GPoint(-83.93764496,39.86391449),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Indian Valley Middle School",'Enon=' + Enon.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.81483459,39.91904831),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Keifer Community Center High School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.78753662,39.95201492),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kenton Elementary School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.76384735,39.98483276),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kenton Ridge High School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.78810120,39.90685272),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kenwood Heights - Beacon Ec Center",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.76773071,39.94509506),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lagonda Elementary School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.79193878,39.90461349),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Life Skills Center-springfield High School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.80173492,39.90695190),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.76570892,39.91456223),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mann Elementary School",'Springfield=' + Springfield.length);
New_Carlisle[New_Carlisle.length] = createMarker(new GPoint(-84.04709625,39.89413834),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mcadams Learning Center Elementary School",'New_Carlisle=' + New_Carlisle.length);
Medway[Medway.length] = createMarker(new GPoint(-84.01197815,39.88208389),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Medway Elementary School",'Medway=' + Medway.length);
South_Charleston[South_Charleston.length] = createMarker(new GPoint(-83.64002228,39.82673645),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Miami View Elementary School",'South_Charleston=' + South_Charleston.length);
South_Charleston[South_Charleston.length] = createMarker(new GPoint(-83.64002228,39.82673645),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Miami View Middle School",'South_Charleston=' + South_Charleston.length);
New_Carlisle[New_Carlisle.length] = createMarker(new GPoint(-84.03202057,39.94862366),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("New Carlisle Middle School",'New_Carlisle=' + New_Carlisle.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.79644775,39.95274353),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North High School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.68174744,39.94162369),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northeastern High School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.77214813,39.98709869),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Northridge Elementary School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.77214813,39.98709869),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Northridge Middle School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.91560364,39.98905563),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Northwestern Elementary School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.91082764,39.98881531),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northwestern High School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.91016388,39.98877716),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Northwestern Middle School",'Springfield=' + Springfield.length);
New_Carlisle[New_Carlisle.length] = createMarker(new GPoint(-83.99411011,39.91297150),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Olive Branch Middle School",'New_Carlisle=' + New_Carlisle.length);
New_Carlisle[New_Carlisle.length] = createMarker(new GPoint(-84.04255676,39.88839722),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Park Layne Elementary School",'New_Carlisle=' + New_Carlisle.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.82126617,39.90296555),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Perrin Woods Elementary School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.82653809,39.90943909),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Possum Elementary School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.74317932,39.91267014),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Reid Elementary School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.87500763,39.92620468),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Rockway Elementary School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.75061035,39.99402618),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Rolling Hills Elementary School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.80480957,39.94360352),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Roosevelt Middle School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.76947021,39.92171860),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Schaefer Middle School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.77982330,39.87091064),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Shawnee High School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.81796265,39.94596863),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Snowhill Elementary School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.83147430,39.92299271),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Snyder Park Elementary School",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.80905914,39.91596985),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South High School",'Springfield=' + Springfield.length);
South_Vienna[South_Vienna.length] = createMarker(new GPoint(-83.61543274,39.92783737),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South Vienna Elementary School",'South_Vienna=' + South_Vienna.length);
South_Vienna[South_Vienna.length] = createMarker(new GPoint(-83.38095856,38.66448975),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("South Vienna Middle School",'South_Vienna=' + South_Vienna.length);
South_Charleston[South_Charleston.length] = createMarker(new GPoint(-83.65149689,39.85169983),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Southeastern High School",'South_Charleston=' + South_Charleston.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.81313324,39.91716766),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Springfield Academy Of Excellence",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.79162000,39.90403300),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Springfield Preparatory And Fitness Academy",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.79123688,39.90082169),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Springfield-clark County High School",'Springfield=' + Springfield.length);
New_Carlisle[New_Carlisle.length] = createMarker(new GPoint(-83.99584198,39.91275787),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tecumseh High School",'New_Carlisle=' + New_Carlisle.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.80769500,39.90829000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Urban Youth Academy, Inc.",'Springfield=' + Springfield.length);
Springfield[Springfield.length] = createMarker(new GPoint(-83.77429199,39.92856216),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Warder Park-wayne Elementary School",'Springfield=' + Springfield.length);
New_Carlisle[New_Carlisle.length] = createMarker(new GPoint(-84.03673553,39.94533539),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Westlake Elementary School",'New_Carlisle=' + New_Carlisle.length);
Yellow_Springs[Yellow_Springs.length] = createMarker(new GPoint(-83.90717316,39.79906845),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Yellow Springs/mckinney High School",'Yellow_Springs=' + Yellow_Springs.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(Donnelsville);
map.removeOverlays(Enon);
map.removeOverlays(Medway);
map.removeOverlays(New_Carlisle);
map.removeOverlays(South_Charleston);
map.removeOverlays(South_Vienna);
map.removeOverlays(Springfield);
map.removeOverlays(Yellow_Springs);
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(Springfield);map.removeOverlays(Donnelsville);
map.removeOverlays(Enon);
map.removeOverlays(Medway);
map.removeOverlays(New_Carlisle);
map.removeOverlays(South_Charleston);
map.removeOverlays(South_Vienna);
map.removeOverlays(Springfield);
map.removeOverlays(Yellow_Springs);
map.addOverlays(Donnelsville);
centerByArray(Donnelsville, false, false);
cntMarker += Donnelsville.length;
map.addOverlays(Enon);
centerByArray(Enon, false, false);
cntMarker += Enon.length;
map.addOverlays(Medway);
centerByArray(Medway, false, false);
cntMarker += Medway.length;
map.addOverlays(New_Carlisle);
centerByArray(New_Carlisle, false, false);
cntMarker += New_Carlisle.length;
map.addOverlays(South_Charleston);
centerByArray(South_Charleston, false, false);
cntMarker += South_Charleston.length;
map.addOverlays(South_Vienna);
centerByArray(South_Vienna, false, false);
cntMarker += South_Vienna.length;
map.addOverlays(Springfield);
centerByArray(Springfield, false, false);
cntMarker += Springfield.length;
map.addOverlays(Yellow_Springs);
centerByArray(Yellow_Springs, false, false);
cntMarker += Yellow_Springs.length;
centerByArray(Springfield,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');
}
}