function addMarkers()
{
mySelect = document.getElementById('selection');
Clinton_Township = [];Clinton_Township[Clinton_Township.length] = createMarker(new GPoint(-82.92440033,42.57086945),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Algonquin Middle School",'Clinton_Township=' + Clinton_Township.length);
Clinton_Township[Clinton_Township.length] = createMarker(new GPoint(-82.90261841,42.56162262),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Charles C. Mcglinnen School",'Clinton_Township=' + Clinton_Township.length);
Clinton_Township[Clinton_Township.length] = createMarker(new GPoint(-82.92282867,42.61409378),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cherokee Elementary School",'Clinton_Township=' + Clinton_Township.length);
Clinton_Township[Clinton_Township.length] = createMarker(new GPoint(-82.92686700,42.60900800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chippewa Valley Adult & Mohegan Alt. Educ.",'Clinton_Township=' + Clinton_Township.length);
Clinton_Township[Clinton_Township.length] = createMarker(new GPoint(-82.93600464,42.61334991),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chippewa Valley High School",'Clinton_Township=' + Clinton_Township.length);
Clinton_Township[Clinton_Township.length] = createMarker(new GPoint(-82.89831543,42.58315659),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clinton Valley Elementary School",'Clinton_Township=' + Clinton_Township.length);
Clinton_Township[Clinton_Township.length] = createMarker(new GPoint(-82.91036224,42.55572891),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Clintondale High School",'Clinton_Township=' + Clinton_Township.length);
Clinton_Township[Clinton_Township.length] = createMarker(new GPoint(-82.91040039,42.55659485),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Clintondale Middle School",'Clinton_Township=' + Clinton_Township.length);
Clinton_Township[Clinton_Township.length] = createMarker(new GPoint(-82.89129900,42.56230800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Continuing Education Center",'Clinton_Township=' + Clinton_Township.length);
Clinton_Township[Clinton_Township.length] = createMarker(new GPoint(-82.96050262,42.55499268),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Einstein Center",'Clinton_Township=' + Clinton_Township.length);
Clinton_Township[Clinton_Township.length] = createMarker(new GPoint(-82.93249512,42.60560226),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Erie Elementary School",'Clinton_Township=' + Clinton_Township.length);
Clinton_Township[Clinton_Township.length] = createMarker(new GPoint(-82.90213900,42.58763000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Frederick V. Pankow Center",'Clinton_Township=' + Clinton_Township.length);
Clinton_Township[Clinton_Township.length] = createMarker(new GPoint(-82.96326447,42.59100723),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Huron Elementary School",'Clinton_Township=' + Clinton_Township.length);
Clinton_Township[Clinton_Township.length] = createMarker(new GPoint(-82.92275238,42.60805511),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lutz School For Work Experience",'Clinton_Township=' + Clinton_Township.length);
Clinton_Township[Clinton_Township.length] = createMarker(new GPoint(-82.95174408,42.58445358),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Macomb Academy",'Clinton_Township=' + Clinton_Township.length);
Clinton_Township[Clinton_Township.length] = createMarker(new GPoint(-82.96061707,42.56018066),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Macomb Mipp Center",'Clinton_Township=' + Clinton_Township.length);
Clinton_Township[Clinton_Township.length] = createMarker(new GPoint(-82.95989990,42.60175323),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Miami Elementary School",'Clinton_Township=' + Clinton_Township.length);
Clinton_Township[Clinton_Township.length] = createMarker(new GPoint(-82.87161255,42.57421112),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Neil E. Reid High School",'Clinton_Township=' + Clinton_Township.length);
Clinton_Township[Clinton_Township.length] = createMarker(new GPoint(-82.93227386,42.57338333),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ottawa Elementary School",'Clinton_Township=' + Clinton_Township.length);
Clinton_Township[Clinton_Township.length] = createMarker(new GPoint(-82.91356659,42.54461288),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Rainbow Elementary School",'Clinton_Township=' + Clinton_Township.length);
Clinton_Township[Clinton_Township.length] = createMarker(new GPoint(-82.89355469,42.54738617),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Robbie Hall Parker School",'Clinton_Township=' + Clinton_Township.length);
Clinton_Township[Clinton_Township.length] = createMarker(new GPoint(-82.94281769,42.55369568),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Salk Elementary School",'Clinton_Township=' + Clinton_Township.length);
Clinton_Township[Clinton_Township.length] = createMarker(new GPoint(-82.93266296,42.60960770),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Seneca Middle School",'Clinton_Township=' + Clinton_Township.length);
Clinton_Township[Clinton_Township.length] = createMarker(new GPoint(-82.87690735,42.56056595),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Tenniswood Elementary School",'Clinton_Township=' + Clinton_Township.length);
Clinton_Township[Clinton_Township.length] = createMarker(new GPoint(-82.93232727,42.56238174),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Walt Disney Elementary School",'Clinton_Township=' + Clinton_Township.length);
Clinton_Township[Clinton_Township.length] = createMarker(new GPoint(-82.95203400,42.58726883),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Wyandot Middle School",'Clinton_Township=' + Clinton_Township.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(Clinton_Township);
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(Clinton_Township);map.removeOverlays(Clinton_Township);
map.addOverlays(Clinton_Township);
centerByArray(Clinton_Township, false, false);
cntMarker += Clinton_Township.length;
centerByArray(Clinton_Township,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');
}
}