function addMarkers(){
mySelect = document.getElementById('selection');
Dayton = [];Cincinnati = [];University_Heights = [];North_Royalton = [];Dublin = [];Fairlawn = [];Independence = [];Hudson = [];Lakewood = [];Cleveland = [];Highland_Heights = [];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("Dayton schools",'all=Dayton');
mySelect.options[mySelect.options.length] = new Option("Dublin schools",'all=Dublin');
mySelect.options[mySelect.options.length] = new Option("Fairlawn schools",'all=Fairlawn');
mySelect.options[mySelect.options.length] = new Option("Highland Heights schools",'all=Highland_Heights');
mySelect.options[mySelect.options.length] = new Option("Hudson schools",'all=Hudson');
mySelect.options[mySelect.options.length] = new Option("Independence schools",'all=Independence');
mySelect.options[mySelect.options.length] = new Option("Lakewood schools",'all=Lakewood');
mySelect.options[mySelect.options.length] = new Option("North Royalton schools",'all=North_Royalton');
mySelect.options[mySelect.options.length] = new Option("University Heights schools",'all=University_Heights');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Dayton[Dayton.length] = createMarker(new GPoint(-84.22321300,39.65672000),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bishop Leibold School-east & West",'Dayton=' + Dayton.length);
Cincinnati[Cincinnati.length] = createMarker(new GPoint(-84.43088700,39.12602000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cardinal Pacelli Elementary School",'Cincinnati=' + Cincinnati.length);
Cincinnati[Cincinnati.length] = createMarker(new GPoint(-84.51908300,39.21131300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central Baptist Schools",'Cincinnati=' + Cincinnati.length);
Cincinnati[Cincinnati.length] = createMarker(new GPoint(-84.32637500,39.18495000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cincinnati Country Day School",'Cincinnati=' + Cincinnati.length);
University_Heights[University_Heights.length] = createMarker(new GPoint(-81.54111600,41.49749400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fuchs Mizrachi School",'University_Heights=' + University_Heights.length);
Cincinnati[Cincinnati.length] = createMarker(new GPoint(-84.37751000,39.08548000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Guardian Angels Elementary School",'Cincinnati=' + Cincinnati.length);
Cincinnati[Cincinnati.length] = createMarker(new GPoint(-84.42725700,39.18038200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Nativity School",'Cincinnati=' + Cincinnati.length);
Cincinnati[Cincinnati.length] = createMarker(new GPoint(-84.66866900,39.14667400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of The Visitation School",'Cincinnati=' + Cincinnati.length);
North_Royalton[North_Royalton.length] = createMarker(new GPoint(-81.73441000,41.32535500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Albert The Great School",'North_Royalton=' + North_Royalton.length);
Dublin[Dublin.length] = createMarker(new GPoint(-83.15825900,40.11686300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Brigid Of Kildare Elementary School",'Dublin=' + Dublin.length);
Fairlawn[Fairlawn.length] = createMarker(new GPoint(-81.60440000,41.12407400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Hilary Elementary School",'Fairlawn=' + Fairlawn.length);
Cincinnati[Cincinnati.length] = createMarker(new GPoint(-84.59989600,39.20415800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. James White Oak School",'Cincinnati=' + Cincinnati.length);
Independence[Independence.length] = createMarker(new GPoint(-81.64205200,41.38476300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Michael School",'Independence=' + Independence.length);
Cincinnati[Cincinnati.length] = createMarker(new GPoint(-84.29973500,39.10187100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Veronica Elementary School",'Cincinnati=' + Cincinnati.length);
Hudson[Hudson.length] = createMarker(new GPoint(-81.41091600,41.24624300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Seton Catholic Elementary School",'Hudson=' + Hudson.length);
Lakewood[Lakewood.length] = createMarker(new GPoint(-81.77747800,41.47831400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ss Cyril - Methodius School",'Lakewood=' + Lakewood.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.60420100,39.18261900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Ignatius Loyola School",'Cincinnati=' + Cincinnati.length);
Highland_Heights[Highland_Heights.length] = createMarker(new GPoint(-81.48614400,41.53882000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Paschal Baylon School",'Highland_Heights=' + Highland_Heights.length);
map.removeOverlays(Cincinnati);
map.removeOverlays(Cleveland);
map.removeOverlays(Dayton);
map.removeOverlays(Dublin);
map.removeOverlays(Fairlawn);
map.removeOverlays(Highland_Heights);
map.removeOverlays(Hudson);
map.removeOverlays(Independence);
map.removeOverlays(Lakewood);
map.removeOverlays(North_Royalton);
map.removeOverlays(University_Heights);
setTimeout(function(){map.addOverlays(Cincinnati)},1000);
setTimeout(function(){map.addOverlays(Cleveland)},1000);
setTimeout(function(){map.addOverlays(Dayton)},1000);
setTimeout(function(){map.addOverlays(Dublin)},1000);
setTimeout(function(){map.addOverlays(Fairlawn)},1000);
setTimeout(function(){map.addOverlays(Highland_Heights)},1000);
setTimeout(function(){map.addOverlays(Hudson)},1000);
setTimeout(function(){map.addOverlays(Independence)},1000);
setTimeout(function(){map.addOverlays(Lakewood)},1000);
setTimeout(function(){map.addOverlays(North_Royalton)},1000);
setTimeout(function(){map.addOverlays(University_Heights)},1000);
maxLng = -81.41091600;
maxLat = 41.53882000;
minLng = -84.66866900;
minLat = 39.08548000;
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(Dayton);
map.removeOverlays(Dublin);
map.removeOverlays(Fairlawn);
map.removeOverlays(Highland_Heights);
map.removeOverlays(Hudson);
map.removeOverlays(Independence);
map.removeOverlays(Lakewood);
map.removeOverlays(North_Royalton);
map.removeOverlays(University_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(Dayton);map.removeOverlays(Cincinnati);
map.removeOverlays(Cleveland);
map.removeOverlays(Dayton);
map.removeOverlays(Dublin);
map.removeOverlays(Fairlawn);
map.removeOverlays(Highland_Heights);
map.removeOverlays(Hudson);
map.removeOverlays(Independence);
map.removeOverlays(Lakewood);
map.removeOverlays(North_Royalton);
map.removeOverlays(University_Heights);
map.addOverlays(Cincinnati);
centerByArray(Cincinnati, false, false);
cntMarker += Cincinnati.length;
map.addOverlays(Cleveland);
centerByArray(Cleveland, false, false);
cntMarker += Cleveland.length;
map.addOverlays(Dayton);
centerByArray(Dayton, false, false);
cntMarker += Dayton.length;
map.addOverlays(Dublin);
centerByArray(Dublin, false, false);
cntMarker += Dublin.length;
map.addOverlays(Fairlawn);
centerByArray(Fairlawn, false, false);
cntMarker += Fairlawn.length;
map.addOverlays(Highland_Heights);
centerByArray(Highland_Heights, false, false);
cntMarker += Highland_Heights.length;
map.addOverlays(Hudson);
centerByArray(Hudson, false, false);
cntMarker += Hudson.length;
map.addOverlays(Independence);
centerByArray(Independence, false, false);
cntMarker += Independence.length;
map.addOverlays(Lakewood);
centerByArray(Lakewood, false, false);
cntMarker += Lakewood.length;
map.addOverlays(North_Royalton);
centerByArray(North_Royalton, false, false);
cntMarker += North_Royalton.length;
map.addOverlays(University_Heights);
centerByArray(University_Heights, false, false);
cntMarker += University_Heights.length;
centerByArray(Dayton,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///22037,21569,21447,21486,22239,34105,22169,21926,21942,21569,21984,21437,21447,21486,21595,21777,21838,22043,21892,21415,22035,21906,/all');
//window.open('/map.php?type=2&schools=22037,21569,21447,21486,22239,34105,22169,21926,21942,21569,21984,21437,21447,21486,21595,21777,21838,22043,21892,21415,22035,21906,&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;
}