function addMarkers()
{
mySelect = document.getElementById('selection');
Bath = [];St_Johns = [];Perry = [];Dewitt = [];Elsie = [];Eureka = [];Fowler = [];Lansing = [];Ovid = [];Pewamo = [];Eagle = [];Westphalia = [];mySelect.options[mySelect.options.length] = new Option("Bath schools",'all=Bath');
mySelect.options[mySelect.options.length] = new Option("Dewitt schools",'all=Dewitt');
mySelect.options[mySelect.options.length] = new Option("Eagle schools",'all=Eagle');
mySelect.options[mySelect.options.length] = new Option("Elsie schools",'all=Elsie');
mySelect.options[mySelect.options.length] = new Option("Eureka schools",'all=Eureka');
mySelect.options[mySelect.options.length] = new Option("Fowler schools",'all=Fowler');
mySelect.options[mySelect.options.length] = new Option("Lansing schools",'all=Lansing');
mySelect.options[mySelect.options.length] = new Option("Ovid schools",'all=Ovid');
mySelect.options[mySelect.options.length] = new Option("Perry schools",'all=Perry');
mySelect.options[mySelect.options.length] = new Option("Pewamo schools",'all=Pewamo');
mySelect.options[mySelect.options.length] = new Option("St Johns schools",'all=St_Johns');
mySelect.options[mySelect.options.length] = new Option("Westphalia schools",'all=Westphalia');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Bath[Bath.length] = createMarker(new GPoint(-84.45709991,42.81299973),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bath Elementary School",'Bath=' + Bath.length);
Bath[Bath.length] = createMarker(new GPoint(-84.45709991,42.81299973),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bath High School",'Bath=' + Bath.length);
Bath[Bath.length] = createMarker(new GPoint(-84.45709991,42.81299973),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bath Middle School",'Bath=' + Bath.length);
St_Johns[St_Johns.length] = createMarker(new GPoint(-84.55902100,43.00139999),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Clinton County Education Center",'St_Johns=' + St_Johns.length);
Perry[Perry.length] = createMarker(new GPoint(-84.21360016,42.83398819),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Corcoran Center",'Perry=' + Perry.length);
Dewitt[Dewitt.length] = createMarker(new GPoint(-84.57330322,42.84170151),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Dewitt High School",'Dewitt=' + Dewitt.length);
Dewitt[Dewitt.length] = createMarker(new GPoint(-84.55090332,42.83797836),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Dewitt Junior High School",'Dewitt=' + Dewitt.length);
Elsie[Elsie.length] = createMarker(new GPoint(-84.39248657,43.09000015),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("E.e. Knight Elementary School",'Elsie=' + Elsie.length);
St_Johns[St_Johns.length] = createMarker(new GPoint(-84.63158417,43.06776428),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("East Essex School",'St_Johns=' + St_Johns.length);
St_Johns[St_Johns.length] = createMarker(new GPoint(-84.56179810,43.00979996),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("East Olive Elementary School",'St_Johns=' + St_Johns.length);
Eureka[Eureka.length] = createMarker(new GPoint(-84.51380157,43.10359955),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Eureka School",'Eureka=' + Eureka.length);
Fowler[Fowler.length] = createMarker(new GPoint(-84.73965454,42.98722458),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fowler High School",'Fowler=' + Fowler.length);
Dewitt[Dewitt.length] = createMarker(new GPoint(-84.57042694,42.84133530),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fuerstenau Early Childhood Center",'Dewitt=' + Dewitt.length);
St_Johns[St_Johns.length] = createMarker(new GPoint(-84.56288910,43.01123047),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Gateway Elementary School",'St_Johns=' + St_Johns.length);
Lansing[Lansing.length] = createMarker(new GPoint(-84.52796173,42.81296158),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Gunnisonville School",'Lansing=' + Lansing.length);
Dewitt[Dewitt.length] = createMarker(new GPoint(-84.57330322,42.84170151),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Herbison Woods Elementary School",'Dewitt=' + Dewitt.length);
Ovid[Ovid.length] = createMarker(new GPoint(-84.37197876,43.01127243),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("North Elementary School",'Ovid=' + Ovid.length);
St_Johns[St_Johns.length] = createMarker(new GPoint(-84.55848694,42.98784637),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Oakview Elementary School",'St_Johns=' + St_Johns.length);
Elsie[Elsie.length] = createMarker(new GPoint(-84.38738251,43.04523849),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ovid-elsie Comm. Ed./alt. H.s.",'Elsie=' + Elsie.length);
Elsie[Elsie.length] = createMarker(new GPoint(-84.38738251,43.04523849),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ovid-elsie High School",'Elsie=' + Elsie.length);
Elsie[Elsie.length] = createMarker(new GPoint(-84.38719177,43.04582214),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Ovid-elsie Middle School",'Elsie=' + Elsie.length);
Pewamo[Pewamo.length] = createMarker(new GPoint(-84.83740997,42.94228363),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pewamo-westphalia High School",'Pewamo=' + Pewamo.length);
Pewamo[Pewamo.length] = createMarker(new GPoint(-84.83740997,42.94228363),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Pewamo-westphalia Junior H.s Middle School",'Pewamo=' + Pewamo.length);
Pewamo[Pewamo.length] = createMarker(new GPoint(-84.83740997,42.94228363),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Pewamo-westphalia Junior High School",'Pewamo=' + Pewamo.length);
St_Johns[St_Johns.length] = createMarker(new GPoint(-84.56179810,43.00979996),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Riley Elementary School",'St_Johns=' + St_Johns.length);
St_Johns[St_Johns.length] = createMarker(new GPoint(-84.56179810,43.00979996),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Saint Johns High School",'St_Johns=' + St_Johns.length);
St_Johns[St_Johns.length] = createMarker(new GPoint(-84.56681061,42.98705292),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Saint Johns Middle School",'St_Johns=' + St_Johns.length);
Dewitt[Dewitt.length] = createMarker(new GPoint(-84.57330322,42.84170151),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Schavey Road Elementary School",'Dewitt=' + Dewitt.length);
Dewitt[Dewitt.length] = createMarker(new GPoint(-84.57330322,42.84170151),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Scott Elementary School",'Dewitt=' + Dewitt.length);
Lansing[Lansing.length] = createMarker(new GPoint(-84.54668427,42.77093887),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sheridan Road School",'Lansing=' + Lansing.length);
Eagle[Eagle.length] = createMarker(new GPoint(-84.70400238,42.82782364),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wacousta Elementary School",'Eagle=' + Eagle.length);
Fowler[Fowler.length] = createMarker(new GPoint(-84.74227905,43.00643158),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Waldron Elementary & Middle School",'Fowler=' + Fowler.length);
Westphalia[Westphalia.length] = createMarker(new GPoint(-84.80308533,42.93056870),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Westphalia Elementary School",'Westphalia=' + Westphalia.length);
St_Johns[St_Johns.length] = createMarker(new GPoint(-84.55852600,43.00015200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wilson Center",'St_Johns=' + St_Johns.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(Bath);
map.removeOverlays(Dewitt);
map.removeOverlays(Eagle);
map.removeOverlays(Elsie);
map.removeOverlays(Eureka);
map.removeOverlays(Fowler);
map.removeOverlays(Lansing);
map.removeOverlays(Ovid);
map.removeOverlays(Perry);
map.removeOverlays(Pewamo);
map.removeOverlays(St_Johns);
map.removeOverlays(Westphalia);
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(Bath);map.removeOverlays(Bath);
map.removeOverlays(Dewitt);
map.removeOverlays(Eagle);
map.removeOverlays(Elsie);
map.removeOverlays(Eureka);
map.removeOverlays(Fowler);
map.removeOverlays(Lansing);
map.removeOverlays(Ovid);
map.removeOverlays(Perry);
map.removeOverlays(Pewamo);
map.removeOverlays(St_Johns);
map.removeOverlays(Westphalia);
map.addOverlays(Bath);
centerByArray(Bath, false, false);
cntMarker += Bath.length;
map.addOverlays(Dewitt);
centerByArray(Dewitt, false, false);
cntMarker += Dewitt.length;
map.addOverlays(Eagle);
centerByArray(Eagle, false, false);
cntMarker += Eagle.length;
map.addOverlays(Elsie);
centerByArray(Elsie, false, false);
cntMarker += Elsie.length;
map.addOverlays(Eureka);
centerByArray(Eureka, false, false);
cntMarker += Eureka.length;
map.addOverlays(Fowler);
centerByArray(Fowler, false, false);
cntMarker += Fowler.length;
map.addOverlays(Lansing);
centerByArray(Lansing, false, false);
cntMarker += Lansing.length;
map.addOverlays(Ovid);
centerByArray(Ovid, false, false);
cntMarker += Ovid.length;
map.addOverlays(Perry);
centerByArray(Perry, false, false);
cntMarker += Perry.length;
map.addOverlays(Pewamo);
centerByArray(Pewamo, false, false);
cntMarker += Pewamo.length;
map.addOverlays(St_Johns);
centerByArray(St_Johns, false, false);
cntMarker += St_Johns.length;
map.addOverlays(Westphalia);
centerByArray(Westphalia, false, false);
cntMarker += Westphalia.length;
centerByArray(Bath,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');
}
}