function addMarkers()
{
mySelect = document.getElementById('selection');
Ashkum = [];Milford = [];Clifton = [];Chebanse = [];Cissna_Park = [];Crescent_City = [];Donovan = [];Watseka = [];Danforth = [];Thawville = [];Gilman = [];Onarga = [];Paxton = [];Sheldon = [];Woodland = [];mySelect.options[mySelect.options.length] = new Option("Ashkum schools",'all=Ashkum');
mySelect.options[mySelect.options.length] = new Option("Chebanse schools",'all=Chebanse');
mySelect.options[mySelect.options.length] = new Option("Cissna Park schools",'all=Cissna_Park');
mySelect.options[mySelect.options.length] = new Option("Clifton schools",'all=Clifton');
mySelect.options[mySelect.options.length] = new Option("Crescent City schools",'all=Crescent_City');
mySelect.options[mySelect.options.length] = new Option("Danforth schools",'all=Danforth');
mySelect.options[mySelect.options.length] = new Option("Donovan schools",'all=Donovan');
mySelect.options[mySelect.options.length] = new Option("Gilman schools",'all=Gilman');
mySelect.options[mySelect.options.length] = new Option("Milford schools",'all=Milford');
mySelect.options[mySelect.options.length] = new Option("Onarga schools",'all=Onarga');
mySelect.options[mySelect.options.length] = new Option("Paxton schools",'all=Paxton');
mySelect.options[mySelect.options.length] = new Option("Sheldon schools",'all=Sheldon');
mySelect.options[mySelect.options.length] = new Option("Thawville schools",'all=Thawville');
mySelect.options[mySelect.options.length] = new Option("Watseka schools",'all=Watseka');
mySelect.options[mySelect.options.length] = new Option("Woodland schools",'all=Woodland');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Ashkum[Ashkum.length] = createMarker(new GPoint(-87.94869995,40.88130188),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ashkum Elementary School",'Ashkum=' + Ashkum.length);
Milford[Milford.length] = createMarker(new GPoint(-87.78791046,40.64723969),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bryce Ash Grove Ed Center",'Milford=' + Milford.length);
Clifton[Clifton.length] = createMarker(new GPoint(-87.90790558,40.95940781),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central High School",'Clifton=' + Clifton.length);
Chebanse[Chebanse.length] = createMarker(new GPoint(-87.90979767,41.00550079),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Chebanse Elementary School",'Chebanse=' + Chebanse.length);
Cissna_Park[Cissna_Park.length] = createMarker(new GPoint(-87.88240051,40.57929993),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cissna Park Elementary School",'Cissna_Park=' + Cissna_Park.length);
Cissna_Park[Cissna_Park.length] = createMarker(new GPoint(-87.88240051,40.57929993),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Cissna Park Junior High School",'Cissna_Park=' + Cissna_Park.length);
Cissna_Park[Cissna_Park.length] = createMarker(new GPoint(-87.88240051,40.57929993),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cissna Park Senior High School",'Cissna_Park=' + Cissna_Park.length);
Clifton[Clifton.length] = createMarker(new GPoint(-87.92839813,40.94110107),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Clifton Elementary School",'Clifton=' + Clifton.length);
Crescent_City[Crescent_City.length] = createMarker(new GPoint(-87.85936300,40.76997500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Crescent City C C Grade School",'Crescent_City=' + Crescent_City.length);
Crescent_City[Crescent_City.length] = createMarker(new GPoint(-87.85839844,40.76908875),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Crescent-iroquois High School",'Crescent_City=' + Crescent_City.length);
Donovan[Donovan.length] = createMarker(new GPoint(-87.64293671,40.89156342),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Donovan Elementary School",'Donovan=' + Donovan.length);
Donovan[Donovan.length] = createMarker(new GPoint(-87.60620117,40.88660049),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Donovan Junior High School",'Donovan=' + Donovan.length);
Donovan[Donovan.length] = createMarker(new GPoint(-87.60620117,40.88660049),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Donovan Senior High School",'Donovan=' + Donovan.length);
Watseka[Watseka.length] = createMarker(new GPoint(-87.73469543,40.77286148),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Glenn Raymond Middle School",'Watseka=' + Watseka.length);
Watseka[Watseka.length] = createMarker(new GPoint(-87.73120117,40.78129959),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Iroquois Area Rds",'Watseka=' + Watseka.length);
Danforth[Danforth.length] = createMarker(new GPoint(-87.99060059,40.82410049),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Iroquois West Elementary Sch/danforth",'Danforth=' + Danforth.length);
Thawville[Thawville.length] = createMarker(new GPoint(-88.09320068,40.68809891),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Iroquois West Elementary Sch/thawville",'Thawville=' + Thawville.length);
Gilman[Gilman.length] = createMarker(new GPoint(-87.99069977,40.76919937),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Iroquois West Elementary School/gilman",'Gilman=' + Gilman.length);
Gilman[Gilman.length] = createMarker(new GPoint(-87.99069977,40.76919937),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Iroquois West High School",'Gilman=' + Gilman.length);
Onarga[Onarga.length] = createMarker(new GPoint(-88.00998688,40.71817398),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Iroquois West Middle School",'Onarga=' + Onarga.length);
Clifton[Clifton.length] = createMarker(new GPoint(-87.90790558,40.95940781),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("John L Nash Middle School",'Clifton=' + Clifton.length);
Crescent_City[Crescent_City.length] = createMarker(new GPoint(-159.64289856,21.94050026),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kula Aupuni Ni'ihau A Kahelelani Aloha Nc Pcs",'Crescent_City=' + Crescent_City.length);
Paxton[Paxton.length] = createMarker(new GPoint(-88.10430145,40.45280075),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Loda Elementary School",'Paxton=' + Paxton.length);
Milford[Milford.length] = createMarker(new GPoint(-87.71739960,40.62749863),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Milford Grade School",'Milford=' + Milford.length);
Milford[Milford.length] = createMarker(new GPoint(-87.71739960,40.62749863),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Milford High School",'Milford=' + Milford.length);
Watseka[Watseka.length] = createMarker(new GPoint(-87.73297882,40.78024292),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Nettie Davis Elementary School",'Watseka=' + Watseka.length);
Onarga[Onarga.length] = createMarker(new GPoint(-88.00427246,40.71573257),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Nexus Education Center",'Onarga=' + Onarga.length);
Sheldon[Sheldon.length] = createMarker(new GPoint(-87.57187653,40.76949692),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sheldon Grade School",'Sheldon=' + Sheldon.length);
Sheldon[Sheldon.length] = createMarker(new GPoint(-87.57187653,40.76949692),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sheldon High School",'Sheldon=' + Sheldon.length);
Watseka[Watseka.length] = createMarker(new GPoint(-87.72370911,40.77024078),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wanda Kendall Elementary School",'Watseka=' + Watseka.length);
Watseka[Watseka.length] = createMarker(new GPoint(-87.72897339,40.77004623),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Watseka Comm High School",'Watseka=' + Watseka.length);
Woodland[Woodland.length] = createMarker(new GPoint(-87.73110199,40.71020126),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Woodland Elementary School",'Woodland=' + Woodland.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(Ashkum);
map.removeOverlays(Chebanse);
map.removeOverlays(Cissna_Park);
map.removeOverlays(Clifton);
map.removeOverlays(Crescent_City);
map.removeOverlays(Danforth);
map.removeOverlays(Donovan);
map.removeOverlays(Gilman);
map.removeOverlays(Milford);
map.removeOverlays(Onarga);
map.removeOverlays(Paxton);
map.removeOverlays(Sheldon);
map.removeOverlays(Thawville);
map.removeOverlays(Watseka);
map.removeOverlays(Woodland);
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(Ashkum);map.removeOverlays(Ashkum);
map.removeOverlays(Chebanse);
map.removeOverlays(Cissna_Park);
map.removeOverlays(Clifton);
map.removeOverlays(Crescent_City);
map.removeOverlays(Danforth);
map.removeOverlays(Donovan);
map.removeOverlays(Gilman);
map.removeOverlays(Milford);
map.removeOverlays(Onarga);
map.removeOverlays(Paxton);
map.removeOverlays(Sheldon);
map.removeOverlays(Thawville);
map.removeOverlays(Watseka);
map.removeOverlays(Woodland);
map.addOverlays(Ashkum);
centerByArray(Ashkum, false, false);
cntMarker += Ashkum.length;
map.addOverlays(Chebanse);
centerByArray(Chebanse, false, false);
cntMarker += Chebanse.length;
map.addOverlays(Cissna_Park);
centerByArray(Cissna_Park, false, false);
cntMarker += Cissna_Park.length;
map.addOverlays(Clifton);
centerByArray(Clifton, false, false);
cntMarker += Clifton.length;
map.addOverlays(Crescent_City);
centerByArray(Crescent_City, false, false);
cntMarker += Crescent_City.length;
map.addOverlays(Danforth);
centerByArray(Danforth, false, false);
cntMarker += Danforth.length;
map.addOverlays(Donovan);
centerByArray(Donovan, false, false);
cntMarker += Donovan.length;
map.addOverlays(Gilman);
centerByArray(Gilman, false, false);
cntMarker += Gilman.length;
map.addOverlays(Milford);
centerByArray(Milford, false, false);
cntMarker += Milford.length;
map.addOverlays(Onarga);
centerByArray(Onarga, false, false);
cntMarker += Onarga.length;
map.addOverlays(Paxton);
centerByArray(Paxton, false, false);
cntMarker += Paxton.length;
map.addOverlays(Sheldon);
centerByArray(Sheldon, false, false);
cntMarker += Sheldon.length;
map.addOverlays(Thawville);
centerByArray(Thawville, false, false);
cntMarker += Thawville.length;
map.addOverlays(Watseka);
centerByArray(Watseka, false, false);
cntMarker += Watseka.length;
map.addOverlays(Woodland);
centerByArray(Woodland, false, false);
cntMarker += Woodland.length;
centerByArray(Ashkum,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');
}
}