function addMarkers()
{
mySelect = document.getElementById('selection');
La_Moille = [];Wyanet = [];Manlius = [];Sheffield = [];Walnut = [];Buda = [];Cherry = [];Dalzell = [];Depue = [];Princeton = [];Spring_Valley = [];Ladd = [];Bureau = [];Malden = [];Neponset = [];Ohio = [];Tiskilwa = [];Van_Orin = [];mySelect.options[mySelect.options.length] = new Option("Buda schools",'all=Buda');
mySelect.options[mySelect.options.length] = new Option("Bureau schools",'all=Bureau');
mySelect.options[mySelect.options.length] = new Option("Cherry schools",'all=Cherry');
mySelect.options[mySelect.options.length] = new Option("Dalzell schools",'all=Dalzell');
mySelect.options[mySelect.options.length] = new Option("Depue schools",'all=Depue');
mySelect.options[mySelect.options.length] = new Option("La Moille schools",'all=La_Moille');
mySelect.options[mySelect.options.length] = new Option("Ladd schools",'all=Ladd');
mySelect.options[mySelect.options.length] = new Option("Malden schools",'all=Malden');
mySelect.options[mySelect.options.length] = new Option("Manlius schools",'all=Manlius');
mySelect.options[mySelect.options.length] = new Option("Neponset schools",'all=Neponset');
mySelect.options[mySelect.options.length] = new Option("Ohio schools",'all=Ohio');
mySelect.options[mySelect.options.length] = new Option("Princeton schools",'all=Princeton');
mySelect.options[mySelect.options.length] = new Option("Sheffield schools",'all=Sheffield');
mySelect.options[mySelect.options.length] = new Option("Spring Valley schools",'all=Spring_Valley');
mySelect.options[mySelect.options.length] = new Option("Tiskilwa schools",'all=Tiskilwa');
mySelect.options[mySelect.options.length] = new Option("Van Orin schools",'all=Van_Orin');
mySelect.options[mySelect.options.length] = new Option("Walnut schools",'all=Walnut');
mySelect.options[mySelect.options.length] = new Option("Wyanet schools",'all=Wyanet');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
La_Moille[La_Moille.length] = createMarker(new GPoint(-89.28730011,41.53889847),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Allen Junior High School",'La_Moille=' + La_Moille.length);
Wyanet[Wyanet.length] = createMarker(new GPoint(-89.58394623,41.36066437),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Behavior Disorder Program Coop",'Wyanet=' + Wyanet.length);
Wyanet[Wyanet.length] = createMarker(new GPoint(-89.58612061,41.36080170),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bureau Cnty Coop Alt School",'Wyanet=' + Wyanet.length);
Manlius[Manlius.length] = createMarker(new GPoint(-89.67790222,41.45149994),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bureau Valley Elementary-manlius Elementary School",'Manlius=' + Manlius.length);
Sheffield[Sheffield.length] = createMarker(new GPoint(-89.73121643,41.35621262),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bureau Valley Elemntry-sheffield Elementary School",'Sheffield=' + Sheffield.length);
Wyanet[Wyanet.length] = createMarker(new GPoint(-89.58394623,41.36066437),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bureau Valley Elemntry-wyanet Elementary School",'Wyanet=' + Wyanet.length);
Manlius[Manlius.length] = createMarker(new GPoint(-89.67790222,41.45149994),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bureau Valley High School",'Manlius=' + Manlius.length);
Walnut[Walnut.length] = createMarker(new GPoint(-89.60749817,41.54980087),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bureau Valley North Elementary School",'Walnut=' + Walnut.length);
Buda[Buda.length] = createMarker(new GPoint(-89.67948914,41.32580948),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bureau Valley South Middle School",'Buda=' + Buda.length);
Cherry[Cherry.length] = createMarker(new GPoint(-89.21160126,41.42620087),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cherry Grade School",'Cherry=' + Cherry.length);
Dalzell[Dalzell.length] = createMarker(new GPoint(-89.17649841,41.35729980),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dalzell Grade School",'Dalzell=' + Dalzell.length);
Depue[Depue.length] = createMarker(new GPoint(-89.32080078,41.34379959),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Depue Elementary School",'Depue=' + Depue.length);
Depue[Depue.length] = createMarker(new GPoint(-89.32080078,41.34379959),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Depue High School",'Depue=' + Depue.length);
Princeton[Princeton.length] = createMarker(new GPoint(-89.46224976,41.38306427),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Douglas Elementary School",'Princeton=' + Princeton.length);
Spring_Valley[Spring_Valley.length] = createMarker(new GPoint(-89.21300507,41.32581711),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hall High School",'Spring_Valley=' + Spring_Valley.length);
Princeton[Princeton.length] = createMarker(new GPoint(-89.47381592,41.37633514),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'Princeton=' + Princeton.length);
Spring_Valley[Spring_Valley.length] = createMarker(new GPoint(-89.20687866,41.33163834),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("John F Kennedy Elementary School",'Spring_Valley=' + Spring_Valley.length);
La_Moille[La_Moille.length] = createMarker(new GPoint(-89.28730011,41.53889847),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("La Moille High School",'La_Moille=' + La_Moille.length);
Ladd[Ladd.length] = createMarker(new GPoint(-89.21734619,41.37903595),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ladd Community Consolidated School District 94",'Ladd=' + Ladd.length);
Bureau[Bureau.length] = createMarker(new GPoint(-89.37729645,41.28820038),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Leepertown Elementary School",'Bureau=' + Bureau.length);
Princeton[Princeton.length] = createMarker(new GPoint(-89.46001434,41.37025452),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Princeton=' + Princeton.length);
Spring_Valley[Spring_Valley.length] = createMarker(new GPoint(-89.19280243,41.32556152),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Spring_Valley=' + Spring_Valley.length);
Princeton[Princeton.length] = createMarker(new GPoint(-89.46892548,41.37516403),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Logan Junior High School",'Princeton=' + Princeton.length);
Malden[Malden.length] = createMarker(new GPoint(-89.35910034,41.43790054),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Malden Grade School",'Malden=' + Malden.length);
Neponset[Neponset.length] = createMarker(new GPoint(-89.79399872,41.29050064),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Neponset Elementary School",'Neponset=' + Neponset.length);
Ohio[Ohio.length] = createMarker(new GPoint(-89.45490265,41.54710007),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ohio Com Consolidated Grade School",'Ohio=' + Ohio.length);
Ohio[Ohio.length] = createMarker(new GPoint(-89.45490265,41.54710007),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ohio Community High School",'Ohio=' + Ohio.length);
Princeton[Princeton.length] = createMarker(new GPoint(-89.46001434,41.37432480),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Princeton High School",'Princeton=' + Princeton.length);
Tiskilwa[Tiskilwa.length] = createMarker(new GPoint(-89.49240112,41.28580093),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Reagan Middle School",'Tiskilwa=' + Tiskilwa.length);
Wyanet[Wyanet.length] = createMarker(new GPoint(-89.58394623,41.36066437),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Roe Bureau Cty Alt School",'Wyanet=' + Wyanet.length);
Van_Orin[Van_Orin.length] = createMarker(new GPoint(-89.35430145,41.55130005),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Van Orin Elementary School",'Van_Orin=' + Van_Orin.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(Buda);
map.removeOverlays(Bureau);
map.removeOverlays(Cherry);
map.removeOverlays(Dalzell);
map.removeOverlays(Depue);
map.removeOverlays(La_Moille);
map.removeOverlays(Ladd);
map.removeOverlays(Malden);
map.removeOverlays(Manlius);
map.removeOverlays(Neponset);
map.removeOverlays(Ohio);
map.removeOverlays(Princeton);
map.removeOverlays(Sheffield);
map.removeOverlays(Spring_Valley);
map.removeOverlays(Tiskilwa);
map.removeOverlays(Van_Orin);
map.removeOverlays(Walnut);
map.removeOverlays(Wyanet);
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(La_Moille);map.removeOverlays(Buda);
map.removeOverlays(Bureau);
map.removeOverlays(Cherry);
map.removeOverlays(Dalzell);
map.removeOverlays(Depue);
map.removeOverlays(La_Moille);
map.removeOverlays(Ladd);
map.removeOverlays(Malden);
map.removeOverlays(Manlius);
map.removeOverlays(Neponset);
map.removeOverlays(Ohio);
map.removeOverlays(Princeton);
map.removeOverlays(Sheffield);
map.removeOverlays(Spring_Valley);
map.removeOverlays(Tiskilwa);
map.removeOverlays(Van_Orin);
map.removeOverlays(Walnut);
map.removeOverlays(Wyanet);
map.addOverlays(Buda);
centerByArray(Buda, false, false);
cntMarker += Buda.length;
map.addOverlays(Bureau);
centerByArray(Bureau, false, false);
cntMarker += Bureau.length;
map.addOverlays(Cherry);
centerByArray(Cherry, false, false);
cntMarker += Cherry.length;
map.addOverlays(Dalzell);
centerByArray(Dalzell, false, false);
cntMarker += Dalzell.length;
map.addOverlays(Depue);
centerByArray(Depue, false, false);
cntMarker += Depue.length;
map.addOverlays(La_Moille);
centerByArray(La_Moille, false, false);
cntMarker += La_Moille.length;
map.addOverlays(Ladd);
centerByArray(Ladd, false, false);
cntMarker += Ladd.length;
map.addOverlays(Malden);
centerByArray(Malden, false, false);
cntMarker += Malden.length;
map.addOverlays(Manlius);
centerByArray(Manlius, false, false);
cntMarker += Manlius.length;
map.addOverlays(Neponset);
centerByArray(Neponset, false, false);
cntMarker += Neponset.length;
map.addOverlays(Ohio);
centerByArray(Ohio, false, false);
cntMarker += Ohio.length;
map.addOverlays(Princeton);
centerByArray(Princeton, false, false);
cntMarker += Princeton.length;
map.addOverlays(Sheffield);
centerByArray(Sheffield, false, false);
cntMarker += Sheffield.length;
map.addOverlays(Spring_Valley);
centerByArray(Spring_Valley, false, false);
cntMarker += Spring_Valley.length;
map.addOverlays(Tiskilwa);
centerByArray(Tiskilwa, false, false);
cntMarker += Tiskilwa.length;
map.addOverlays(Van_Orin);
centerByArray(Van_Orin, false, false);
cntMarker += Van_Orin.length;
map.addOverlays(Walnut);
centerByArray(Walnut, false, false);
cntMarker += Walnut.length;
map.addOverlays(Wyanet);
centerByArray(Wyanet, false, false);
cntMarker += Wyanet.length;
centerByArray(La_Moille,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');
}
}