function addMarkers()
{
mySelect = document.getElementById('selection');
Allegan = [];Otsego = [];Fennville = [];South_Haven = [];Hamilton = [];Wayland = [];Holland = [];Dorr = [];Douglas = [];Plainwell = [];Glenn = [];Hopkins = [];Martin = [];Moline = [];Bloomingdale = [];Saugatuck = [];mySelect.options[mySelect.options.length] = new Option("Allegan schools",'all=Allegan');
mySelect.options[mySelect.options.length] = new Option("Bloomingdale schools",'all=Bloomingdale');
mySelect.options[mySelect.options.length] = new Option("Dorr schools",'all=Dorr');
mySelect.options[mySelect.options.length] = new Option("Douglas schools",'all=Douglas');
mySelect.options[mySelect.options.length] = new Option("Fennville schools",'all=Fennville');
mySelect.options[mySelect.options.length] = new Option("Glenn schools",'all=Glenn');
mySelect.options[mySelect.options.length] = new Option("Hamilton schools",'all=Hamilton');
mySelect.options[mySelect.options.length] = new Option("Holland schools",'all=Holland');
mySelect.options[mySelect.options.length] = new Option("Hopkins schools",'all=Hopkins');
mySelect.options[mySelect.options.length] = new Option("Martin schools",'all=Martin');
mySelect.options[mySelect.options.length] = new Option("Moline schools",'all=Moline');
mySelect.options[mySelect.options.length] = new Option("Otsego schools",'all=Otsego');
mySelect.options[mySelect.options.length] = new Option("Plainwell schools",'all=Plainwell');
mySelect.options[mySelect.options.length] = new Option("Saugatuck schools",'all=Saugatuck');
mySelect.options[mySelect.options.length] = new Option("South Haven schools",'all=South_Haven');
mySelect.options[mySelect.options.length] = new Option("Wayland schools",'all=Wayland');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Allegan[Allegan.length] = createMarker(new GPoint(-85.84322357,42.52327347),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Allegan Alternative High School",'Allegan=' + Allegan.length);
Allegan[Allegan.length] = createMarker(new GPoint(-85.82702637,42.53483582),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Allegan Co. Area Math/science Ed. Center",'Allegan=' + Allegan.length);
Allegan[Allegan.length] = createMarker(new GPoint(-85.85824585,42.52687454),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Allegan Co. Development Center",'Allegan=' + Allegan.length);
Otsego[Otsego.length] = createMarker(new GPoint(-85.69856262,42.46061707),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Allegan County Even Start Elementary School",'Otsego=' + Otsego.length);
Allegan[Allegan.length] = createMarker(new GPoint(-85.86926270,42.58149719),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Allegan County Youth Home",'Allegan=' + Allegan.length);
Otsego[Otsego.length] = createMarker(new GPoint(-85.70230103,42.46143723),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Allegan Elementary School",'Otsego=' + Otsego.length);
Allegan[Allegan.length] = createMarker(new GPoint(-85.84322357,42.52327347),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Allegan High School",'Allegan=' + Allegan.length);
Otsego[Otsego.length] = createMarker(new GPoint(-85.70230103,42.46143723),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Allegan Street Elementary School",'Otsego=' + Otsego.length);
Fennville[Fennville.length] = createMarker(new GPoint(-86.15309906,42.58160019),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Anna Michen Elementary School",'Fennville=' + Fennville.length);
Fennville[Fennville.length] = createMarker(new GPoint(-86.15309906,42.58160019),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Anna Michen Lower Elementary School",'Fennville=' + Fennville.length);
Fennville[Fennville.length] = createMarker(new GPoint(-86.15309906,42.58160019),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Anna Michen Upper Elementary School",'Fennville=' + Fennville.length);
Allegan[Allegan.length] = createMarker(new GPoint(-85.82826233,42.53450012),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Area Technical & Ed. Center",'Allegan=' + Allegan.length);
South_Haven[South_Haven.length] = createMarker(new GPoint(-86.18722534,42.41923523),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Baseline Middle School",'South_Haven=' + South_Haven.length);
Hamilton[Hamilton.length] = createMarker(new GPoint(-85.91886139,42.71452332),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bentheim Elementary School",'Hamilton=' + Hamilton.length);
Wayland[Wayland.length] = createMarker(new GPoint(-85.64935303,42.67146301),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bessie B. Baker School",'Wayland=' + Wayland.length);
Holland[Holland.length] = createMarker(new GPoint(-86.11399841,42.70057297),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Blue Star Elementary School",'Holland=' + Holland.length);
Allegan[Allegan.length] = createMarker(new GPoint(-85.84322357,42.52327347),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dawson Elementary School",'Allegan=' + Allegan.length);
Fennville[Fennville.length] = createMarker(new GPoint(-86.15309906,42.58160019),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Discovery Elementary School",'Fennville=' + Fennville.length);
Otsego[Otsego.length] = createMarker(new GPoint(-85.68996429,42.45212173),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dix Street Elementary School",'Otsego=' + Otsego.length);
Dorr[Dorr.length] = createMarker(new GPoint(-85.72180939,42.72218704),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dorr School",'Dorr=' + Dorr.length);
Douglas[Douglas.length] = createMarker(new GPoint(-86.20050049,42.64329910),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Douglas Elementary School",'Douglas=' + Douglas.length);
Wayland[Wayland.length] = createMarker(new GPoint(-85.56473541,42.66622925),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Environmental Education Center",'Wayland=' + Wayland.length);
Fennville[Fennville.length] = createMarker(new GPoint(-86.15309906,42.58160019),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fennville High School",'Fennville=' + Fennville.length);
Fennville[Fennville.length] = createMarker(new GPoint(-86.15309906,42.58160019),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Fennville Middle School",'Fennville=' + Fennville.length);
Fennville[Fennville.length] = createMarker(new GPoint(-86.15309906,42.58160019),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fennville Public High School",'Fennville=' + Fennville.length);
Plainwell[Plainwell.length] = createMarker(new GPoint(-85.63890076,42.43706894),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Gilkey Elementary School",'Plainwell=' + Plainwell.length);
Glenn[Glenn.length] = createMarker(new GPoint(-86.23020172,42.52230072),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Glenn Elementary School",'Glenn=' + Glenn.length);
Glenn[Glenn.length] = createMarker(new GPoint(-86.23020172,42.52230072),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Glenn Public School",'Glenn=' + Glenn.length);
Hamilton[Hamilton.length] = createMarker(new GPoint(-85.98249817,42.67950058),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hamilton Elementary School",'Hamilton=' + Hamilton.length);
Hamilton[Hamilton.length] = createMarker(new GPoint(-85.98249817,42.67950058),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hamilton High School",'Hamilton=' + Hamilton.length);
Hamilton[Hamilton.length] = createMarker(new GPoint(-85.98249817,42.67950058),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Hamilton Middle School",'Hamilton=' + Hamilton.length);
Hopkins[Hopkins.length] = createMarker(new GPoint(-85.74420166,42.62789917),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hopkins Elementary School",'Hopkins=' + Hopkins.length);
Hopkins[Hopkins.length] = createMarker(new GPoint(-85.74420166,42.62789917),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hopkins High School",'Hopkins=' + Hopkins.length);
Hopkins[Hopkins.length] = createMarker(new GPoint(-85.76093292,42.62302399),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Hopkins Middle School",'Hopkins=' + Hopkins.length);
Allegan[Allegan.length] = createMarker(new GPoint(-85.84322357,42.52327347),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("L.e. White Middle School",'Allegan=' + Allegan.length);
Holland[Holland.length] = createMarker(new GPoint(-86.10698700,42.76853943),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Maplewood Elementary School",'Holland=' + Holland.length);
Martin[Martin.length] = createMarker(new GPoint(-85.63870239,42.53839874),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Martin High School",'Martin=' + Martin.length);
Moline[Moline.length] = createMarker(new GPoint(-85.66362762,42.73926926),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Moline School",'Moline=' + Moline.length);
Allegan[Allegan.length] = createMarker(new GPoint(-85.84322357,42.52327347),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("North Ward Elementary School",'Allegan=' + Allegan.length);
Otsego[Otsego.length] = createMarker(new GPoint(-85.69611900,42.46038000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Otsego High School",'Otsego=' + Otsego.length);
Otsego[Otsego.length] = createMarker(new GPoint(-85.70948029,42.45383835),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Otsego Middle School",'Otsego=' + Otsego.length);
Allegan[Allegan.length] = createMarker(new GPoint(-85.86017609,42.51771545),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Outlook Academy",'Allegan=' + Allegan.length);
Fennville[Fennville.length] = createMarker(new GPoint(-86.10456000,42.59971100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pearl Alternative/adult Education School",'Fennville=' + Fennville.length);
Wayland[Wayland.length] = createMarker(new GPoint(-85.64469910,42.67276382),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Pine Street Elementary School",'Wayland=' + Wayland.length);
Allegan[Allegan.length] = createMarker(new GPoint(-85.84350100,42.52283300),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pine Trails Elementary School",'Allegan=' + Allegan.length);
Plainwell[Plainwell.length] = createMarker(new GPoint(-85.64852905,42.43536377),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Plainwell High School",'Plainwell=' + Plainwell.length);
Plainwell[Plainwell.length] = createMarker(new GPoint(-85.64898682,42.43645477),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Plainwell Middle School",'Plainwell=' + Plainwell.length);
Plainwell[Plainwell.length] = createMarker(new GPoint(-85.64183900,42.44278900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Plainwell Young Adult Program",'Plainwell=' + Plainwell.length);
Bloomingdale[Bloomingdale.length] = createMarker(new GPoint(-85.96630096,42.37779999),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pullman Elementary School",'Bloomingdale=' + Bloomingdale.length);
Wayland[Wayland.length] = createMarker(new GPoint(-85.63672638,42.67393875),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("R.j. Steeby School",'Wayland=' + Wayland.length);
Plainwell[Plainwell.length] = createMarker(new GPoint(-85.63061523,42.44832993),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Renaissance High School",'Plainwell=' + Plainwell.length);
Martin[Martin.length] = createMarker(new GPoint(-85.63870239,42.53839874),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Robert D. Brandon Elementary School",'Martin=' + Martin.length);
Holland[Holland.length] = createMarker(new GPoint(-85.99845123,42.73355103),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sandyview School",'Holland=' + Holland.length);
Saugatuck[Saugatuck.length] = createMarker(new GPoint(-86.19831848,42.65775681),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Saugatuck High School",'Saugatuck=' + Saugatuck.length);
Saugatuck[Saugatuck.length] = createMarker(new GPoint(-86.19831848,42.65775681),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Saugatuck Middle School",'Saugatuck=' + Saugatuck.length);
Allegan[Allegan.length] = createMarker(new GPoint(-85.84322357,42.52327347),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Ward Alt. Ed School",'Allegan=' + Allegan.length);
Plainwell[Plainwell.length] = createMarker(new GPoint(-85.65235901,42.43680954),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Starr Elementary School",'Plainwell=' + Plainwell.length);
Dorr[Dorr.length] = createMarker(new GPoint(-85.76394653,42.72519684),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sycamore Elementary School",'Dorr=' + Dorr.length);
Wayland[Wayland.length] = createMarker(new GPoint(-85.62898254,42.67366409),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wayland High School",'Wayland=' + Wayland.length);
Wayland[Wayland.length] = createMarker(new GPoint(-85.62802124,42.66324234),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Wayland Union Middle School",'Wayland=' + Wayland.length);
Wayland[Wayland.length] = createMarker(new GPoint(-85.64173126,42.67439651),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wayland Young Adult Program",'Wayland=' + Wayland.length);
Allegan[Allegan.length] = createMarker(new GPoint(-85.84322357,42.52327347),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("West Ward Elementary School",'Allegan=' + Allegan.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(Allegan);
map.removeOverlays(Bloomingdale);
map.removeOverlays(Dorr);
map.removeOverlays(Douglas);
map.removeOverlays(Fennville);
map.removeOverlays(Glenn);
map.removeOverlays(Hamilton);
map.removeOverlays(Holland);
map.removeOverlays(Hopkins);
map.removeOverlays(Martin);
map.removeOverlays(Moline);
map.removeOverlays(Otsego);
map.removeOverlays(Plainwell);
map.removeOverlays(Saugatuck);
map.removeOverlays(South_Haven);
map.removeOverlays(Wayland);
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(Allegan);map.removeOverlays(Allegan);
map.removeOverlays(Bloomingdale);
map.removeOverlays(Dorr);
map.removeOverlays(Douglas);
map.removeOverlays(Fennville);
map.removeOverlays(Glenn);
map.removeOverlays(Hamilton);
map.removeOverlays(Holland);
map.removeOverlays(Hopkins);
map.removeOverlays(Martin);
map.removeOverlays(Moline);
map.removeOverlays(Otsego);
map.removeOverlays(Plainwell);
map.removeOverlays(Saugatuck);
map.removeOverlays(South_Haven);
map.removeOverlays(Wayland);
map.addOverlays(Allegan);
centerByArray(Allegan, false, false);
cntMarker += Allegan.length;
map.addOverlays(Bloomingdale);
centerByArray(Bloomingdale, false, false);
cntMarker += Bloomingdale.length;
map.addOverlays(Dorr);
centerByArray(Dorr, false, false);
cntMarker += Dorr.length;
map.addOverlays(Douglas);
centerByArray(Douglas, false, false);
cntMarker += Douglas.length;
map.addOverlays(Fennville);
centerByArray(Fennville, false, false);
cntMarker += Fennville.length;
map.addOverlays(Glenn);
centerByArray(Glenn, false, false);
cntMarker += Glenn.length;
map.addOverlays(Hamilton);
centerByArray(Hamilton, false, false);
cntMarker += Hamilton.length;
map.addOverlays(Holland);
centerByArray(Holland, false, false);
cntMarker += Holland.length;
map.addOverlays(Hopkins);
centerByArray(Hopkins, false, false);
cntMarker += Hopkins.length;
map.addOverlays(Martin);
centerByArray(Martin, false, false);
cntMarker += Martin.length;
map.addOverlays(Moline);
centerByArray(Moline, false, false);
cntMarker += Moline.length;
map.addOverlays(Otsego);
centerByArray(Otsego, false, false);
cntMarker += Otsego.length;
map.addOverlays(Plainwell);
centerByArray(Plainwell, false, false);
cntMarker += Plainwell.length;
map.addOverlays(Saugatuck);
centerByArray(Saugatuck, false, false);
cntMarker += Saugatuck.length;
map.addOverlays(South_Haven);
centerByArray(South_Haven, false, false);
cntMarker += South_Haven.length;
map.addOverlays(Wayland);
centerByArray(Wayland, false, false);
cntMarker += Wayland.length;
centerByArray(Allegan,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');
}
}