function addMarkers()
{
mySelect = document.getElementById('selection');
Sterling_Heights = [];Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.01108551,42.58605194),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Adlai Stevenson High School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.07530975,42.53981781),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Angus Elementary School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.00371552,42.61004257),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bemis Junior High School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-82.98348999,42.54367828),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Black Elementary School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.00646210,42.55596161),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bozymowski Center",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.00646210,42.55596161),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bozymowski Center Middle School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.00444794,42.61002731),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Browning Elementary School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-82.99710083,42.56337357),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bruce Collins Elementary School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.07073975,42.59701157),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Burr Elementary School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.00350952,42.55181885),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Career Preparation Center",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.02056885,42.55134583),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Carleton Middle School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.01497650,42.57892609),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Davis Junior High School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.00688171,42.58375168),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dekeyser Elementary School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.01512909,42.61293793),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dresden Elementary School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.02197266,42.54608917),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fillmore Elementary School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.08010101,42.57122421),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Flynn Middle School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.07955170,42.58958817),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Frank Jeannette Junior High School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.05566406,42.53605652),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Fuhrmann Middle School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-82.98228455,42.60311890),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Graebner Elementary School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.06973267,42.55505753),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Grissom Middle School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.05911255,42.53986359),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Harwood Elementary School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.05508423,42.55121231),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hatherly Elementary School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-82.99212646,42.60212326),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Havel Elementary School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.01072693,42.60216141),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Henry Ford Ii High School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.01016998,42.56941223),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Heritage Junior High School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.08158875,42.56871033),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Holden Elementary School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.01436615,42.56654739),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Huron Academy",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-82.99880219,42.60110092),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jack Harvey Elementary School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.06558228,42.57034683),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.00269318,42.62402344),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Magahay Elementary School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.01271057,42.54823685),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Maple Lane School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.02169037,42.57710266),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Messmore Elementary School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.01536560,42.56264496),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Naomi Gibbing Elementary School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.00577545,42.57046127),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Oakbrook Elementary School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.02140808,42.58436203),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Plumbrook Elementary School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-82.99726105,42.57889557),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Rose Kidd Elementary School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.08161163,42.58276367),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Schuchard Elementary School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.02571106,42.59173584),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Schwarzkoff Elementary School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-82.99798584,42.55214310),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sterling Heights Senior High School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.07528687,42.56017303),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Thorpe Elementary School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-82.99690247,42.64294052),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Utica Learning Academy",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.01088715,42.58023071),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Walsh Elementary School",'Sterling_Heights=' + Sterling_Heights.length);
Sterling_Heights[Sterling_Heights.length] = createMarker(new GPoint(-83.01880646,42.55573654),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Willow Woods Elementary School",'Sterling_Heights=' + Sterling_Heights.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(Sterling_Heights);
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(Sterling_Heights);map.removeOverlays(Sterling_Heights);
map.addOverlays(Sterling_Heights);
centerByArray(Sterling_Heights, false, false);
cntMarker += Sterling_Heights.length;
centerByArray(Sterling_Heights,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');
}
}