function addMarkers()
{
mySelect = document.getElementById('selection');
Cleveland = [];Shaker_Heights = [];Cleveland[Cleveland.length] = createMarker(new GPoint(-81.60057068,41.48838043),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Alexander Graham Bell Elementary School",'Cleveland=' + Cleveland.length);
Cleveland[Cleveland.length] = createMarker(new GPoint(-81.59161377,41.46461105),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Alexander Hamilton Middle School",'Cleveland=' + Cleveland.length);
Cleveland[Cleveland.length] = createMarker(new GPoint(-81.60247040,41.46385193),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Andrew J Rickoff Elementary School",'Cleveland=' + Cleveland.length);
Shaker_Heights[Shaker_Heights.length] = createMarker(new GPoint(-81.57768250,41.43140030),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Boulevard Elementary School",'Shaker_Heights=' + Shaker_Heights.length);
Cleveland[Cleveland.length] = createMarker(new GPoint(-81.59114838,41.46223068),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Charles Dickens Elementary School",'Cleveland=' + Cleveland.length);
Shaker_Heights[Shaker_Heights.length] = createMarker(new GPoint(-81.55762482,41.47145081),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fernway Elementary School",'Shaker_Heights=' + Shaker_Heights.length);
Cleveland[Cleveland.length] = createMarker(new GPoint(-81.60421753,41.48129654),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Harvey Rice Elementary School",'Cleveland=' + Cleveland.length);
Cleveland[Cleveland.length] = createMarker(new GPoint(-81.59097290,41.45410919),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hope Academy Chapelside Campus",'Cleveland=' + Cleveland.length);
Cleveland[Cleveland.length] = createMarker(new GPoint(-81.59754181,41.49282455),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Intergenerational School, Elementary School",'Cleveland=' + Cleveland.length);
Cleveland[Cleveland.length] = createMarker(new GPoint(-81.60153198,41.48846436),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jesse Owens Academy (clc) High School",'Cleveland=' + Cleveland.length);
Cleveland[Cleveland.length] = createMarker(new GPoint(-81.51887512,41.08100510),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Life Skills Of Northeast Ohio",'Cleveland=' + Cleveland.length);
Shaker_Heights[Shaker_Heights.length] = createMarker(new GPoint(-81.57410400,41.47721900),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Onaway Elementary School",'Shaker_Heights=' + Shaker_Heights.length);
Cleveland[Cleveland.length] = createMarker(new GPoint(-81.55862300,41.47042200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rising Star Elementary School",'Cleveland=' + Cleveland.length);
Cleveland[Cleveland.length] = createMarker(new GPoint(-81.58464813,41.47128677),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Robert Fulton Elementary School",'Cleveland=' + Cleveland.length);
Shaker_Heights[Shaker_Heights.length] = createMarker(new GPoint(-81.57071686,41.47319412),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Shaker Hts High School",'Shaker_Heights=' + Shaker_Heights.length);
Cleveland[Cleveland.length] = createMarker(new GPoint(-81.60114288,41.48922348),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sunbeam Elementary School",'Cleveland=' + Cleveland.length);
Shaker_Heights[Shaker_Heights.length] = createMarker(new GPoint(-81.57514954,41.47825241),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Woodbury Elementary School",'Shaker_Heights=' + Shaker_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(Cleveland);
map.removeOverlays(Shaker_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(Cleveland);map.removeOverlays(Cleveland);
map.removeOverlays(Shaker_Heights);
map.addOverlays(Cleveland);
centerByArray(Cleveland, false, false);
cntMarker += Cleveland.length;
map.addOverlays(Shaker_Heights);
centerByArray(Shaker_Heights, false, false);
cntMarker += Shaker_Heights.length;
centerByArray(Cleveland,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');
}
}