function addMarkers(){
mySelect = document.getElementById('selection');
Kingston = [];Stone_Ridge = [];Hurley = [];New_Paltz = [];Saugerties = [];Mt_Tremper = [];Highland = [];Wawarsing = [];Rifton = [];Woodstock = [];mySelect.options[mySelect.options.length] = new Option("Highland schools",'all=Highland');
mySelect.options[mySelect.options.length] = new Option("Hurley schools",'all=Hurley');
mySelect.options[mySelect.options.length] = new Option("Kingston schools",'all=Kingston');
mySelect.options[mySelect.options.length] = new Option("Mt Tremper schools",'all=Mt_Tremper');
mySelect.options[mySelect.options.length] = new Option("New Paltz schools",'all=New_Paltz');
mySelect.options[mySelect.options.length] = new Option("Rifton schools",'all=Rifton');
mySelect.options[mySelect.options.length] = new Option("Saugerties schools",'all=Saugerties');
mySelect.options[mySelect.options.length] = new Option("Stone Ridge schools",'all=Stone_Ridge');
mySelect.options[mySelect.options.length] = new Option("Wawarsing schools",'all=Wawarsing');
mySelect.options[mySelect.options.length] = new Option("Woodstock schools",'all=Woodstock');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Kingston[Kingston.length] = createMarker(new GPoint(-74.00393100,41.93533800),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Beginnings",'Kingston=' + Kingston.length);
Kingston[Kingston.length] = createMarker(new GPoint(-73.96454100,41.99628600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Center for Spectrum Services",'Kingston=' + Kingston.length);
Kingston[Kingston.length] = createMarker(new GPoint(-73.97102200,41.92452400),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Children's Home Of Kingston",'Kingston=' + Kingston.length);
Kingston[Kingston.length] = createMarker(new GPoint(-74.00100000,41.93170000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Community Rehab Center Ucp",'Kingston=' + Kingston.length);
Kingston[Kingston.length] = createMarker(new GPoint(-73.99051500,41.92861700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Good Shepherd School",'Kingston=' + Kingston.length);
Stone_Ridge[Stone_Ridge.length] = createMarker(new GPoint(-74.16511900,41.85854000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("High Meadow School Inc",'Stone_Ridge=' + Stone_Ridge.length);
Hurley[Hurley.length] = createMarker(new GPoint(-74.04331700,41.93455300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("John A Coleman Catholic High School",'Hurley=' + Hurley.length);
Kingston[Kingston.length] = createMarker(new GPoint(-73.98781000,41.92205400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kingston Catholic School",'Kingston=' + Kingston.length);
Kingston[Kingston.length] = createMarker(new GPoint(-74.02661000,41.93232700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School Of Kingston",'Kingston=' + Kingston.length);
New_Paltz[New_Paltz.length] = createMarker(new GPoint(-74.08960000,41.74490000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mountain Laurel Waldorf School",'New_Paltz=' + New_Paltz.length);
Kingston[Kingston.length] = createMarker(new GPoint(-74.01888200,41.93121600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Joseph School",'Kingston=' + Kingston.length);
Saugerties[Saugerties.length] = createMarker(new GPoint(-73.95477500,42.07921700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Saugerties Progressive School",'Saugerties=' + Saugerties.length);
Mt_Tremper[Mt_Tremper.length] = createMarker(new GPoint(-74.24046000,42.03526900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("School Of The New Moon",'Mt_Tremper=' + Mt_Tremper.length);
New_Paltz[New_Paltz.length] = createMarker(new GPoint(-74.08960000,41.74490000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Shawangunk Ridge School",'New_Paltz=' + New_Paltz.length);
Highland[Highland.length] = createMarker(new GPoint(-73.96822300,41.72288200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Augustine School",'Highland=' + Highland.length);
Saugerties[Saugerties.length] = createMarker(new GPoint(-73.94694200,42.07798100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Mary Of The Snow School",'Saugerties=' + Saugerties.length);
Wawarsing[Wawarsing.length] = createMarker(new GPoint(-74.35770000,41.75880000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wawarsing Christian Academy",'Wawarsing=' + Wawarsing.length);
Kingston[Kingston.length] = createMarker(new GPoint(-74.00945000,41.93284100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Winter Bear Montessori School",'Kingston=' + Kingston.length);
Rifton[Rifton.length] = createMarker(new GPoint(-74.03770000,41.83750000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Woodcrest School",'Rifton=' + Rifton.length);
Woodstock[Woodstock.length] = createMarker(new GPoint(-74.18861600,42.02169700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Woodstock Day School",'Woodstock=' + Woodstock.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/////3/' + showArray);
map.removeOverlays(Highland);
map.removeOverlays(Hurley);
map.removeOverlays(Kingston);
map.removeOverlays(Mt_Tremper);
map.removeOverlays(New_Paltz);
map.removeOverlays(Rifton);
map.removeOverlays(Saugerties);
map.removeOverlays(Stone_Ridge);
map.removeOverlays(Wawarsing);
map.removeOverlays(Woodstock);
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(Kingston);map.removeOverlays(Highland);
map.removeOverlays(Hurley);
map.removeOverlays(Kingston);
map.removeOverlays(Mt_Tremper);
map.removeOverlays(New_Paltz);
map.removeOverlays(Rifton);
map.removeOverlays(Saugerties);
map.removeOverlays(Stone_Ridge);
map.removeOverlays(Wawarsing);
map.removeOverlays(Woodstock);
map.addOverlays(Highland);
centerByArray(Highland, false, false);
cntMarker += Highland.length;
map.addOverlays(Hurley);
centerByArray(Hurley, false, false);
cntMarker += Hurley.length;
map.addOverlays(Kingston);
centerByArray(Kingston, false, false);
cntMarker += Kingston.length;
map.addOverlays(Mt_Tremper);
centerByArray(Mt_Tremper, false, false);
cntMarker += Mt_Tremper.length;
map.addOverlays(New_Paltz);
centerByArray(New_Paltz, false, false);
cntMarker += New_Paltz.length;
map.addOverlays(Rifton);
centerByArray(Rifton, false, false);
cntMarker += Rifton.length;
map.addOverlays(Saugerties);
centerByArray(Saugerties, false, false);
cntMarker += Saugerties.length;
map.addOverlays(Stone_Ridge);
centerByArray(Stone_Ridge, false, false);
cntMarker += Stone_Ridge.length;
map.addOverlays(Wawarsing);
centerByArray(Wawarsing, false, false);
cntMarker += Wawarsing.length;
map.addOverlays(Woodstock);
centerByArray(Woodstock, false, false);
cntMarker += Woodstock.length;
centerByArray(Kingston,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=3&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;
}