function addMarkers(){
mySelect = document.getElementById('selection');
Rogers = [];Cleveland = [];Cincinnati = [];Thornville = [];Copley = [];Cleveland_Hts = [];Dayton = [];Saint_Paris = [];Columbus = [];Lakewood = [];Toledo = [];Wickliffe = [];Shaker_Heights = [];Hunting_Valley = [];Youngstown = [];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 Hts schools",'all=Cleveland_Hts');
mySelect.options[mySelect.options.length] = new Option("Columbus schools",'all=Columbus');
mySelect.options[mySelect.options.length] = new Option("Copley schools",'all=Copley');
mySelect.options[mySelect.options.length] = new Option("Dayton schools",'all=Dayton');
mySelect.options[mySelect.options.length] = new Option("Hunting Valley schools",'all=Hunting_Valley');
mySelect.options[mySelect.options.length] = new Option("Lakewood schools",'all=Lakewood');
mySelect.options[mySelect.options.length] = new Option("Rogers schools",'all=Rogers');
mySelect.options[mySelect.options.length] = new Option("Saint Paris schools",'all=Saint_Paris');
mySelect.options[mySelect.options.length] = new Option("Shaker Heights schools",'all=Shaker_Heights');
mySelect.options[mySelect.options.length] = new Option("Thornville schools",'all=Thornville');
mySelect.options[mySelect.options.length] = new Option("Toledo schools",'all=Toledo');
mySelect.options[mySelect.options.length] = new Option("Wickliffe schools",'all=Wickliffe');
mySelect.options[mySelect.options.length] = new Option("Youngstown schools",'all=Youngstown');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Rogers[Rogers.length] = createMarker(new GPoint(-80.61213800,40.77713700),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Act 1 Education Center",'Rogers=' + Rogers.length);
Cleveland[Cleveland.length] = createMarker(new GPoint(-81.60998100,41.48009400),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Benedictine",'Cleveland=' + Cleveland.length);
Cincinnati[Cincinnati.length] = createMarker(new GPoint(-84.57877600,39.11213700),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Elder High School",'Cincinnati=' + Cincinnati.length);
Thornville[Thornville.length] = createMarker(new GPoint(-82.43969700,39.80591400),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Fairfield Academy High School",'Thornville=' + Thornville.length);
Copley[Copley.length] = createMarker(new GPoint(-81.65188000,41.09943700),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("The Ghent Academy For Boys",'Copley=' + Copley.length);
Cincinnati[Cincinnati.length] = createMarker(new GPoint(-84.58695000,39.18962900),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("La Salle High School",'Cincinnati=' + Cincinnati.length);
Cincinnati[Cincinnati.length] = createMarker(new GPoint(-84.35762700,39.21947700),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Moeller High School",'Cincinnati=' + Cincinnati.length);
Cleveland_Hts[Cleveland_Hts.length] = createMarker(new GPoint(-81.53668200,41.51908000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mosdas Our Hatnah",'Cleveland_Hts=' + Cleveland_Hts.length);
Dayton[Dayton.length] = createMarker(new GPoint(-84.28331200,39.73197000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Nicholas-liberty Adult",'Dayton=' + Dayton.length);
Saint_Paris[Saint_Paris.length] = createMarker(new GPoint(-83.97171800,40.15265200),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Operation Rebirth Christian Academy",'Saint_Paris=' + Saint_Paris.length);
Columbus[Columbus.length] = createMarker(new GPoint(-82.94737500,39.96844800),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("St. Charles Preparatory School",'Columbus=' + Columbus.length);
Lakewood[Lakewood.length] = createMarker(new GPoint(-81.78503000,41.48523300),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("St. Edward High School",'Lakewood=' + Lakewood.length);
Toledo[Toledo.length] = createMarker(new GPoint(-83.59656000,41.66319300),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("St. Francis De Sales High School",'Toledo=' + Toledo.length);
Toledo[Toledo.length] = createMarker(new GPoint(-83.68150300,41.61417000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("St. John's Jesuit High School",'Toledo=' + Toledo.length);
Cincinnati[Cincinnati.length] = createMarker(new GPoint(-84.56037900,39.20369000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("St. Xavier High School",'Cincinnati=' + Cincinnati.length);
Cleveland[Cleveland.length] = createMarker(new GPoint(-81.70689200,41.48248300),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("St Ignatius High School",'Cleveland=' + Cleveland.length);
Cincinnati[Cincinnati.length] = createMarker(new GPoint(-84.50473300,39.10644200),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("St Peter Claver Latin School For Boys",'Cincinnati=' + Cincinnati.length);
Wickliffe[Wickliffe.length] = createMarker(new GPoint(-81.48714000,41.59668900),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Telshe High School",'Wickliffe=' + Wickliffe.length);
Shaker_Heights[Shaker_Heights.length] = createMarker(new GPoint(-81.53345400,41.48063700),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("University Lower School",'Shaker_Heights=' + Shaker_Heights.length);
Hunting_Valley[Hunting_Valley.length] = createMarker(new GPoint(-81.43811600,41.48584900),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("University School",'Hunting_Valley=' + Hunting_Valley.length);
Cleveland[Cleveland.length] = createMarker(new GPoint(-81.51249200,41.50499600),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Yeshiva High School-jacob Sapirstein Campus Boys",'Cleveland=' + Cleveland.length);
Youngstown[Youngstown.length] = createMarker(new GPoint(-80.62603500,41.11897200),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Youngstown Youth Academy High School",'Youngstown=' + Youngstown.length);
map.removeOverlays(Cincinnati);
map.removeOverlays(Cleveland);
map.removeOverlays(Cleveland_Hts);
map.removeOverlays(Columbus);
map.removeOverlays(Copley);
map.removeOverlays(Dayton);
map.removeOverlays(Hunting_Valley);
map.removeOverlays(Lakewood);
map.removeOverlays(Rogers);
map.removeOverlays(Saint_Paris);
map.removeOverlays(Shaker_Heights);
map.removeOverlays(Thornville);
map.removeOverlays(Toledo);
map.removeOverlays(Wickliffe);
map.removeOverlays(Youngstown);
setTimeout(function(){map.addOverlays(Cincinnati)},1000);
setTimeout(function(){map.addOverlays(Cleveland)},1000);
setTimeout(function(){map.addOverlays(Cleveland_Hts)},1000);
setTimeout(function(){map.addOverlays(Columbus)},1000);
setTimeout(function(){map.addOverlays(Copley)},1000);
setTimeout(function(){map.addOverlays(Dayton)},1000);
setTimeout(function(){map.addOverlays(Hunting_Valley)},1000);
setTimeout(function(){map.addOverlays(Lakewood)},1000);
setTimeout(function(){map.addOverlays(Rogers)},1000);
setTimeout(function(){map.addOverlays(Saint_Paris)},1000);
setTimeout(function(){map.addOverlays(Shaker_Heights)},1000);
setTimeout(function(){map.addOverlays(Thornville)},1000);
setTimeout(function(){map.addOverlays(Toledo)},1000);
setTimeout(function(){map.addOverlays(Wickliffe)},1000);
setTimeout(function(){map.addOverlays(Youngstown)},1000);
maxLng = -80.61213800;
maxLat = 41.66319300;
minLng = -84.58695000;
minLat = 39.10644200;
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(Cincinnati);
map.removeOverlays(Cleveland);
map.removeOverlays(Cleveland_Hts);
map.removeOverlays(Columbus);
map.removeOverlays(Copley);
map.removeOverlays(Dayton);
map.removeOverlays(Hunting_Valley);
map.removeOverlays(Lakewood);
map.removeOverlays(Rogers);
map.removeOverlays(Saint_Paris);
map.removeOverlays(Shaker_Heights);
map.removeOverlays(Thornville);
map.removeOverlays(Toledo);
map.removeOverlays(Wickliffe);
map.removeOverlays(Youngstown);
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(Rogers);map.removeOverlays(Cincinnati);
map.removeOverlays(Cleveland);
map.removeOverlays(Cleveland_Hts);
map.removeOverlays(Columbus);
map.removeOverlays(Copley);
map.removeOverlays(Dayton);
map.removeOverlays(Hunting_Valley);
map.removeOverlays(Lakewood);
map.removeOverlays(Rogers);
map.removeOverlays(Saint_Paris);
map.removeOverlays(Shaker_Heights);
map.removeOverlays(Thornville);
map.removeOverlays(Toledo);
map.removeOverlays(Wickliffe);
map.removeOverlays(Youngstown);
map.addOverlays(Cincinnati);
centerByArray(Cincinnati, false, false);
cntMarker += Cincinnati.length;
map.addOverlays(Cleveland);
centerByArray(Cleveland, false, false);
cntMarker += Cleveland.length;
map.addOverlays(Cleveland_Hts);
centerByArray(Cleveland_Hts, false, false);
cntMarker += Cleveland_Hts.length;
map.addOverlays(Columbus);
centerByArray(Columbus, false, false);
cntMarker += Columbus.length;
map.addOverlays(Copley);
centerByArray(Copley, false, false);
cntMarker += Copley.length;
map.addOverlays(Dayton);
centerByArray(Dayton, false, false);
cntMarker += Dayton.length;
map.addOverlays(Hunting_Valley);
centerByArray(Hunting_Valley, false, false);
cntMarker += Hunting_Valley.length;
map.addOverlays(Lakewood);
centerByArray(Lakewood, false, false);
cntMarker += Lakewood.length;
map.addOverlays(Rogers);
centerByArray(Rogers, false, false);
cntMarker += Rogers.length;
map.addOverlays(Saint_Paris);
centerByArray(Saint_Paris, false, false);
cntMarker += Saint_Paris.length;
map.addOverlays(Shaker_Heights);
centerByArray(Shaker_Heights, false, false);
cntMarker += Shaker_Heights.length;
map.addOverlays(Thornville);
centerByArray(Thornville, false, false);
cntMarker += Thornville.length;
map.addOverlays(Toledo);
centerByArray(Toledo, false, false);
cntMarker += Toledo.length;
map.addOverlays(Wickliffe);
centerByArray(Wickliffe, false, false);
cntMarker += Wickliffe.length;
map.addOverlays(Youngstown);
centerByArray(Youngstown, false, false);
cntMarker += Youngstown.length;
centerByArray(Rogers,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///21539,21678,21758,22252,21401,22037,21662,21992,32767,22325,22254,35693,21814,21552,22017,22070,22278,22370,31662,21769,22291,35693,21814,22326,21552,/all');
//window.open('/map.php?type=2&schools=21539,21678,21758,22252,21401,22037,21662,21992,32767,22325,22254,35693,21814,21552,22017,22070,22278,22370,31662,21769,22291,35693,21814,22326,21552,&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;
}