function addMarkers(){
mySelect = document.getElementById('selection');
Buffalo = [];Buffalo[Buffalo.length] = createMarker(new GPoint(-78.90293700,42.95691900),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("All Saints",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.81865200,42.84800600),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bishop Timon-st Jude High School",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.87531300,42.92423000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Buffalo Seminary",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.86927600,42.91617400),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Canisius High School",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.82482000,42.95191300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cantalician Center For Learnin",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.86980400,42.91275700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Catholic Academy West Buffalo",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.84908600,42.88930400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Catholic Central School",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.79923700,42.93201000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Charles Grandison Finney High School",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.85990600,42.98991700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Covenant Academy",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.83288600,42.89924500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Darul Ullom Al Madania",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.81597100,42.92635900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Dayspring Christian Academy",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.86144000,42.94273700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Elmwood-franklin School",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.83911200,42.90044000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eva L. Jeltz Christian Academy",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.85381200,42.90081800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Greater Refuge Temple Christian Academy",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.83586800,42.94825600),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Holy Angels Academy High School",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.82535500,42.84709100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Family School",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.86606200,42.94678300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Spirit School",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.81206600,42.84539700),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mount Mercy Academy",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.85266600,42.92679700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mt St Joseph Academy",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.87511300,42.91553700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Nardin Academy",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.87374600,42.91763700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Nardin Academy Elementary School",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.87353300,42.91761000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Nardin Academy High School",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.85604400,42.94126600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Nichols School",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.88819600,42.93812200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of Black Rock School",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.82693900,42.85651200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Agatha School",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.82052300,42.83813700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Ambrose",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.78822900,42.89534900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Andrew School",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.86457900,42.89522200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. John Christian Academy",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.82374800,42.95292000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Joseph School University He",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.84959100,42.95872000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("St. Joseph's Collegiate Institute",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.85652100,42.94756300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Margaret School",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.83991100,42.95279200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Rose Of Lima Elementary School",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.84028600,42.88854300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Stanislaus School",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.81177900,42.85766600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Teresa School",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.80705200,42.88743700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Agnes School",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.80284600,42.87193700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Bernard Elementary School",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.85373900,42.97310400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St John The Baptist School",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.84893800,42.93968700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Mark Elementary School",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.80641200,42.83375100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Martin Of Tours School",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.81473300,42.85081900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Thomas Aquinas Elementary School",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.85935000,42.88116400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sts Columba-brigid Montessori School",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.80668200,42.91896300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Turner/carroll",'Buffalo=' + Buffalo.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.87285500,42.90393900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Westminster Early Childhood Pr",'Buffalo=' + Buffalo.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//////' + showArray);
map.removeOverlays(Buffalo);
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(Buffalo);map.removeOverlays(Buffalo);
map.addOverlays(Buffalo);
centerByArray(Buffalo, false, false);
cntMarker += Buffalo.length;
centerByArray(Buffalo,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=&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;
}