function addMarkers()
{
mySelect = document.getElementById('selection');
Three_Rivers = [];Sturgis = [];Burr_Oak = [];White_Pigeon = [];Centreville = [];Colon = [];Constantine = [];Leonidas = [];Mendon = [];mySelect.options[mySelect.options.length] = new Option("Burr Oak schools",'all=Burr_Oak');
mySelect.options[mySelect.options.length] = new Option("Centreville schools",'all=Centreville');
mySelect.options[mySelect.options.length] = new Option("Colon schools",'all=Colon');
mySelect.options[mySelect.options.length] = new Option("Constantine schools",'all=Constantine');
mySelect.options[mySelect.options.length] = new Option("Leonidas schools",'all=Leonidas');
mySelect.options[mySelect.options.length] = new Option("Mendon schools",'all=Mendon');
mySelect.options[mySelect.options.length] = new Option("Sturgis schools",'all=Sturgis');
mySelect.options[mySelect.options.length] = new Option("Three Rivers schools",'all=Three_Rivers');
mySelect.options[mySelect.options.length] = new Option("White Pigeon schools",'all=White_Pigeon');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Three_Rivers[Three_Rivers.length] = createMarker(new GPoint(-85.64290619,41.94116974),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Andrews Elementary School",'Three_Rivers=' + Three_Rivers.length);
Sturgis[Sturgis.length] = createMarker(new GPoint(-85.40753174,41.80091095),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Arden Park School",'Sturgis=' + Sturgis.length);
Three_Rivers[Three_Rivers.length] = createMarker(new GPoint(-85.62288666,41.94583893),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Barrows School",'Three_Rivers=' + Three_Rivers.length);
Burr_Oak[Burr_Oak.length] = createMarker(new GPoint(-85.32679749,41.85169983),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Burr Oak Elementary School",'Burr_Oak=' + Burr_Oak.length);
Burr_Oak[Burr_Oak.length] = createMarker(new GPoint(-85.32679749,41.85169983),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Burr Oak High School",'Burr_Oak=' + Burr_Oak.length);
White_Pigeon[White_Pigeon.length] = createMarker(new GPoint(-85.67030334,41.79520035),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'White_Pigeon=' + White_Pigeon.length);
Centreville[Centreville.length] = createMarker(new GPoint(-85.51550293,41.92110062),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Centreville Elementary School",'Centreville=' + Centreville.length);
Centreville[Centreville.length] = createMarker(new GPoint(-85.51550293,41.92110062),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Centreville High School",'Centreville=' + Centreville.length);
Centreville[Centreville.length] = createMarker(new GPoint(-85.51550293,41.92110062),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Centreville Middle School",'Centreville=' + Centreville.length);
Colon[Colon.length] = createMarker(new GPoint(-85.32209778,41.95814514),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Colon Elementary School",'Colon=' + Colon.length);
Colon[Colon.length] = createMarker(new GPoint(-85.31708527,41.95969009),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Colon High School",'Colon=' + Colon.length);
Sturgis[Sturgis.length] = createMarker(new GPoint(-85.41208649,41.79666138),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Congress School",'Sturgis=' + Sturgis.length);
Constantine[Constantine.length] = createMarker(new GPoint(-85.66769409,41.83630753),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Constantine High School",'Constantine=' + Constantine.length);
Constantine[Constantine.length] = createMarker(new GPoint(-85.66605377,41.83549500),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Constantine Middle School",'Constantine=' + Constantine.length);
Centreville[Centreville.length] = createMarker(new GPoint(-85.51550293,41.92110062),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Covered Bridge School",'Centreville=' + Centreville.length);
Constantine[Constantine.length] = createMarker(new GPoint(-85.66282654,41.83333588),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Eastside Elementary School",'Constantine=' + Constantine.length);
Sturgis[Sturgis.length] = createMarker(new GPoint(-85.39861298,41.80163956),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Eastwood School",'Sturgis=' + Sturgis.length);
Sturgis[Sturgis.length] = createMarker(new GPoint(-85.35037994,41.79169083),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fawn River School",'Sturgis=' + Sturgis.length);
Centreville[Centreville.length] = createMarker(new GPoint(-85.50694200,41.89464200),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Great Start Program",'Centreville=' + Centreville.length);
Three_Rivers[Three_Rivers.length] = createMarker(new GPoint(-85.62459564,41.93300629),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Huss School-alternative Academy",'Three_Rivers=' + Three_Rivers.length);
Sturgis[Sturgis.length] = createMarker(new GPoint(-85.41608429,41.80856323),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jerolene School",'Sturgis=' + Sturgis.length);
Three_Rivers[Three_Rivers.length] = createMarker(new GPoint(-85.66520691,41.93956375),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Johnnycake School",'Three_Rivers=' + Three_Rivers.length);
Leonidas[Leonidas.length] = createMarker(new GPoint(-85.23039246,42.08742523),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Leonidas Child Development C Elementary School",'Leonidas=' + Leonidas.length);
Leonidas[Leonidas.length] = createMarker(new GPoint(-85.35227966,42.02109909),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Leonidas Child Development Center",'Leonidas=' + Leonidas.length);
White_Pigeon[White_Pigeon.length] = createMarker(new GPoint(-85.67030334,41.79520035),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Little Chief's Village School",'White_Pigeon=' + White_Pigeon.length);
Mendon[Mendon.length] = createMarker(new GPoint(-85.45252991,42.01123810),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mendon Elementary School",'Mendon=' + Mendon.length);
Mendon[Mendon.length] = createMarker(new GPoint(-85.44950104,42.01369858),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mendon Middle/high School",'Mendon=' + Mendon.length);
Three_Rivers[Three_Rivers.length] = createMarker(new GPoint(-85.63220215,41.94350815),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Norton Elementary School",'Three_Rivers=' + Three_Rivers.length);
Sturgis[Sturgis.length] = createMarker(new GPoint(-85.44013977,41.91923523),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Nottawa Community School",'Sturgis=' + Sturgis.length);
Three_Rivers[Three_Rivers.length] = createMarker(new GPoint(-85.63583374,42.01776123),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Park Community School",'Three_Rivers=' + Three_Rivers.length);
Sturgis[Sturgis.length] = createMarker(new GPoint(-85.42620850,41.79933548),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Park School",'Sturgis=' + Sturgis.length);
Centreville[Centreville.length] = createMarker(new GPoint(-85.51550293,41.92110062),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pathfinder Center",'Centreville=' + Centreville.length);
Constantine[Constantine.length] = createMarker(new GPoint(-85.67264557,41.83433914),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Riverside Elementary School",'Constantine=' + Constantine.length);
Three_Rivers[Three_Rivers.length] = createMarker(new GPoint(-85.63451385,41.95019531),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ruth Hoppin School",'Three_Rivers=' + Three_Rivers.length);
Sturgis[Sturgis.length] = createMarker(new GPoint(-85.41869400,41.80025000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sturgis High School",'Sturgis=' + Sturgis.length);
Sturgis[Sturgis.length] = createMarker(new GPoint(-85.41896820,41.80106354),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Sturgis Middle School",'Sturgis=' + Sturgis.length);
Three_Rivers[Three_Rivers.length] = createMarker(new GPoint(-85.63640000,41.94266700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Three Rivers High School",'Three_Rivers=' + Three_Rivers.length);
Three_Rivers[Three_Rivers.length] = createMarker(new GPoint(-85.61933136,41.95344162),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Three Rivers Middle School",'Three_Rivers=' + Three_Rivers.length);
Sturgis[Sturgis.length] = createMarker(new GPoint(-85.41120148,41.81063843),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wall School",'Sturgis=' + Sturgis.length);
Sturgis[Sturgis.length] = createMarker(new GPoint(-85.42618561,41.79484558),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wenzel School",'Sturgis=' + Sturgis.length);
White_Pigeon[White_Pigeon.length] = createMarker(new GPoint(-85.67030334,41.79520035),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("White Pigeon Jr/sr High School",'White_Pigeon=' + White_Pigeon.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(Burr_Oak);
map.removeOverlays(Centreville);
map.removeOverlays(Colon);
map.removeOverlays(Constantine);
map.removeOverlays(Leonidas);
map.removeOverlays(Mendon);
map.removeOverlays(Sturgis);
map.removeOverlays(Three_Rivers);
map.removeOverlays(White_Pigeon);
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(Three_Rivers);map.removeOverlays(Burr_Oak);
map.removeOverlays(Centreville);
map.removeOverlays(Colon);
map.removeOverlays(Constantine);
map.removeOverlays(Leonidas);
map.removeOverlays(Mendon);
map.removeOverlays(Sturgis);
map.removeOverlays(Three_Rivers);
map.removeOverlays(White_Pigeon);
map.addOverlays(Burr_Oak);
centerByArray(Burr_Oak, false, false);
cntMarker += Burr_Oak.length;
map.addOverlays(Centreville);
centerByArray(Centreville, false, false);
cntMarker += Centreville.length;
map.addOverlays(Colon);
centerByArray(Colon, false, false);
cntMarker += Colon.length;
map.addOverlays(Constantine);
centerByArray(Constantine, false, false);
cntMarker += Constantine.length;
map.addOverlays(Leonidas);
centerByArray(Leonidas, false, false);
cntMarker += Leonidas.length;
map.addOverlays(Mendon);
centerByArray(Mendon, false, false);
cntMarker += Mendon.length;
map.addOverlays(Sturgis);
centerByArray(Sturgis, false, false);
cntMarker += Sturgis.length;
map.addOverlays(Three_Rivers);
centerByArray(Three_Rivers, false, false);
cntMarker += Three_Rivers.length;
map.addOverlays(White_Pigeon);
centerByArray(White_Pigeon, false, false);
cntMarker += White_Pigeon.length;
centerByArray(Three_Rivers,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');
}
}