function addMarkers(){
mySelect = document.getElementById('selection');
Amherst = [];Tonawanda = [];Buffalo = [];Collins = [];Cheektowaga = [];West_Seneca = [];Williamsville = [];Depew = [];South_Wales = [];Gowanda = [];Grand_Island = [];Hamburg = [];Kenmore = [];Snyder = [];Athol_Springs = [];Lancaster = [];mySelect.options[mySelect.options.length] = new Option("Amherst schools",'all=Amherst');
mySelect.options[mySelect.options.length] = new Option("Athol Springs schools",'all=Athol_Springs');
mySelect.options[mySelect.options.length] = new Option("Buffalo schools",'all=Buffalo');
mySelect.options[mySelect.options.length] = new Option("Cheektowaga schools",'all=Cheektowaga');
mySelect.options[mySelect.options.length] = new Option("Collins schools",'all=Collins');
mySelect.options[mySelect.options.length] = new Option("Depew schools",'all=Depew');
mySelect.options[mySelect.options.length] = new Option("Gowanda schools",'all=Gowanda');
mySelect.options[mySelect.options.length] = new Option("Grand Island schools",'all=Grand_Island');
mySelect.options[mySelect.options.length] = new Option("Hamburg schools",'all=Hamburg');
mySelect.options[mySelect.options.length] = new Option("Kenmore schools",'all=Kenmore');
mySelect.options[mySelect.options.length] = new Option("Lancaster schools",'all=Lancaster');
mySelect.options[mySelect.options.length] = new Option("Snyder schools",'all=Snyder');
mySelect.options[mySelect.options.length] = new Option("South Wales schools",'all=South_Wales');
mySelect.options[mySelect.options.length] = new Option("Tonawanda schools",'all=Tonawanda');
mySelect.options[mySelect.options.length] = new Option("West Seneca schools",'all=West_Seneca');
mySelect.options[mySelect.options.length] = new Option("Williamsville schools",'all=Williamsville');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Amherst[Amherst.length] = createMarker(new GPoint(-78.75295900,43.06876600),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Amherst Christian Academy",'Amherst=' + Amherst.length);
Tonawanda[Tonawanda.length] = createMarker(new GPoint(-78.87358300,43.02149300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Baptist School",'Tonawanda=' + Tonawanda.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);
Collins[Collins.length] = createMarker(new GPoint(-78.84491500,42.49845300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Blossom Garden Friends School",'Collins=' + Collins.length);
Amherst[Amherst.length] = createMarker(new GPoint(-78.80721300,42.96223700),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Buffalo Academy Of The Sacred Heart",'Amherst=' + Amherst.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);
Tonawanda[Tonawanda.length] = createMarker(new GPoint(-78.86351100,42.99950600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cardinal O Hara High School",'Tonawanda=' + Tonawanda.length);
Cheektowaga[Cheektowaga.length] = createMarker(new GPoint(-78.74649900,42.92040000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Center For Handicapped Children",'Cheektowaga=' + Cheektowaga.length);
West_Seneca[West_Seneca.length] = createMarker(new GPoint(-78.76744100,42.83974100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Center Road Christian Academy",'West_Seneca=' + West_Seneca.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);
Williamsville[Williamsville.length] = createMarker(new GPoint(-78.73691900,42.96505100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christian Central Academy",'Williamsville=' + Williamsville.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);
Williamsville[Williamsville.length] = createMarker(new GPoint(-78.71631600,42.96627600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gateway-longview Lynde School",'Williamsville=' + Williamsville.length);
Depew[Depew.length] = createMarker(new GPoint(-78.68707700,42.90520100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("God's New Covenant Academy",'Depew=' + Depew.length);
South_Wales[South_Wales.length] = createMarker(new GPoint(-78.58229300,42.70862000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("The Gow School",'South_Wales=' + South_Wales.length);
Gowanda[Gowanda.length] = createMarker(new GPoint(-78.94178600,42.47326300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gowanda Christian Academy",'Gowanda=' + Gowanda.length);
Grand_Island[Grand_Island.length] = createMarker(new GPoint(-78.95984600,43.01829500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grand Island Christian Academy",'Grand_Island=' + Grand_Island.length);
Hamburg[Hamburg.length] = createMarker(new GPoint(-78.83362900,42.71606300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hamburg Christian Academy",'Hamburg=' + Hamburg.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);
Hamburg[Hamburg.length] = createMarker(new GPoint(-78.82432400,42.75602400),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Immaculata Academy",'Hamburg=' + Hamburg.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);
Kenmore[Kenmore.length] = createMarker(new GPoint(-78.87339500,42.98671100),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mount St Mary Academy",'Kenmore=' + Kenmore.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);
Tonawanda[Tonawanda.length] = createMarker(new GPoint(-78.85948700,43.00871800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Life Christian School",'Tonawanda=' + Tonawanda.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.85604400,42.94126600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Nichols School",'Buffalo=' + Buffalo.length);
Hamburg[Hamburg.length] = createMarker(new GPoint(-78.83990000,42.73440000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Old Time Baptist Academy",'Hamburg=' + Hamburg.length);
Snyder[Snyder.length] = createMarker(new GPoint(-78.78375800,42.96780000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Park School Of Buffalo",'Snyder=' + Snyder.length);
Athol_Springs[Athol_Springs.length] = createMarker(new GPoint(-78.86534000,42.77143700),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("St. Francis High School",'Athol_Springs=' + Athol_Springs.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);
Lancaster[Lancaster.length] = createMarker(new GPoint(-78.67962500,42.90772500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Marys High School",'Lancaster=' + Lancaster.length);
Buffalo[Buffalo.length] = createMarker(new GPoint(-78.80668200,42.91896300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Turner/carroll",'Buffalo=' + Buffalo.length);
West_Seneca[West_Seneca.length] = createMarker(new GPoint(-78.75198800,42.81403200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West Seneca Christian School",'West_Seneca=' + West_Seneca.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(Amherst);
map.removeOverlays(Athol_Springs);
map.removeOverlays(Buffalo);
map.removeOverlays(Cheektowaga);
map.removeOverlays(Collins);
map.removeOverlays(Depew);
map.removeOverlays(Gowanda);
map.removeOverlays(Grand_Island);
map.removeOverlays(Hamburg);
map.removeOverlays(Kenmore);
map.removeOverlays(Lancaster);
map.removeOverlays(Snyder);
map.removeOverlays(South_Wales);
map.removeOverlays(Tonawanda);
map.removeOverlays(West_Seneca);
map.removeOverlays(Williamsville);
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(Amherst);map.removeOverlays(Amherst);
map.removeOverlays(Athol_Springs);
map.removeOverlays(Buffalo);
map.removeOverlays(Cheektowaga);
map.removeOverlays(Collins);
map.removeOverlays(Depew);
map.removeOverlays(Gowanda);
map.removeOverlays(Grand_Island);
map.removeOverlays(Hamburg);
map.removeOverlays(Kenmore);
map.removeOverlays(Lancaster);
map.removeOverlays(Snyder);
map.removeOverlays(South_Wales);
map.removeOverlays(Tonawanda);
map.removeOverlays(West_Seneca);
map.removeOverlays(Williamsville);
map.addOverlays(Amherst);
centerByArray(Amherst, false, false);
cntMarker += Amherst.length;
map.addOverlays(Athol_Springs);
centerByArray(Athol_Springs, false, false);
cntMarker += Athol_Springs.length;
map.addOverlays(Buffalo);
centerByArray(Buffalo, false, false);
cntMarker += Buffalo.length;
map.addOverlays(Cheektowaga);
centerByArray(Cheektowaga, false, false);
cntMarker += Cheektowaga.length;
map.addOverlays(Collins);
centerByArray(Collins, false, false);
cntMarker += Collins.length;
map.addOverlays(Depew);
centerByArray(Depew, false, false);
cntMarker += Depew.length;
map.addOverlays(Gowanda);
centerByArray(Gowanda, false, false);
cntMarker += Gowanda.length;
map.addOverlays(Grand_Island);
centerByArray(Grand_Island, false, false);
cntMarker += Grand_Island.length;
map.addOverlays(Hamburg);
centerByArray(Hamburg, false, false);
cntMarker += Hamburg.length;
map.addOverlays(Kenmore);
centerByArray(Kenmore, false, false);
cntMarker += Kenmore.length;
map.addOverlays(Lancaster);
centerByArray(Lancaster, false, false);
cntMarker += Lancaster.length;
map.addOverlays(Snyder);
centerByArray(Snyder, false, false);
cntMarker += Snyder.length;
map.addOverlays(South_Wales);
centerByArray(South_Wales, false, false);
cntMarker += South_Wales.length;
map.addOverlays(Tonawanda);
centerByArray(Tonawanda, false, false);
cntMarker += Tonawanda.length;
map.addOverlays(West_Seneca);
centerByArray(West_Seneca, false, false);
cntMarker += West_Seneca.length;
map.addOverlays(Williamsville);
centerByArray(Williamsville, false, false);
cntMarker += Williamsville.length;
centerByArray(Amherst,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;
}