function addMarkers()
{
mySelect = document.getElementById('selection');
Battle_Creek = [];Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.15518188,42.31310272),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Alternative Community Educat",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.19293976,42.32680511),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ann J. Kellogg School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.21383667,42.30228806),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Arbor Academy",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.23368073,42.26076126),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Battle Creek Area Learning Center",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.18197632,42.32232666),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Battle Creek Central High School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.22512817,42.32233047),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Battle Creek Math-sci Center",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.13561249,42.27223587),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Beadle Lake Elementary School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.17337799,42.33935165),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calhoun Area Technology Center",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.20628357,42.31010056),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Coburn School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.13535309,42.32294846),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Doris Klaussen Dev. Center",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.20043945,42.33847809),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dudley School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.17968750,42.32114410),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Early Childhood Education Elementary School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.23368073,42.26076126),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Early Childhood-prep Elementary School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.17306519,42.30812073),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Franklin School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.17519379,42.32995224),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fremont School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.15338898,42.26115036),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Harper Creek High School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.15039062,42.26116180),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Harper Creek Junior High School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.21408844,42.30332184),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lakeview Alternative Educati High School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.22858429,42.29565048),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lakeview High School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.21655273,42.30311203),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Lakeview Junior High School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.24210358,42.34999847),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lamora Park School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.20256042,42.32753754),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Level Park School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.16719818,42.32359314),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mckinley Elementary School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.21391296,42.30377960),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Michigan School Readiness Preschool",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.21649933,42.39540100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Michigan Youth Challenge Academy",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.19624329,42.27721024),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Minges Brook School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.21002960,42.33895493),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Northwestern Junior High School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.20999908,42.33885193),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Northwestern Middle School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.18093109,42.31734467),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Operation Graduation High School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.13050079,42.37013626),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Pennfield Central School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.13050079,42.37013626),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Pennfield Dunlap Middle School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.13050079,42.37013626),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pennfield North School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.13050079,42.37013626),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pennfield Purdy School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.13050079,42.37013626),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pennfield Senior High School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.15869141,42.30956268),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Post Elementary School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.20706177,42.30114746),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Prairieview School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.18932343,42.29049683),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Riverside Elementary School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.19662476,42.30859375),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Roosevelt School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.19451904,42.23196411),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sonoma School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.15511322,42.31313705),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Hill Academy",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.19628143,42.31296158),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Southwestern Academy",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.19609070,42.31278229),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Southwestern Junior High School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.21408844,42.30332184),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Territorial School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.23107147,42.34044266),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Urbandale School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.15560913,42.33179855),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Verona School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.18110657,42.32172775),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("W.k. Kellogg Junior High School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.18104553,42.32187653),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("W.k. Kellogg Middle School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.19021606,42.33886337),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Washington Academy",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.19036865,42.33864212),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Washington School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.11116028,42.30719376),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wattles Park Elementary School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.22799683,42.28720856),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Westlake Elementary School",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.20240021,42.31713486),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wilson Academy",'Battle_Creek=' + Battle_Creek.length);
Battle_Creek[Battle_Creek.length] = createMarker(new GPoint(-85.22000122,42.30009842),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wilson School",'Battle_Creek=' + Battle_Creek.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(Battle_Creek);
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(Battle_Creek);map.removeOverlays(Battle_Creek);
map.addOverlays(Battle_Creek);
centerByArray(Battle_Creek, false, false);
cntMarker += Battle_Creek.length;
centerByArray(Battle_Creek,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');
}
}