function addMarkers(){
mySelect = document.getElementById('selection');
Saginaw = [];Bridgeport = [];Oakley = [];Chesaning = [];Frankenmuth = [];Hemlock = [];Reese = [];mySelect.options[mySelect.options.length] = new Option("Bridgeport schools",'all=Bridgeport');
mySelect.options[mySelect.options.length] = new Option("Chesaning schools",'all=Chesaning');
mySelect.options[mySelect.options.length] = new Option("Frankenmuth schools",'all=Frankenmuth');
mySelect.options[mySelect.options.length] = new Option("Hemlock schools",'all=Hemlock');
mySelect.options[mySelect.options.length] = new Option("Oakley schools",'all=Oakley');
mySelect.options[mySelect.options.length] = new Option("Reese schools",'all=Reese');
mySelect.options[mySelect.options.length] = new Option("Saginaw schools",'all=Saginaw');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Saginaw[Saginaw.length] = createMarker(new GPoint(-84.01720600,43.46546300),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethany Lutheran School",'Saginaw=' + Saginaw.length);
Saginaw[Saginaw.length] = createMarker(new GPoint(-84.00880500,43.42731800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethany St John's Lutheran School",'Saginaw=' + Saginaw.length);
Saginaw[Saginaw.length] = createMarker(new GPoint(-83.95248800,43.44515700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethlehem Lutheran School",'Saginaw=' + Saginaw.length);
Bridgeport[Bridgeport.length] = createMarker(new GPoint(-83.85930000,43.35020000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bridgeport Baptist Academy",'Bridgeport=' + Bridgeport.length);
Oakley[Oakley.length] = createMarker(new GPoint(-84.22931800,43.18693700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christ Lutheran School",'Oakley=' + Oakley.length);
Saginaw[Saginaw.length] = createMarker(new GPoint(-84.07672200,43.41586300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Community Baptist Christian School",'Saginaw=' + Saginaw.length);
Saginaw[Saginaw.length] = createMarker(new GPoint(-83.98380000,43.44516300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gethsemane Lutheran School",'Saginaw=' + Saginaw.length);
Saginaw[Saginaw.length] = createMarker(new GPoint(-84.02174200,43.43215200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Good Shepherd Early Childhood",'Saginaw=' + Saginaw.length);
Saginaw[Saginaw.length] = createMarker(new GPoint(-83.99543300,43.45516500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grace Christian School",'Saginaw=' + Saginaw.length);
Saginaw[Saginaw.length] = createMarker(new GPoint(-84.02941000,43.43924400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Growing Years Christian School",'Saginaw=' + Saginaw.length);
Saginaw[Saginaw.length] = createMarker(new GPoint(-83.96524800,43.41843600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Cross Lutheran School",'Saginaw=' + Saginaw.length);
Saginaw[Saginaw.length] = createMarker(new GPoint(-83.79054300,43.40697700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Immanuel Lutheran School",'Saginaw=' + Saginaw.length);
Chesaning[Chesaning.length] = createMarker(new GPoint(-84.12309500,43.18175400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of Perpetual Help School",'Chesaning=' + Chesaning.length);
Saginaw[Saginaw.length] = createMarker(new GPoint(-84.03452000,43.45440200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Peace Lutheran School",'Saginaw=' + Saginaw.length);
Saginaw[Saginaw.length] = createMarker(new GPoint(-84.00993100,43.40069000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("S S Peter And Paul School",'Saginaw=' + Saginaw.length);
Saginaw[Saginaw.length] = createMarker(new GPoint(-83.94581000,43.45076300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Josaphat Elementary School",'Saginaw=' + Saginaw.length);
Frankenmuth[Frankenmuth.length] = createMarker(new GPoint(-83.74858800,43.33661300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Lorenz Lutheran",'Frankenmuth=' + Frankenmuth.length);
Hemlock[Hemlock.length] = createMarker(new GPoint(-84.21016100,43.44223300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Peter Lutheran School",'Hemlock=' + Hemlock.length);
Saginaw[Saginaw.length] = createMarker(new GPoint(-84.02131000,43.43846500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Thomas Aquinas Elementary School",'Saginaw=' + Saginaw.length);
Saginaw[Saginaw.length] = createMarker(new GPoint(-83.93357300,43.32355200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sheridan Road Baptist School",'Saginaw=' + Saginaw.length);
Reese[Reese.length] = createMarker(new GPoint(-83.69800000,43.45810000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Elizabeth Area Catholic School",'Reese=' + Reese.length);
Saginaw[Saginaw.length] = createMarker(new GPoint(-83.96818800,43.44078600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Helen Elementary School",'Saginaw=' + Saginaw.length);
Hemlock[Hemlock.length] = createMarker(new GPoint(-84.20065900,43.38931100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Johns Lutheran School",'Hemlock=' + Hemlock.length);
Saginaw[Saginaw.length] = createMarker(new GPoint(-83.97618300,43.43556300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Pauls Lutheran School",'Saginaw=' + Saginaw.length);
Saginaw[Saginaw.length] = createMarker(new GPoint(-83.98869700,43.42633400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Stephen Catholic School",'Saginaw=' + Saginaw.length);
Saginaw[Saginaw.length] = createMarker(new GPoint(-83.99050000,43.49394200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tri-City SDA School",'Saginaw=' + Saginaw.length);
Hemlock[Hemlock.length] = createMarker(new GPoint(-84.26763100,43.46336700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Zion Lutheran School",'Hemlock=' + Hemlock.length);
Chesaning[Chesaning.length] = createMarker(new GPoint(-84.10732600,43.18606300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Zion Lutheran School",'Chesaning=' + Chesaning.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(Bridgeport);
map.removeOverlays(Chesaning);
map.removeOverlays(Frankenmuth);
map.removeOverlays(Hemlock);
map.removeOverlays(Oakley);
map.removeOverlays(Reese);
map.removeOverlays(Saginaw);
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(Saginaw);map.removeOverlays(Bridgeport);
map.removeOverlays(Chesaning);
map.removeOverlays(Frankenmuth);
map.removeOverlays(Hemlock);
map.removeOverlays(Oakley);
map.removeOverlays(Reese);
map.removeOverlays(Saginaw);
map.addOverlays(Bridgeport);
centerByArray(Bridgeport, false, false);
cntMarker += Bridgeport.length;
map.addOverlays(Chesaning);
centerByArray(Chesaning, false, false);
cntMarker += Chesaning.length;
map.addOverlays(Frankenmuth);
centerByArray(Frankenmuth, false, false);
cntMarker += Frankenmuth.length;
map.addOverlays(Hemlock);
centerByArray(Hemlock, false, false);
cntMarker += Hemlock.length;
map.addOverlays(Oakley);
centerByArray(Oakley, false, false);
cntMarker += Oakley.length;
map.addOverlays(Reese);
centerByArray(Reese, false, false);
cntMarker += Reese.length;
map.addOverlays(Saginaw);
centerByArray(Saginaw, false, false);
cntMarker += Saginaw.length;
centerByArray(Saginaw,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;
}