function addMarkers(){
mySelect = document.getElementById('selection');
Rogers = [];Bellevue = [];Warren = [];Mount_Vernon = [];Akron = [];Cleveland = [];Norwalk = [];Oxford = [];Olmsted_Falls = [];Brook_Park = [];Athens = [];Copley = [];Youngstown = [];mySelect.options[mySelect.options.length] = new Option("Akron schools",'all=Akron');
mySelect.options[mySelect.options.length] = new Option("Athens schools",'all=Athens');
mySelect.options[mySelect.options.length] = new Option("Bellevue schools",'all=Bellevue');
mySelect.options[mySelect.options.length] = new Option("Brook Park schools",'all=Brook_Park');
mySelect.options[mySelect.options.length] = new Option("Cleveland schools",'all=Cleveland');
mySelect.options[mySelect.options.length] = new Option("Copley schools",'all=Copley');
mySelect.options[mySelect.options.length] = new Option("Mount Vernon schools",'all=Mount_Vernon');
mySelect.options[mySelect.options.length] = new Option("Norwalk schools",'all=Norwalk');
mySelect.options[mySelect.options.length] = new Option("Olmsted Falls schools",'all=Olmsted_Falls');
mySelect.options[mySelect.options.length] = new Option("Oxford schools",'all=Oxford');
mySelect.options[mySelect.options.length] = new Option("Rogers schools",'all=Rogers');
mySelect.options[mySelect.options.length] = new Option("Warren schools",'all=Warren');
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);
Bellevue[Bellevue.length] = createMarker(new GPoint(-82.84510000,41.26560000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Alpha Omega Christian School",'Bellevue=' + Bellevue.length);
Warren[Warren.length] = createMarker(new GPoint(-80.74078900,41.24734300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christian Altern School For Teens",'Warren=' + Warren.length);
Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-82.48494900,40.39561800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christian Star Academy",'Mount_Vernon=' + Mount_Vernon.length);
Akron[Akron.length] = createMarker(new GPoint(-81.47981900,41.06676300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("East Akron Ymca Phoenix Program",'Akron=' + Akron.length);
Cleveland[Cleveland.length] = createMarker(new GPoint(-81.68043000,41.49782100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eleanor Gerson High School",'Cleveland=' + Cleveland.length);
Cleveland[Cleveland.length] = createMarker(new GPoint(-81.75795700,41.48071100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eleanor Gerson West Middle School",'Cleveland=' + Cleveland.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);
Oxford[Oxford.length] = createMarker(new GPoint(-84.73860000,39.50050000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mcguffey Foundation School",'Oxford=' + Oxford.length);
Olmsted_Falls[Olmsted_Falls.length] = createMarker(new GPoint(-81.90149000,41.37372900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ombudsman Educational Services",'Olmsted_Falls=' + Olmsted_Falls.length);
Brook_Park[Brook_Park.length] = createMarker(new GPoint(-81.78500600,41.40514600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ombudsman Educational Services",'Brook_Park=' + Brook_Park.length);
Cleveland[Cleveland.length] = createMarker(new GPoint(-81.56498200,41.42956300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ramah Jr. Academy",'Cleveland=' + Cleveland.length);
Athens[Athens.length] = createMarker(new GPoint(-82.14122600,39.32069900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("River Valley Community School",'Athens=' + Athens.length);
Copley[Copley.length] = createMarker(new GPoint(-81.61921900,41.08378700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Spring Garden Waldorf School",'Copley=' + Copley.length);
Cleveland[Cleveland.length] = createMarker(new GPoint(-81.72064600,41.47762300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Urban Community School",'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(Akron);
map.removeOverlays(Athens);
map.removeOverlays(Bellevue);
map.removeOverlays(Brook_Park);
map.removeOverlays(Cleveland);
map.removeOverlays(Copley);
map.removeOverlays(Mount_Vernon);
map.removeOverlays(Norwalk);
map.removeOverlays(Olmsted_Falls);
map.removeOverlays(Oxford);
map.removeOverlays(Rogers);
map.removeOverlays(Warren);
map.removeOverlays(Youngstown);
setTimeout(function(){map.addOverlays(Akron)},1000);
setTimeout(function(){map.addOverlays(Athens)},1000);
setTimeout(function(){map.addOverlays(Bellevue)},1000);
setTimeout(function(){map.addOverlays(Brook_Park)},1000);
setTimeout(function(){map.addOverlays(Cleveland)},1000);
setTimeout(function(){map.addOverlays(Copley)},1000);
setTimeout(function(){map.addOverlays(Mount_Vernon)},1000);
setTimeout(function(){map.addOverlays(Norwalk)},1000);
setTimeout(function(){map.addOverlays(Olmsted_Falls)},1000);
setTimeout(function(){map.addOverlays(Oxford)},1000);
setTimeout(function(){map.addOverlays(Rogers)},1000);
setTimeout(function(){map.addOverlays(Warren)},1000);
setTimeout(function(){map.addOverlays(Youngstown)},1000);
maxLng = -80.61213800;
maxLat = 41.49782100;
minLng = -84.73860000;
minLat = 39.32069900;
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(Athens);
map.removeOverlays(Bellevue);
map.removeOverlays(Brook_Park);
map.removeOverlays(Cleveland);
map.removeOverlays(Copley);
map.removeOverlays(Mount_Vernon);
map.removeOverlays(Norwalk);
map.removeOverlays(Olmsted_Falls);
map.removeOverlays(Oxford);
map.removeOverlays(Rogers);
map.removeOverlays(Warren);
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(Akron);
map.removeOverlays(Athens);
map.removeOverlays(Bellevue);
map.removeOverlays(Brook_Park);
map.removeOverlays(Cleveland);
map.removeOverlays(Copley);
map.removeOverlays(Mount_Vernon);
map.removeOverlays(Norwalk);
map.removeOverlays(Olmsted_Falls);
map.removeOverlays(Oxford);
map.removeOverlays(Rogers);
map.removeOverlays(Warren);
map.removeOverlays(Youngstown);
map.addOverlays(Akron);
centerByArray(Akron, false, false);
cntMarker += Akron.length;
map.addOverlays(Athens);
centerByArray(Athens, false, false);
cntMarker += Athens.length;
map.addOverlays(Bellevue);
centerByArray(Bellevue, false, false);
cntMarker += Bellevue.length;
map.addOverlays(Brook_Park);
centerByArray(Brook_Park, false, false);
cntMarker += Brook_Park.length;
map.addOverlays(Cleveland);
centerByArray(Cleveland, false, false);
cntMarker += Cleveland.length;
map.addOverlays(Copley);
centerByArray(Copley, false, false);
cntMarker += Copley.length;
map.addOverlays(Mount_Vernon);
centerByArray(Mount_Vernon, false, false);
cntMarker += Mount_Vernon.length;
map.addOverlays(Norwalk);
centerByArray(Norwalk, false, false);
cntMarker += Norwalk.length;
map.addOverlays(Olmsted_Falls);
centerByArray(Olmsted_Falls, false, false);
cntMarker += Olmsted_Falls.length;
map.addOverlays(Oxford);
centerByArray(Oxford, false, false);
cntMarker += Oxford.length;
map.addOverlays(Rogers);
centerByArray(Rogers, false, false);
cntMarker += Rogers.length;
map.addOverlays(Warren);
centerByArray(Warren, false, false);
cntMarker += Warren.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///22303,21373,21540,36303,21484,21601,31654,35693,21477,22370,22303,21874,21373,31655,21859,22327,21921,21743,35693,21477,/all');
//window.open('/map.php?type=2&schools=22303,21373,21540,36303,21484,21601,31654,35693,21477,22370,22303,21874,21373,31655,21859,22327,21921,21743,35693,21477,&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;
}