function addMarkers(){
mySelect = document.getElementById('selection');
Columbus = [];Gahanna = [];Blacklick = [];Worthington = [];Grove_City = [];Groveport = [];Brice = [];Westerville = [];Canal_Winchester = [];mySelect.options[mySelect.options.length] = new Option("Blacklick schools",'all=Blacklick');
mySelect.options[mySelect.options.length] = new Option("Brice schools",'all=Brice');
mySelect.options[mySelect.options.length] = new Option("Canal Winchester schools",'all=Canal_Winchester');
mySelect.options[mySelect.options.length] = new Option("Columbus schools",'all=Columbus');
mySelect.options[mySelect.options.length] = new Option("Gahanna schools",'all=Gahanna');
mySelect.options[mySelect.options.length] = new Option("Grove City schools",'all=Grove_City');
mySelect.options[mySelect.options.length] = new Option("Groveport schools",'all=Groveport');
mySelect.options[mySelect.options.length] = new Option("Westerville schools",'all=Westerville');
mySelect.options[mySelect.options.length] = new Option("Worthington schools",'all=Worthington');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Columbus[Columbus.length] = createMarker(new GPoint(-82.91084800,39.94485000),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bishop Hartley High School",'Columbus=' + Columbus.length);
Columbus[Columbus.length] = createMarker(new GPoint(-83.07968000,39.94035600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bishop Ready High School",'Columbus=' + Columbus.length);
Columbus[Columbus.length] = createMarker(new GPoint(-83.01663800,40.04930500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bishop Watterson High School",'Columbus=' + Columbus.length);
Columbus[Columbus.length] = createMarker(new GPoint(-83.05408800,39.91967700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central Baptist School",'Columbus=' + Columbus.length);
Columbus[Columbus.length] = createMarker(new GPoint(-82.87638900,40.04299100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Columbus Academy",'Columbus=' + Columbus.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);
Columbus[Columbus.length] = createMarker(new GPoint(-82.85359900,39.97228100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Columbus Torah Academy",'Columbus=' + Columbus.length);
Gahanna[Gahanna.length] = createMarker(new GPoint(-82.86509600,40.03940200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gahanna Christian Academy",'Gahanna=' + Gahanna.length);
Blacklick[Blacklick.length] = createMarker(new GPoint(-82.79665100,39.98479000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grace Christian School",'Blacklick=' + Blacklick.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);
Grove_City[Grove_City.length] = createMarker(new GPoint(-83.07031800,39.86918800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grove City Christian School",'Grove_City=' + Grove_City.length);
Groveport[Groveport.length] = createMarker(new GPoint(-82.91036100,39.86846200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Madison Christian School",'Groveport=' + Groveport.length);
Columbus[Columbus.length] = createMarker(new GPoint(-82.96796200,40.08070000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Marburn Academy",'Columbus=' + Columbus.length);
Brice[Brice.length] = createMarker(new GPoint(-82.83100000,39.91700000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Hope Christian Academy",'Brice=' + Brice.length);
Westerville[Westerville.length] = createMarker(new GPoint(-82.94636900,40.11073300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northside Christian School",'Westerville=' + Westerville.length);
Columbus[Columbus.length] = createMarker(new GPoint(-82.94540400,40.01916700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rosemont Center School",'Columbus=' + Columbus.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);
Columbus[Columbus.length] = createMarker(new GPoint(-82.97628700,40.05313500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Francis De Sales High School",'Columbus=' + Columbus.length);
Columbus[Columbus.length] = createMarker(new GPoint(-82.99105900,40.04129000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tree Of Life Christian School-northridge Branch",'Columbus=' + Columbus.length);
Columbus[Columbus.length] = createMarker(new GPoint(-82.99100900,40.04131100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tree Of Life Christian Schools",'Columbus=' + Columbus.length);
Columbus[Columbus.length] = createMarker(new GPoint(-83.06577200,40.03108300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Wellington School",'Columbus=' + Columbus.length);
Canal_Winchester[Canal_Winchester.length] = createMarker(new GPoint(-82.82530200,39.88904000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("World Harvest Christian Academy",'Canal_Winchester=' + Canal_Winchester.length);
Worthington[Worthington.length] = createMarker(new GPoint(-83.01012200,40.10022100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Worthington Christian Schools",'Worthington=' + Worthington.length);
} // 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/////2/' + showArray);
map.removeOverlays(Blacklick);
map.removeOverlays(Brice);
map.removeOverlays(Canal_Winchester);
map.removeOverlays(Columbus);
map.removeOverlays(Gahanna);
map.removeOverlays(Grove_City);
map.removeOverlays(Groveport);
map.removeOverlays(Westerville);
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(Columbus);map.removeOverlays(Blacklick);
map.removeOverlays(Brice);
map.removeOverlays(Canal_Winchester);
map.removeOverlays(Columbus);
map.removeOverlays(Gahanna);
map.removeOverlays(Grove_City);
map.removeOverlays(Groveport);
map.removeOverlays(Westerville);
map.removeOverlays(Worthington);
map.addOverlays(Blacklick);
centerByArray(Blacklick, false, false);
cntMarker += Blacklick.length;
map.addOverlays(Brice);
centerByArray(Brice, false, false);
cntMarker += Brice.length;
map.addOverlays(Canal_Winchester);
centerByArray(Canal_Winchester, false, false);
cntMarker += Canal_Winchester.length;
map.addOverlays(Columbus);
centerByArray(Columbus, false, false);
cntMarker += Columbus.length;
map.addOverlays(Gahanna);
centerByArray(Gahanna, false, false);
cntMarker += Gahanna.length;
map.addOverlays(Grove_City);
centerByArray(Grove_City, false, false);
cntMarker += Grove_City.length;
map.addOverlays(Groveport);
centerByArray(Groveport, false, false);
cntMarker += Groveport.length;
map.addOverlays(Westerville);
centerByArray(Westerville, false, false);
cntMarker += Westerville.length;
map.addOverlays(Worthington);
centerByArray(Worthington, false, false);
cntMarker += Worthington.length;
centerByArray(Columbus,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////all');
//window.open('/map.php?type=1&schools=&school_level=2&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;
}