function addMarkers(){
mySelect = document.getElementById('selection');
Baldwinsville = [];Syracuse = [];Cicero = [];Fayetteville = [];Dewitt = [];East_Syracuse = [];North_Syracuse = [];Mattydale = [];mySelect.options[mySelect.options.length] = new Option("Baldwinsville schools",'all=Baldwinsville');
mySelect.options[mySelect.options.length] = new Option("Cicero schools",'all=Cicero');
mySelect.options[mySelect.options.length] = new Option("Dewitt schools",'all=Dewitt');
mySelect.options[mySelect.options.length] = new Option("East Syracuse schools",'all=East_Syracuse');
mySelect.options[mySelect.options.length] = new Option("Fayetteville schools",'all=Fayetteville');
mySelect.options[mySelect.options.length] = new Option("Mattydale schools",'all=Mattydale');
mySelect.options[mySelect.options.length] = new Option("North Syracuse schools",'all=North_Syracuse');
mySelect.options[mySelect.options.length] = new Option("Syracuse schools",'all=Syracuse');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Baldwinsville[Baldwinsville.length] = createMarker(new GPoint(-76.31733900,43.12464400),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Baldwinsville Christian Academy",'Baldwinsville=' + Baldwinsville.length);
Syracuse[Syracuse.length] = createMarker(new GPoint(-76.10240600,43.06915600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Blessed Sacrament School",'Syracuse=' + Syracuse.length);
Syracuse[Syracuse.length] = createMarker(new GPoint(-76.16846700,43.05113700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Blessed Virgin Mary Mother Of God Academy",'Syracuse=' + Syracuse.length);
Syracuse[Syracuse.length] = createMarker(new GPoint(-76.14898700,43.04649700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cathedral School",'Syracuse=' + Syracuse.length);
Cicero[Cicero.length] = createMarker(new GPoint(-76.11947100,43.16310700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Childtime Chldrn Center",'Cicero=' + Cicero.length);
Baldwinsville[Baldwinsville.length] = createMarker(new GPoint(-76.30753600,43.17669400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Childtime Learning Center",'Baldwinsville=' + Baldwinsville.length);
Fayetteville[Fayetteville.length] = createMarker(new GPoint(-76.00205500,43.03048900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Creative Environment Day School",'Fayetteville=' + Fayetteville.length);
Syracuse[Syracuse.length] = createMarker(new GPoint(-76.14725300,43.00350300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Heritage School",'Syracuse=' + Syracuse.length);
Dewitt[Dewitt.length] = createMarker(new GPoint(-76.07327600,43.03622800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Cross Elementary School",'Dewitt=' + Dewitt.length);
Syracuse[Syracuse.length] = createMarker(new GPoint(-76.23966800,43.04605300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Family School",'Syracuse=' + Syracuse.length);
Fayetteville[Fayetteville.length] = createMarker(new GPoint(-75.99296300,43.02683300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Immaculate Conception School",'Fayetteville=' + Fayetteville.length);
Syracuse[Syracuse.length] = createMarker(new GPoint(-76.10014600,43.04279800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jowonio School",'Syracuse=' + Syracuse.length);
Syracuse[Syracuse.length] = createMarker(new GPoint(-76.09793000,43.08436400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Living Word Academy",'Syracuse=' + Syracuse.length);
Syracuse[Syracuse.length] = createMarker(new GPoint(-76.15743900,43.04039000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Madrasat Al Ihsan",'Syracuse=' + Syracuse.length);
Dewitt[Dewitt.length] = createMarker(new GPoint(-76.07140600,43.02656300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Manlius Pebble Hill School",'Dewitt=' + Dewitt.length);
Syracuse[Syracuse.length] = createMarker(new GPoint(-76.12416600,43.06407700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Merriday School",'Syracuse=' + Syracuse.length);
Syracuse[Syracuse.length] = createMarker(new GPoint(-76.10998600,43.02632700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School of Syracuse",'Syracuse=' + Syracuse.length);
Syracuse[Syracuse.length] = createMarker(new GPoint(-76.17134000,43.03283600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Most Holy Rosary School",'Syracuse=' + Syracuse.length);
Syracuse[Syracuse.length] = createMarker(new GPoint(-76.12444800,43.05377900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The New School",'Syracuse=' + Syracuse.length);
Syracuse[Syracuse.length] = createMarker(new GPoint(-76.14916200,43.05930200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of Pompei School",'Syracuse=' + Syracuse.length);
Syracuse[Syracuse.length] = createMarker(new GPoint(-76.18975900,43.04215900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Parkview Jr Academy",'Syracuse=' + Syracuse.length);
Syracuse[Syracuse.length] = createMarker(new GPoint(-76.17979400,43.05226300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sacred Heart School",'Syracuse=' + Syracuse.length);
Syracuse[Syracuse.length] = createMarker(new GPoint(-76.20425200,43.02820800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Ann's School",'Syracuse=' + Syracuse.length);
Syracuse[Syracuse.length] = createMarker(new GPoint(-76.16141500,43.04349400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Lucy's Academy",'Syracuse=' + Syracuse.length);
East_Syracuse[East_Syracuse.length] = createMarker(new GPoint(-76.07661100,43.06767100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Matthew School",'East_Syracuse=' + East_Syracuse.length);
North_Syracuse[North_Syracuse.length] = createMarker(new GPoint(-76.13231000,43.13093800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Rose Of Lima School",'North_Syracuse=' + North_Syracuse.length);
Syracuse[Syracuse.length] = createMarker(new GPoint(-76.20275300,43.04045400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Charles Borromeo School",'Syracuse=' + Syracuse.length);
Syracuse[Syracuse.length] = createMarker(new GPoint(-76.12649700,43.08183800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Daniel School",'Syracuse=' + Syracuse.length);
Syracuse[Syracuse.length] = createMarker(new GPoint(-76.14277800,42.99896500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St James School",'Syracuse=' + Syracuse.length);
Mattydale[Mattydale.length] = createMarker(new GPoint(-76.14760100,43.09973400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Margarets School",'Mattydale=' + Mattydale.length);
Baldwinsville[Baldwinsville.length] = createMarker(new GPoint(-76.32994800,43.15315900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Mary's Academy",'Baldwinsville=' + Baldwinsville.length);
Syracuse[Syracuse.length] = createMarker(new GPoint(-76.18302300,43.05082800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Patricks School",'Syracuse=' + Syracuse.length);
Syracuse[Syracuse.length] = createMarker(new GPoint(-76.07320200,43.04492800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Syracuse Hebrew Day School",'Syracuse=' + Syracuse.length);
Baldwinsville[Baldwinsville.length] = createMarker(new GPoint(-76.34858400,43.15176100),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Temple Baptist Academy",'Baldwinsville=' + Baldwinsville.length);
Baldwinsville[Baldwinsville.length] = createMarker(new GPoint(-76.33260400,43.16218000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Word of Life Christian Academy",'Baldwinsville=' + Baldwinsville.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/////1/' + showArray);
map.removeOverlays(Baldwinsville);
map.removeOverlays(Cicero);
map.removeOverlays(Dewitt);
map.removeOverlays(East_Syracuse);
map.removeOverlays(Fayetteville);
map.removeOverlays(Mattydale);
map.removeOverlays(North_Syracuse);
map.removeOverlays(Syracuse);
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(Baldwinsville);map.removeOverlays(Baldwinsville);
map.removeOverlays(Cicero);
map.removeOverlays(Dewitt);
map.removeOverlays(East_Syracuse);
map.removeOverlays(Fayetteville);
map.removeOverlays(Mattydale);
map.removeOverlays(North_Syracuse);
map.removeOverlays(Syracuse);
map.addOverlays(Baldwinsville);
centerByArray(Baldwinsville, false, false);
cntMarker += Baldwinsville.length;
map.addOverlays(Cicero);
centerByArray(Cicero, false, false);
cntMarker += Cicero.length;
map.addOverlays(Dewitt);
centerByArray(Dewitt, false, false);
cntMarker += Dewitt.length;
map.addOverlays(East_Syracuse);
centerByArray(East_Syracuse, false, false);
cntMarker += East_Syracuse.length;
map.addOverlays(Fayetteville);
centerByArray(Fayetteville, false, false);
cntMarker += Fayetteville.length;
map.addOverlays(Mattydale);
centerByArray(Mattydale, false, false);
cntMarker += Mattydale.length;
map.addOverlays(North_Syracuse);
centerByArray(North_Syracuse, false, false);
cntMarker += North_Syracuse.length;
map.addOverlays(Syracuse);
centerByArray(Syracuse, false, false);
cntMarker += Syracuse.length;
centerByArray(Baldwinsville,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=1&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;
}