function addMarkers(){
mySelect = document.getElementById('selection');
Cleveland_Heights = [];Cincinnati = [];Columbus = [];Norwalk = [];Beachwood = [];Rocky_River = [];Toledo = [];Akron = [];South_Euclid = [];Cleveland = [];mySelect.options[mySelect.options.length] = new Option("Akron schools",'all=Akron');
mySelect.options[mySelect.options.length] = new Option("Beachwood schools",'all=Beachwood');
mySelect.options[mySelect.options.length] = new Option("Cincinnati schools",'all=Cincinnati');
mySelect.options[mySelect.options.length] = new Option("Cleveland schools",'all=Cleveland');
mySelect.options[mySelect.options.length] = new Option("Cleveland Heights schools",'all=Cleveland_Heights');
mySelect.options[mySelect.options.length] = new Option("Columbus schools",'all=Columbus');
mySelect.options[mySelect.options.length] = new Option("Norwalk schools",'all=Norwalk');
mySelect.options[mySelect.options.length] = new Option("Rocky River schools",'all=Rocky_River');
mySelect.options[mySelect.options.length] = new Option("South Euclid schools",'all=South_Euclid');
mySelect.options[mySelect.options.length] = new Option("Toledo schools",'all=Toledo');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Cleveland_Heights[Cleveland_Heights.length] = createMarker(new GPoint(-81.56086200,41.48463600),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Beaumont School",'Cleveland_Heights=' + Cleveland_Heights.length);
Cincinnati[Cincinnati.length] = createMarker(new GPoint(-84.35215600,39.07760500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Children's World",'Cincinnati=' + Cincinnati.length);
Columbus[Columbus.length] = createMarker(new GPoint(-82.93922000,39.96783800),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Columbus School For Girls",'Columbus=' + Columbus.length);
Norwalk[Norwalk.length] = createMarker(new GPoint(-82.61092500,41.23859400),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Harbor Christian School",'Norwalk=' + Norwalk.length);
Beachwood[Beachwood.length] = createMarker(new GPoint(-81.51693400,41.49207400),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hebrew Academy Of Cleve. Yavne",'Beachwood=' + Beachwood.length);
Rocky_River[Rocky_River.length] = createMarker(new GPoint(-81.85050200,41.46780900),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Magnificat High School",'Rocky_River=' + Rocky_River.length);
Cincinnati[Cincinnati.length] = createMarker(new GPoint(-84.55490500,39.20052200),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mcauley High School",'Cincinnati=' + Cincinnati.length);
Cincinnati[Cincinnati.length] = createMarker(new GPoint(-84.60186100,39.14058100),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mother Of Mercy High School",'Cincinnati=' + Cincinnati.length);
Cincinnati[Cincinnati.length] = createMarker(new GPoint(-84.42993400,39.22146500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mount Notre Dame High School",'Cincinnati=' + Cincinnati.length);
Toledo[Toledo.length] = createMarker(new GPoint(-83.62880900,41.69142800),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Notre Dame Academy",'Toledo=' + Toledo.length);
Akron[Akron.length] = createMarker(new GPoint(-81.55926200,41.10207300),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of The Elms High School",'Akron=' + Akron.length);
South_Euclid[South_Euclid.length] = createMarker(new GPoint(-81.51929200,41.50890700),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Regina High School",'South_Euclid=' + South_Euclid.length);
Cincinnati[Cincinnati.length] = createMarker(new GPoint(-84.45160700,39.19091900),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ritss High School",'Cincinnati=' + Cincinnati.length);
Cleveland[Cleveland.length] = createMarker(new GPoint(-81.81466200,41.45964700),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("St. Joseph Academy",'Cleveland=' + Cleveland.length);
Cincinnati[Cincinnati.length] = createMarker(new GPoint(-84.48169000,39.12525200),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("St. Ursula Academy",'Cincinnati=' + Cincinnati.length);
Toledo[Toledo.length] = createMarker(new GPoint(-83.63980200,41.67117700),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("St. Ursula Academy",'Toledo=' + Toledo.length);
Cincinnati[Cincinnati.length] = createMarker(new GPoint(-84.57753800,39.11388800),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Seton High School",'Cincinnati=' + Cincinnati.length);
Cincinnati[Cincinnati.length] = createMarker(new GPoint(-84.37018000,39.24956300),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ursuline Academy",'Cincinnati=' + Cincinnati.length);
map.removeOverlays(Akron);
map.removeOverlays(Beachwood);
map.removeOverlays(Cincinnati);
map.removeOverlays(Cleveland);
map.removeOverlays(Cleveland_Heights);
map.removeOverlays(Columbus);
map.removeOverlays(Norwalk);
map.removeOverlays(Rocky_River);
map.removeOverlays(South_Euclid);
map.removeOverlays(Toledo);
setTimeout(function(){map.addOverlays(Akron)},1000);
setTimeout(function(){map.addOverlays(Beachwood)},1000);
setTimeout(function(){map.addOverlays(Cincinnati)},1000);
setTimeout(function(){map.addOverlays(Cleveland)},1000);
setTimeout(function(){map.addOverlays(Cleveland_Heights)},1000);
setTimeout(function(){map.addOverlays(Columbus)},1000);
setTimeout(function(){map.addOverlays(Norwalk)},1000);
setTimeout(function(){map.addOverlays(Rocky_River)},1000);
setTimeout(function(){map.addOverlays(South_Euclid)},1000);
setTimeout(function(){map.addOverlays(Toledo)},1000);
maxLng = -81.51693400;
maxLat = 41.69142800;
minLng = -84.60186100;
minLat = 39.07760500;
reCenterMap();
} // 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,11);
/*
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(Akron);
map.removeOverlays(Beachwood);
map.removeOverlays(Cincinnati);
map.removeOverlays(Cleveland);
map.removeOverlays(Cleveland_Heights);
map.removeOverlays(Columbus);
map.removeOverlays(Norwalk);
map.removeOverlays(Rocky_River);
map.removeOverlays(South_Euclid);
map.removeOverlays(Toledo);
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_Heights);map.removeOverlays(Akron);
map.removeOverlays(Beachwood);
map.removeOverlays(Cincinnati);
map.removeOverlays(Cleveland);
map.removeOverlays(Cleveland_Heights);
map.removeOverlays(Columbus);
map.removeOverlays(Norwalk);
map.removeOverlays(Rocky_River);
map.removeOverlays(South_Euclid);
map.removeOverlays(Toledo);
map.addOverlays(Akron);
centerByArray(Akron, false, false);
cntMarker += Akron.length;
map.addOverlays(Beachwood);
centerByArray(Beachwood, false, false);
cntMarker += Beachwood.length;
map.addOverlays(Cincinnati);
centerByArray(Cincinnati, false, false);
cntMarker += Cincinnati.length;
map.addOverlays(Cleveland);
centerByArray(Cleveland, false, false);
cntMarker += Cleveland.length;
map.addOverlays(Cleveland_Heights);
centerByArray(Cleveland_Heights, false, false);
cntMarker += Cleveland_Heights.length;
map.addOverlays(Columbus);
centerByArray(Columbus, false, false);
cntMarker += Columbus.length;
map.addOverlays(Norwalk);
centerByArray(Norwalk, false, false);
cntMarker += Norwalk.length;
map.addOverlays(Rocky_River);
centerByArray(Rocky_River, false, false);
cntMarker += Rocky_River.length;
map.addOverlays(South_Euclid);
centerByArray(South_Euclid, false, false);
cntMarker += South_Euclid.length;
map.addOverlays(Toledo);
centerByArray(Toledo, false, false);
cntMarker += Toledo.length;
centerByArray(Cleveland_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///21830,31658,21742,21770,21772,21863,22237,21907,22328,21893,21396,21501,21601,21724,21867,21798,22236,22390,21501,/all');
//window.open('/map.php?type=2&schools=21830,31658,21742,21770,21772,21863,22237,21907,22328,21893,21396,21501,21601,21724,21867,21798,22236,22390,21501,&school_level=&radius=&zipcode=&school_type_search=&school_type_code=');
}
}
function createMarker(point, label, icon)
{
var marker = new GMarker(point, icon);
var html = label;
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}