function addMarkers(){
mySelect = document.getElementById('selection');
Cincinnati = [];Wakeman = [];Defiance = [];Columbus = [];Worthington = [];Amelia = [];Chesterland = [];Lancaster = [];Mansfield = [];Mount_Vernon = [];Heath = [];Piqua = [];Cleveland = [];Toledo = [];mySelect.options[mySelect.options.length] = new Option("Amelia schools",'all=Amelia');
mySelect.options[mySelect.options.length] = new Option("Chesterland schools",'all=Chesterland');
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("Columbus schools",'all=Columbus');
mySelect.options[mySelect.options.length] = new Option("Defiance schools",'all=Defiance');
mySelect.options[mySelect.options.length] = new Option("Heath schools",'all=Heath');
mySelect.options[mySelect.options.length] = new Option("Lancaster schools",'all=Lancaster');
mySelect.options[mySelect.options.length] = new Option("Mansfield schools",'all=Mansfield');
mySelect.options[mySelect.options.length] = new Option("Mount Vernon schools",'all=Mount_Vernon');
mySelect.options[mySelect.options.length] = new Option("Piqua schools",'all=Piqua');
mySelect.options[mySelect.options.length] = new Option("Toledo schools",'all=Toledo');
mySelect.options[mySelect.options.length] = new Option("Wakeman schools",'all=Wakeman');
mySelect.options[mySelect.options.length] = new Option("Worthington schools",'all=Worthington');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Cincinnati[Cincinnati.length] = createMarker(new GPoint(-84.51804400,39.15272800),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cincinnati Junior Academy",'Cincinnati=' + Cincinnati.length);
Wakeman[Wakeman.length] = createMarker(new GPoint(-82.40810600,41.19452800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Clarksfield Seventh-day Adventist School",'Wakeman=' + Wakeman.length);
Defiance[Defiance.length] = createMarker(new GPoint(-84.34221400,41.28256300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Defiance Seventh Day Adventist",'Defiance=' + Defiance.length);
Columbus[Columbus.length] = createMarker(new GPoint(-82.90589900,39.96718100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eastwood Jr. Academy",'Columbus=' + Columbus.length);
Worthington[Worthington.length] = createMarker(new GPoint(-83.00522200,40.08990500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Griswold Christian Academy",'Worthington=' + Worthington.length);
Amelia[Amelia.length] = createMarker(new GPoint(-84.20653000,39.01533900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hamlet S D A Elementary School",'Amelia=' + Amelia.length);
Chesterland[Chesterland.length] = createMarker(new GPoint(-81.37357600,41.52268500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kaleidoscope Christian School",'Chesterland=' + Chesterland.length);
Lancaster[Lancaster.length] = createMarker(new GPoint(-82.54595600,39.76138900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lancaster Sda Elementary School",'Lancaster=' + Lancaster.length);
Mansfield[Mansfield.length] = createMarker(new GPoint(-82.55067600,40.72698900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mansfield Sda School",'Mansfield=' + Mansfield.length);
Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-82.48035900,40.39103000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mount Vernon Academy",'Mount_Vernon=' + Mount_Vernon.length);
Mount_Vernon[Mount_Vernon.length] = createMarker(new GPoint(-82.68840000,40.30970000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mount Vernon Sda Elementary School",'Mount_Vernon=' + Mount_Vernon.length);
Heath[Heath.length] = createMarker(new GPoint(-82.39582100,40.03348500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Newark Seventh-day Adventist School",'Heath=' + Heath.length);
Piqua[Piqua.length] = createMarker(new GPoint(-84.27872800,40.15961600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Piqua Sda Christian School",'Piqua=' + Piqua.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);
Toledo[Toledo.length] = createMarker(new GPoint(-83.66120300,41.69096300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Toledo Junior Academy",'Toledo=' + Toledo.length);
map.removeOverlays(Amelia);
map.removeOverlays(Chesterland);
map.removeOverlays(Cincinnati);
map.removeOverlays(Cleveland);
map.removeOverlays(Columbus);
map.removeOverlays(Defiance);
map.removeOverlays(Heath);
map.removeOverlays(Lancaster);
map.removeOverlays(Mansfield);
map.removeOverlays(Mount_Vernon);
map.removeOverlays(Piqua);
map.removeOverlays(Toledo);
map.removeOverlays(Wakeman);
map.removeOverlays(Worthington);
setTimeout(function(){map.addOverlays(Amelia)},1000);
setTimeout(function(){map.addOverlays(Chesterland)},1000);
setTimeout(function(){map.addOverlays(Cincinnati)},1000);
setTimeout(function(){map.addOverlays(Cleveland)},1000);
setTimeout(function(){map.addOverlays(Columbus)},1000);
setTimeout(function(){map.addOverlays(Defiance)},1000);
setTimeout(function(){map.addOverlays(Heath)},1000);
setTimeout(function(){map.addOverlays(Lancaster)},1000);
setTimeout(function(){map.addOverlays(Mansfield)},1000);
setTimeout(function(){map.addOverlays(Mount_Vernon)},1000);
setTimeout(function(){map.addOverlays(Piqua)},1000);
setTimeout(function(){map.addOverlays(Toledo)},1000);
setTimeout(function(){map.addOverlays(Wakeman)},1000);
setTimeout(function(){map.addOverlays(Worthington)},1000);
maxLng = -81.37357600;
maxLat = 41.69096300;
minLng = -84.51804400;
minLat = 39.01533900;
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(Amelia);
map.removeOverlays(Chesterland);
map.removeOverlays(Cincinnati);
map.removeOverlays(Cleveland);
map.removeOverlays(Columbus);
map.removeOverlays(Defiance);
map.removeOverlays(Heath);
map.removeOverlays(Lancaster);
map.removeOverlays(Mansfield);
map.removeOverlays(Mount_Vernon);
map.removeOverlays(Piqua);
map.removeOverlays(Toledo);
map.removeOverlays(Wakeman);
map.removeOverlays(Worthington);
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(Cincinnati);map.removeOverlays(Amelia);
map.removeOverlays(Chesterland);
map.removeOverlays(Cincinnati);
map.removeOverlays(Cleveland);
map.removeOverlays(Columbus);
map.removeOverlays(Defiance);
map.removeOverlays(Heath);
map.removeOverlays(Lancaster);
map.removeOverlays(Mansfield);
map.removeOverlays(Mount_Vernon);
map.removeOverlays(Piqua);
map.removeOverlays(Toledo);
map.removeOverlays(Wakeman);
map.removeOverlays(Worthington);
map.addOverlays(Amelia);
centerByArray(Amelia, false, false);
cntMarker += Amelia.length;
map.addOverlays(Chesterland);
centerByArray(Chesterland, false, false);
cntMarker += Chesterland.length;
map.addOverlays(Cincinnati);
centerByArray(Cincinnati, false, false);
cntMarker += Cincinnati.length;
map.addOverlays(Cleveland);
centerByArray(Cleveland, false, false);
cntMarker += Cleveland.length;
map.addOverlays(Columbus);
centerByArray(Columbus, false, false);
cntMarker += Columbus.length;
map.addOverlays(Defiance);
centerByArray(Defiance, false, false);
cntMarker += Defiance.length;
map.addOverlays(Heath);
centerByArray(Heath, false, false);
cntMarker += Heath.length;
map.addOverlays(Lancaster);
centerByArray(Lancaster, false, false);
cntMarker += Lancaster.length;
map.addOverlays(Mansfield);
centerByArray(Mansfield, false, false);
cntMarker += Mansfield.length;
map.addOverlays(Mount_Vernon);
centerByArray(Mount_Vernon, false, false);
cntMarker += Mount_Vernon.length;
map.addOverlays(Piqua);
centerByArray(Piqua, false, false);
cntMarker += Piqua.length;
map.addOverlays(Toledo);
centerByArray(Toledo, false, false);
cntMarker += Toledo.length;
map.addOverlays(Wakeman);
centerByArray(Wakeman, false, false);
cntMarker += Wakeman.length;
map.addOverlays(Worthington);
centerByArray(Worthington, false, false);
cntMarker += Worthington.length;
centerByArray(Cincinnati,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///21773,21593,21599,21670,21490,21859,33956,21526,21789,21687,21727,21774,21850,22307,21493,21593,/all');
//window.open('/map.php?type=2&schools=21773,21593,21599,21670,21490,21859,33956,21526,21789,21687,21727,21774,21850,22307,21493,21593,&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;
}