function addMarkers(){
mySelect = document.getElementById('selection');
Penn_Yan = [];Himrod = [];Dundee = [];Lakemont = [];Keuka_Park = [];mySelect.options[mySelect.options.length] = new Option("Dundee schools",'all=Dundee');
mySelect.options[mySelect.options.length] = new Option("Himrod schools",'all=Himrod');
mySelect.options[mySelect.options.length] = new Option("Keuka Park schools",'all=Keuka_Park');
mySelect.options[mySelect.options.length] = new Option("Lakemont schools",'all=Lakemont');
mySelect.options[mySelect.options.length] = new Option("Penn Yan schools",'all=Penn_Yan');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Penn_Yan[Penn_Yan.length] = createMarker(new GPoint(-77.07986600,42.70142500),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Benton Mennonite School",'Penn_Yan=' + Penn_Yan.length);
Himrod[Himrod.length] = createMarker(new GPoint(-76.94600000,42.59430000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chubb Hollow Mennonite School",'Himrod=' + Himrod.length);
Penn_Yan[Penn_Yan.length] = createMarker(new GPoint(-77.05425100,42.61532800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Creekside Mennonite School",'Penn_Yan=' + Penn_Yan.length);
Dundee[Dundee.length] = createMarker(new GPoint(-77.06302400,42.48830500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Crystal Valley Christian School",'Dundee=' + Dundee.length);
Penn_Yan[Penn_Yan.length] = createMarker(new GPoint(-77.05818700,42.66794800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Emmanuel Baptist Academy",'Penn_Yan=' + Penn_Yan.length);
Lakemont[Lakemont.length] = createMarker(new GPoint(-76.92830000,42.51610000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Freedom Academy",'Lakemont=' + Lakemont.length);
Dundee[Dundee.length] = createMarker(new GPoint(-77.00662000,42.50587600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gravel Run Mennonite School",'Dundee=' + Dundee.length);
Penn_Yan[Penn_Yan.length] = createMarker(new GPoint(-77.01430300,42.74606400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kashong School",'Penn_Yan=' + Penn_Yan.length);
Dundee[Dundee.length] = createMarker(new GPoint(-76.95875900,42.53961200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Meadow Lane School",'Dundee=' + Dundee.length);
Penn_Yan[Penn_Yan.length] = createMarker(new GPoint(-76.94366200,42.63204900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Conquest Mennonite School",'Penn_Yan=' + Penn_Yan.length);
Keuka_Park[Keuka_Park.length] = createMarker(new GPoint(-77.13252300,42.63300700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pine Grove Mennonite School",'Keuka_Park=' + Keuka_Park.length);
Dundee[Dundee.length] = createMarker(new GPoint(-77.01801700,42.52281500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Scenic Valley Mennonite School",'Dundee=' + Dundee.length);
Dundee[Dundee.length] = createMarker(new GPoint(-76.95089700,42.56575900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Spring Hill Mennonite School",'Dundee=' + Dundee.length);
Penn_Yan[Penn_Yan.length] = createMarker(new GPoint(-77.05849400,42.66141900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Michaels Elementary School",'Penn_Yan=' + Penn_Yan.length);
Penn_Yan[Penn_Yan.length] = createMarker(new GPoint(-77.07470200,42.71730400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sunny Haven Mennonite School",'Penn_Yan=' + Penn_Yan.length);
Dundee[Dundee.length] = createMarker(new GPoint(-77.03981100,42.54723400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sunny View Mennonite School",'Dundee=' + Dundee.length);
Penn_Yan[Penn_Yan.length] = createMarker(new GPoint(-76.99602800,42.67895900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Torrey Ridge Mennonite School",'Penn_Yan=' + Penn_Yan.length);
Penn_Yan[Penn_Yan.length] = createMarker(new GPoint(-77.05500000,42.65760000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Townline School",'Penn_Yan=' + Penn_Yan.length);
Dundee[Dundee.length] = createMarker(new GPoint(-76.97145700,42.55348400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Walnut View Mennonite School",'Dundee=' + Dundee.length);
Penn_Yan[Penn_Yan.length] = createMarker(new GPoint(-77.10994500,42.66566200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West Wood Mennonite School",'Penn_Yan=' + Penn_Yan.length);
Penn_Yan[Penn_Yan.length] = createMarker(new GPoint(-77.02522000,42.58432200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wood Corner Mennonite School",'Penn_Yan=' + Penn_Yan.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(Dundee);
map.removeOverlays(Himrod);
map.removeOverlays(Keuka_Park);
map.removeOverlays(Lakemont);
map.removeOverlays(Penn_Yan);
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(Penn_Yan);map.removeOverlays(Dundee);
map.removeOverlays(Himrod);
map.removeOverlays(Keuka_Park);
map.removeOverlays(Lakemont);
map.removeOverlays(Penn_Yan);
map.addOverlays(Dundee);
centerByArray(Dundee, false, false);
cntMarker += Dundee.length;
map.addOverlays(Himrod);
centerByArray(Himrod, false, false);
cntMarker += Himrod.length;
map.addOverlays(Keuka_Park);
centerByArray(Keuka_Park, false, false);
cntMarker += Keuka_Park.length;
map.addOverlays(Lakemont);
centerByArray(Lakemont, false, false);
cntMarker += Lakemont.length;
map.addOverlays(Penn_Yan);
centerByArray(Penn_Yan, false, false);
cntMarker += Penn_Yan.length;
centerByArray(Penn_Yan,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;
}