function addMarkers()
{
mySelect = document.getElementById('selection');
Beaver_Island = [];Charlevoix = [];Boyne_Falls = [];Boyne_City = [];East_Jordan = [];mySelect.options[mySelect.options.length] = new Option("Beaver Island schools",'all=Beaver_Island');
mySelect.options[mySelect.options.length] = new Option("Boyne City schools",'all=Boyne_City');
mySelect.options[mySelect.options.length] = new Option("Boyne Falls schools",'all=Boyne_Falls');
mySelect.options[mySelect.options.length] = new Option("Charlevoix schools",'all=Charlevoix');
mySelect.options[mySelect.options.length] = new Option("East Jordan schools",'all=East_Jordan');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Beaver_Island[Beaver_Island.length] = createMarker(new GPoint(-85.53919983,45.71459961),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Beaver Island Community School",'Beaver_Island=' + Beaver_Island.length);
Charlevoix[Charlevoix.length] = createMarker(new GPoint(-85.26095581,45.31708908),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Beaver Island Lighthouse Program",'Charlevoix=' + Charlevoix.length);
Boyne_Falls[Boyne_Falls.length] = createMarker(new GPoint(-84.91318512,45.17041397),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Boyne City Alt. Ed. Boyne Valley Campus",'Boyne_Falls=' + Boyne_Falls.length);
Boyne_City[Boyne_City.length] = createMarker(new GPoint(-85.01689911,45.22579956),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Boyne City Elementary School",'Boyne_City=' + Boyne_City.length);
Boyne_City[Boyne_City.length] = createMarker(new GPoint(-85.01689911,45.22579956),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Boyne City High School",'Boyne_City=' + Boyne_City.length);
Boyne_City[Boyne_City.length] = createMarker(new GPoint(-85.01689911,45.22579956),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Boyne City Middle School",'Boyne_City=' + Boyne_City.length);
Boyne_Falls[Boyne_Falls.length] = createMarker(new GPoint(-84.84860229,45.21289825),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Boyne Falls Public School",'Boyne_Falls=' + Boyne_Falls.length);
Boyne_Falls[Boyne_Falls.length] = createMarker(new GPoint(-84.84860229,45.21289825),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Boyne Falls School",'Boyne_Falls=' + Boyne_Falls.length);
Charlevoix[Charlevoix.length] = createMarker(new GPoint(-85.24030304,45.32976151),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Char-em Programs",'Charlevoix=' + Charlevoix.length);
Charlevoix[Charlevoix.length] = createMarker(new GPoint(-85.24625397,45.32564926),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Charlevoix Elementary School",'Charlevoix=' + Charlevoix.length);
Charlevoix[Charlevoix.length] = createMarker(new GPoint(-85.26993561,45.28279495),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Charlevoix High School",'Charlevoix=' + Charlevoix.length);
Charlevoix[Charlevoix.length] = createMarker(new GPoint(-85.25843811,45.31160355),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Charlevoix Middle School",'Charlevoix=' + Charlevoix.length);
Boyne_City[Boyne_City.length] = createMarker(new GPoint(-84.97135925,45.19040298),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Concord Academy:boyne",'Boyne_City=' + Boyne_City.length);
East_Jordan[East_Jordan.length] = createMarker(new GPoint(-85.12049866,45.15950012),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("East Jordan Elementary School",'East_Jordan=' + East_Jordan.length);
East_Jordan[East_Jordan.length] = createMarker(new GPoint(-85.12049866,45.15950012),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("East Jordan High School",'East_Jordan=' + East_Jordan.length);
East_Jordan[East_Jordan.length] = createMarker(new GPoint(-85.12049866,45.15950012),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("East Jordan Middle School",'East_Jordan=' + East_Jordan.length);
Boyne_Falls[Boyne_Falls.length] = createMarker(new GPoint(-84.91318512,45.17041397),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Great Lakes Academic Center",'Boyne_Falls=' + Boyne_Falls.length);
Charlevoix[Charlevoix.length] = createMarker(new GPoint(-85.25912476,45.31403732),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northwest Academy",'Charlevoix=' + Charlevoix.length);
Boyne_Falls[Boyne_Falls.length] = createMarker(new GPoint(-84.91318512,45.17041397),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Porter Creek School",'Boyne_Falls=' + Boyne_Falls.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,10);
/*
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////' + showArray);
map.removeOverlays(Beaver_Island);
map.removeOverlays(Boyne_City);
map.removeOverlays(Boyne_Falls);
map.removeOverlays(Charlevoix);
map.removeOverlays(East_Jordan);
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(Beaver_Island);map.removeOverlays(Beaver_Island);
map.removeOverlays(Boyne_City);
map.removeOverlays(Boyne_Falls);
map.removeOverlays(Charlevoix);
map.removeOverlays(East_Jordan);
map.addOverlays(Beaver_Island);
centerByArray(Beaver_Island, false, false);
cntMarker += Beaver_Island.length;
map.addOverlays(Boyne_City);
centerByArray(Boyne_City, false, false);
cntMarker += Boyne_City.length;
map.addOverlays(Boyne_Falls);
centerByArray(Boyne_Falls, false, false);
cntMarker += Boyne_Falls.length;
map.addOverlays(Charlevoix);
centerByArray(Charlevoix, false, false);
cntMarker += Charlevoix.length;
map.addOverlays(East_Jordan);
centerByArray(East_Jordan, false, false);
cntMarker += East_Jordan.length;
centerByArray(Beaver_Island,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');
}
}