function addMarkers(){
mySelect = document.getElementById('selection');
Berne = [];Decatur = [];Monroe = [];Geneva = [];mySelect.options[mySelect.options.length] = new Option("Berne schools",'all=Berne');
mySelect.options[mySelect.options.length] = new Option("Decatur schools",'all=Decatur');
mySelect.options[mySelect.options.length] = new Option("Geneva schools",'all=Geneva');
mySelect.options[mySelect.options.length] = new Option("Monroe schools",'all=Monroe');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Berne[Berne.length] = createMarker(new GPoint(-84.97510000,40.71426000),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Clearview Amish School",'Berne=' + Berne.length);
Decatur[Decatur.length] = createMarker(new GPoint(-84.93530000,40.83680000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Countryside School",'Decatur=' + Decatur.length);
Monroe[Monroe.length] = createMarker(new GPoint(-84.97477000,40.73054100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fairview Amish School",'Monroe=' + Monroe.length);
Berne[Berne.length] = createMarker(new GPoint(-84.95470000,40.64310000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Christian Academy",'Berne=' + Berne.length);
Geneva[Geneva.length] = createMarker(new GPoint(-84.90690000,40.60364200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hartford Valley School",'Geneva=' + Geneva.length);
Geneva[Geneva.length] = createMarker(new GPoint(-84.85912700,40.60763000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jefferson Parochial Amish School",'Geneva=' + Geneva.length);
Berne[Berne.length] = createMarker(new GPoint(-84.94620000,40.66040000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lincoln Amish School",'Berne=' + Berne.length);
Berne[Berne.length] = createMarker(new GPoint(-84.91742200,40.66988000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Maple Leaf",'Berne=' + Berne.length);
Monroe[Monroe.length] = createMarker(new GPoint(-84.88315300,40.70243600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Oak Grove Amish School",'Monroe=' + Monroe.length);
Berne[Berne.length] = createMarker(new GPoint(-84.94899600,40.70141300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Plain View Amish School",'Berne=' + Berne.length);
Monroe[Monroe.length] = createMarker(new GPoint(-84.91762000,40.72840100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pleasant Valley",'Monroe=' + Monroe.length);
Berne[Berne.length] = createMarker(new GPoint(-84.86859600,40.65515900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Prairie School",'Berne=' + Berne.length);
Decatur[Decatur.length] = createMarker(new GPoint(-84.92670400,40.83008500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Joseph Elementary School",'Decatur=' + Decatur.length);
Decatur[Decatur.length] = createMarker(new GPoint(-84.86476800,40.90606300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Peter-immanuel Lutheran",'Decatur=' + Decatur.length);
Monroe[Monroe.length] = createMarker(new GPoint(-84.84071800,40.70310000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Shady Lane School",'Monroe=' + Monroe.length);
Geneva[Geneva.length] = createMarker(new GPoint(-84.89257600,40.60745800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Adams Parochial",'Geneva=' + Geneva.length);
Berne[Berne.length] = createMarker(new GPoint(-84.93530000,40.83680000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South East Amish School",'Berne=' + Berne.length);
Geneva[Geneva.length] = createMarker(new GPoint(-84.87917600,40.61523700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Southeast Amish School",'Geneva=' + Geneva.length);
Decatur[Decatur.length] = createMarker(new GPoint(-84.92669800,40.83009900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Joseph School",'Decatur=' + Decatur.length);
Berne[Berne.length] = createMarker(new GPoint(-84.93418200,40.64376900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sunnyside Amish School",'Berne=' + Berne.length);
Monroe[Monroe.length] = createMarker(new GPoint(-84.93689100,40.73697700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Swiss Valley",'Monroe=' + Monroe.length);
Geneva[Geneva.length] = createMarker(new GPoint(-84.95243900,40.62153000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wabash Valley",'Geneva=' + Geneva.length);
Geneva[Geneva.length] = createMarker(new GPoint(-84.99022800,40.62043300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West Wabash School",'Geneva=' + Geneva.length);
Monroe[Monroe.length] = createMarker(new GPoint(-84.92660000,40.72840000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Winchester Amish School C/o Girod",'Monroe=' + Monroe.length);
Decatur[Decatur.length] = createMarker(new GPoint(-85.00807100,40.91334500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wyneken Memorial Lutheran School",'Decatur=' + Decatur.length);
Decatur[Decatur.length] = createMarker(new GPoint(-84.93410300,40.82997300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Zion Lutheran School",'Decatur=' + Decatur.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(Berne);
map.removeOverlays(Decatur);
map.removeOverlays(Geneva);
map.removeOverlays(Monroe);
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(Berne);map.removeOverlays(Berne);
map.removeOverlays(Decatur);
map.removeOverlays(Geneva);
map.removeOverlays(Monroe);
map.addOverlays(Berne);
centerByArray(Berne, false, false);
cntMarker += Berne.length;
map.addOverlays(Decatur);
centerByArray(Decatur, false, false);
cntMarker += Decatur.length;
map.addOverlays(Geneva);
centerByArray(Geneva, false, false);
cntMarker += Geneva.length;
map.addOverlays(Monroe);
centerByArray(Monroe, false, false);
cntMarker += Monroe.length;
centerByArray(Berne,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;
}