function addMarkers(){
mySelect = document.getElementById('selection');
Staatsburg = [];Rhinebeck = [];Hopewell_Junction = [];Millbrook = [];Poughkeepsie = [];Red_Hook = [];Amenia = [];Wappingers_Falls = [];Pawling = [];Clinton_Corners = [];mySelect.options[mySelect.options.length] = new Option("Amenia schools",'all=Amenia');
mySelect.options[mySelect.options.length] = new Option("Clinton Corners schools",'all=Clinton_Corners');
mySelect.options[mySelect.options.length] = new Option("Hopewell Junction schools",'all=Hopewell_Junction');
mySelect.options[mySelect.options.length] = new Option("Millbrook schools",'all=Millbrook');
mySelect.options[mySelect.options.length] = new Option("Pawling schools",'all=Pawling');
mySelect.options[mySelect.options.length] = new Option("Poughkeepsie schools",'all=Poughkeepsie');
mySelect.options[mySelect.options.length] = new Option("Red Hook schools",'all=Red_Hook');
mySelect.options[mySelect.options.length] = new Option("Rhinebeck schools",'all=Rhinebeck');
mySelect.options[mySelect.options.length] = new Option("Staatsburg schools",'all=Staatsburg');
mySelect.options[mySelect.options.length] = new Option("Wappingers Falls schools",'all=Wappingers_Falls');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Staatsburg[Staatsburg.length] = createMarker(new GPoint(-73.89240000,41.85140000),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Anderson School",'Staatsburg=' + Staatsburg.length);
Rhinebeck[Rhinebeck.length] = createMarker(new GPoint(-73.88450000,41.92770000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Astor Learning Center",'Rhinebeck=' + Rhinebeck.length);
Hopewell_Junction[Hopewell_Junction.length] = createMarker(new GPoint(-73.78993300,41.52895300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethel Christian Academy",'Hopewell_Junction=' + Hopewell_Junction.length);
Millbrook[Millbrook.length] = createMarker(new GPoint(-73.82950000,42.00180000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cardinal Hayes School For Spec",'Millbrook=' + Millbrook.length);
Poughkeepsie[Poughkeepsie.length] = createMarker(new GPoint(-73.92960000,41.71610000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Day Training Center (rehab Prog",'Poughkeepsie=' + Poughkeepsie.length);
Red_Hook[Red_Hook.length] = createMarker(new GPoint(-73.82970000,42.00170000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Devereux Foundation",'Red_Hook=' + Red_Hook.length);
Millbrook[Millbrook.length] = createMarker(new GPoint(-73.68240000,41.78850000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Duane Lake Academy",'Millbrook=' + Millbrook.length);
Poughkeepsie[Poughkeepsie.length] = createMarker(new GPoint(-73.88432400,41.65545800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Christian Academy",'Poughkeepsie=' + Poughkeepsie.length);
Poughkeepsie[Poughkeepsie.length] = createMarker(new GPoint(-73.88432400,41.65545800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Christian Academy",'Poughkeepsie=' + Poughkeepsie.length);
Amenia[Amenia.length] = createMarker(new GPoint(-73.55782000,41.89139300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Kildonan School",'Amenia=' + Amenia.length);
Amenia[Amenia.length] = createMarker(new GPoint(-73.54671400,41.86560500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Maplebrook School",'Amenia=' + Amenia.length);
Amenia[Amenia.length] = createMarker(new GPoint(-73.54606200,41.86614200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Maplebrook School",'Amenia=' + Amenia.length);
Millbrook[Millbrook.length] = createMarker(new GPoint(-73.67760000,41.78980000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Millbrook School",'Millbrook=' + Millbrook.length);
Red_Hook[Red_Hook.length] = createMarker(new GPoint(-73.87097700,41.99167800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northern Dutchess Christian School",'Red_Hook=' + Red_Hook.length);
Poughkeepsie[Poughkeepsie.length] = createMarker(new GPoint(-73.92501700,41.65852100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Oakwood Friends School",'Poughkeepsie=' + Poughkeepsie.length);
Poughkeepsie[Poughkeepsie.length] = createMarker(new GPoint(-73.88873700,41.66510900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of Lourdes High School",'Poughkeepsie=' + Poughkeepsie.length);
Poughkeepsie[Poughkeepsie.length] = createMarker(new GPoint(-73.88963200,41.65913100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Poughkeepsie Day School",'Poughkeepsie=' + Poughkeepsie.length);
Wappingers_Falls[Wappingers_Falls.length] = createMarker(new GPoint(-73.92225400,41.58633300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Randolph School",'Wappingers_Falls=' + Wappingers_Falls.length);
Poughkeepsie[Poughkeepsie.length] = createMarker(new GPoint(-73.92854400,41.69347000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tabernacle Christian Academy",'Poughkeepsie=' + Poughkeepsie.length);
Pawling[Pawling.length] = createMarker(new GPoint(-73.59298500,41.57081600),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Trinity-pawling School",'Pawling=' + Pawling.length);
Clinton_Corners[Clinton_Corners.length] = createMarker(new GPoint(-73.76576800,41.86851500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Upton Lake Christian School",'Clinton_Corners=' + Clinton_Corners.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(Amenia);
map.removeOverlays(Clinton_Corners);
map.removeOverlays(Hopewell_Junction);
map.removeOverlays(Millbrook);
map.removeOverlays(Pawling);
map.removeOverlays(Poughkeepsie);
map.removeOverlays(Red_Hook);
map.removeOverlays(Rhinebeck);
map.removeOverlays(Staatsburg);
map.removeOverlays(Wappingers_Falls);
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(Staatsburg);map.removeOverlays(Amenia);
map.removeOverlays(Clinton_Corners);
map.removeOverlays(Hopewell_Junction);
map.removeOverlays(Millbrook);
map.removeOverlays(Pawling);
map.removeOverlays(Poughkeepsie);
map.removeOverlays(Red_Hook);
map.removeOverlays(Rhinebeck);
map.removeOverlays(Staatsburg);
map.removeOverlays(Wappingers_Falls);
map.addOverlays(Amenia);
centerByArray(Amenia, false, false);
cntMarker += Amenia.length;
map.addOverlays(Clinton_Corners);
centerByArray(Clinton_Corners, false, false);
cntMarker += Clinton_Corners.length;
map.addOverlays(Hopewell_Junction);
centerByArray(Hopewell_Junction, false, false);
cntMarker += Hopewell_Junction.length;
map.addOverlays(Millbrook);
centerByArray(Millbrook, false, false);
cntMarker += Millbrook.length;
map.addOverlays(Pawling);
centerByArray(Pawling, false, false);
cntMarker += Pawling.length;
map.addOverlays(Poughkeepsie);
centerByArray(Poughkeepsie, false, false);
cntMarker += Poughkeepsie.length;
map.addOverlays(Red_Hook);
centerByArray(Red_Hook, false, false);
cntMarker += Red_Hook.length;
map.addOverlays(Rhinebeck);
centerByArray(Rhinebeck, false, false);
cntMarker += Rhinebeck.length;
map.addOverlays(Staatsburg);
centerByArray(Staatsburg, false, false);
cntMarker += Staatsburg.length;
map.addOverlays(Wappingers_Falls);
centerByArray(Wappingers_Falls, false, false);
cntMarker += Wappingers_Falls.length;
centerByArray(Staatsburg,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;
}