function addMarkers(){
mySelect = document.getElementById('selection');
Monroe = [];Newburgh = [];New_Windsor = [];Warwick = [];Port_Jervis = [];Pine_Bush = [];Washingtonville = [];Goshen = [];Middletown = [];Walden = [];Highland_Falls = [];Cornwall_On_Hudson = [];Florida = [];Highland_Mills = [];Tuxedo_Park = [];mySelect.options[mySelect.options.length] = new Option("Cornwall On Hudson schools",'all=Cornwall_On_Hudson');
mySelect.options[mySelect.options.length] = new Option("Florida schools",'all=Florida');
mySelect.options[mySelect.options.length] = new Option("Goshen schools",'all=Goshen');
mySelect.options[mySelect.options.length] = new Option("Highland Falls schools",'all=Highland_Falls');
mySelect.options[mySelect.options.length] = new Option("Highland Mills schools",'all=Highland_Mills');
mySelect.options[mySelect.options.length] = new Option("Middletown schools",'all=Middletown');
mySelect.options[mySelect.options.length] = new Option("Monroe schools",'all=Monroe');
mySelect.options[mySelect.options.length] = new Option("New Windsor schools",'all=New_Windsor');
mySelect.options[mySelect.options.length] = new Option("Newburgh schools",'all=Newburgh');
mySelect.options[mySelect.options.length] = new Option("Pine Bush schools",'all=Pine_Bush');
mySelect.options[mySelect.options.length] = new Option("Port Jervis schools",'all=Port_Jervis');
mySelect.options[mySelect.options.length] = new Option("Tuxedo Park schools",'all=Tuxedo_Park');
mySelect.options[mySelect.options.length] = new Option("Walden schools",'all=Walden');
mySelect.options[mySelect.options.length] = new Option("Warwick schools",'all=Warwick');
mySelect.options[mySelect.options.length] = new Option("Washingtonville schools",'all=Washingtonville');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Monroe[Monroe.length] = createMarker(new GPoint(-74.16152500,41.33749900),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bais Rochel School",'Monroe=' + Monroe.length);
Newburgh[Newburgh.length] = createMarker(new GPoint(-74.01314800,41.50819300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bishop Dunn Memorial",'Newburgh=' + Newburgh.length);
Monroe[Monroe.length] = createMarker(new GPoint(-74.19930000,41.30860000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bnei Yoel School",'Monroe=' + Monroe.length);
New_Windsor[New_Windsor.length] = createMarker(new GPoint(-74.03669600,41.46431700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Butterhill Day School",'New_Windsor=' + New_Windsor.length);
Warwick[Warwick.length] = createMarker(new GPoint(-74.32666400,41.27342000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calvary Christian Academy",'Warwick=' + Warwick.length);
Port_Jervis[Port_Jervis.length] = createMarker(new GPoint(-74.65860000,41.37510000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calvary Christian School",'Port_Jervis=' + Port_Jervis.length);
Pine_Bush[Pine_Bush.length] = createMarker(new GPoint(-74.24518200,41.60227300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chapel Field Christian High School",'Pine_Bush=' + Pine_Bush.length);
New_Windsor[New_Windsor.length] = createMarker(new GPoint(-74.10354200,41.48316700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Children S Country Day School",'New_Windsor=' + New_Windsor.length);
Warwick[Warwick.length] = createMarker(new GPoint(-74.35379500,41.28398300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Day Spring Community School",'Warwick=' + Warwick.length);
Washingtonville[Washingtonville.length] = createMarker(new GPoint(-74.15752600,41.42772600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("English Rose Day School",'Washingtonville=' + Washingtonville.length);
Goshen[Goshen.length] = createMarker(new GPoint(-74.34153700,41.38603400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Goshen Christian School",'Goshen=' + Goshen.length);
Middletown[Middletown.length] = createMarker(new GPoint(-74.29881400,41.48239800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Harmony Christian School",'Middletown=' + Middletown.length);
Washingtonville[Washingtonville.length] = createMarker(new GPoint(-74.14096300,41.47490400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hudson Valley Circle Of Learning School",'Washingtonville=' + Washingtonville.length);
Newburgh[Newburgh.length] = createMarker(new GPoint(-74.07478800,41.55768100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Leptondale Christian Academy",'Newburgh=' + Newburgh.length);
New_Windsor[New_Windsor.length] = createMarker(new GPoint(-74.02608900,41.48755000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Little Harvard",'New_Windsor=' + New_Windsor.length);
Washingtonville[Washingtonville.length] = createMarker(new GPoint(-74.15831800,41.42678400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Little Harvard At Washingtonville",'Washingtonville=' + Washingtonville.length);
New_Windsor[New_Windsor.length] = createMarker(new GPoint(-74.05580000,41.46690000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mcquade Childrens Services Kaplan Campus School",'New_Windsor=' + New_Windsor.length);
Middletown[Middletown.length] = createMarker(new GPoint(-74.42060900,41.45063000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Middletown Christian School-sda",'Middletown=' + Middletown.length);
Monroe[Monroe.length] = createMarker(new GPoint(-74.19930000,41.30860000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Monroe Day School",'Monroe=' + Monroe.length);
Walden[Walden.length] = createMarker(new GPoint(-74.18554500,41.56913800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Most Precious Blood School",'Walden=' + Walden.length);
Middletown[Middletown.length] = createMarker(new GPoint(-74.40905500,41.45017800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Beginnings Montessori",'Middletown=' + Middletown.length);
Newburgh[Newburgh.length] = createMarker(new GPoint(-74.00934800,41.50844100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Newburgh Jabemacle Elementary School",'Newburgh=' + Newburgh.length);
Middletown[Middletown.length] = createMarker(new GPoint(-74.44221700,41.46254900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Nysarc-orange Inc",'Middletown=' + Middletown.length);
Middletown[Middletown.length] = createMarker(new GPoint(-74.43495800,41.43229000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of Mount Carmel School",'Middletown=' + Middletown.length);
Highland_Falls[Highland_Falls.length] = createMarker(new GPoint(-73.96497100,41.37232900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sacred Heart of Jesus School",'Highland_Falls=' + Highland_Falls.length);
Monroe[Monroe.length] = createMarker(new GPoint(-74.17936100,41.31657400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sacred Heart School",'Monroe=' + Monroe.length);
Newburgh[Newburgh.length] = createMarker(new GPoint(-74.02166200,41.49958500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sacred Heart School",'Newburgh=' + Newburgh.length);
Goshen[Goshen.length] = createMarker(new GPoint(-74.32572900,41.40588500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. John School",'Goshen=' + Goshen.length);
Cornwall_On_Hudson[Cornwall_On_Hudson.length] = createMarker(new GPoint(-74.02245700,41.44386400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Thomas Of Canterbury",'Cornwall_On_Hudson=' + Cornwall_On_Hudson.length);
Monroe[Monroe.length] = createMarker(new GPoint(-74.18712900,41.32812000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Sheri Torah, Inc. V'yoel Moshe",'Monroe=' + Monroe.length);
New_Windsor[New_Windsor.length] = createMarker(new GPoint(-74.04062400,41.48014700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Joseph School",'New_Windsor=' + New_Windsor.length);
Florida[Florida.length] = createMarker(new GPoint(-74.35527200,41.33252900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Joseph School",'Florida=' + Florida.length);
Middletown[Middletown.length] = createMarker(new GPoint(-74.41146200,41.45203700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Joseph School",'Middletown=' + Middletown.length);
Monroe[Monroe.length] = createMarker(new GPoint(-74.17874800,41.31822000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Paul Christian Education Center",'Monroe=' + Monroe.length);
Warwick[Warwick.length] = createMarker(new GPoint(-74.38808300,41.25641600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Stephen St Edward School",'Warwick=' + Warwick.length);
Cornwall_On_Hudson[Cornwall_On_Hudson.length] = createMarker(new GPoint(-87.65601400,41.96984600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Thomas Of Canterbury School",'Cornwall_On_Hudson=' + Cornwall_On_Hudson.length);
Highland_Mills[Highland_Mills.length] = createMarker(new GPoint(-74.11897500,41.35904200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Thevenet Montessori School",'Highland_Mills=' + Highland_Mills.length);
Port_Jervis[Port_Jervis.length] = createMarker(new GPoint(-74.66020000,41.37590000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Catholic School",'Port_Jervis=' + Port_Jervis.length);
Tuxedo_Park[Tuxedo_Park.length] = createMarker(new GPoint(-74.21250900,41.21346200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tuxedo Park School",'Tuxedo_Park=' + Tuxedo_Park.length);
New_Windsor[New_Windsor.length] = createMarker(new GPoint(-74.02763800,41.47050900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Windsor Academy",'New_Windsor=' + New_Windsor.length);
New_Windsor[New_Windsor.length] = createMarker(new GPoint(-74.10355600,41.48312900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Woodland Montessori",'New_Windsor=' + New_Windsor.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(Cornwall_On_Hudson);
map.removeOverlays(Florida);
map.removeOverlays(Goshen);
map.removeOverlays(Highland_Falls);
map.removeOverlays(Highland_Mills);
map.removeOverlays(Middletown);
map.removeOverlays(Monroe);
map.removeOverlays(New_Windsor);
map.removeOverlays(Newburgh);
map.removeOverlays(Pine_Bush);
map.removeOverlays(Port_Jervis);
map.removeOverlays(Tuxedo_Park);
map.removeOverlays(Walden);
map.removeOverlays(Warwick);
map.removeOverlays(Washingtonville);
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(Monroe);map.removeOverlays(Cornwall_On_Hudson);
map.removeOverlays(Florida);
map.removeOverlays(Goshen);
map.removeOverlays(Highland_Falls);
map.removeOverlays(Highland_Mills);
map.removeOverlays(Middletown);
map.removeOverlays(Monroe);
map.removeOverlays(New_Windsor);
map.removeOverlays(Newburgh);
map.removeOverlays(Pine_Bush);
map.removeOverlays(Port_Jervis);
map.removeOverlays(Tuxedo_Park);
map.removeOverlays(Walden);
map.removeOverlays(Warwick);
map.removeOverlays(Washingtonville);
map.addOverlays(Cornwall_On_Hudson);
centerByArray(Cornwall_On_Hudson, false, false);
cntMarker += Cornwall_On_Hudson.length;
map.addOverlays(Florida);
centerByArray(Florida, false, false);
cntMarker += Florida.length;
map.addOverlays(Goshen);
centerByArray(Goshen, false, false);
cntMarker += Goshen.length;
map.addOverlays(Highland_Falls);
centerByArray(Highland_Falls, false, false);
cntMarker += Highland_Falls.length;
map.addOverlays(Highland_Mills);
centerByArray(Highland_Mills, false, false);
cntMarker += Highland_Mills.length;
map.addOverlays(Middletown);
centerByArray(Middletown, false, false);
cntMarker += Middletown.length;
map.addOverlays(Monroe);
centerByArray(Monroe, false, false);
cntMarker += Monroe.length;
map.addOverlays(New_Windsor);
centerByArray(New_Windsor, false, false);
cntMarker += New_Windsor.length;
map.addOverlays(Newburgh);
centerByArray(Newburgh, false, false);
cntMarker += Newburgh.length;
map.addOverlays(Pine_Bush);
centerByArray(Pine_Bush, false, false);
cntMarker += Pine_Bush.length;
map.addOverlays(Port_Jervis);
centerByArray(Port_Jervis, false, false);
cntMarker += Port_Jervis.length;
map.addOverlays(Tuxedo_Park);
centerByArray(Tuxedo_Park, false, false);
cntMarker += Tuxedo_Park.length;
map.addOverlays(Walden);
centerByArray(Walden, false, false);
cntMarker += Walden.length;
map.addOverlays(Warwick);
centerByArray(Warwick, false, false);
cntMarker += Warwick.length;
map.addOverlays(Washingtonville);
centerByArray(Washingtonville, false, false);
cntMarker += Washingtonville.length;
centerByArray(Monroe,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;
}