function addMarkers()
{
mySelect = document.getElementById('selection');
South_Bend = [];Mishawaka = [];Granger = [];Walkerton = [];Lakeville = [];Wakarusa = [];Osceola = [];North_Liberty = [];New_Carlisle = [];mySelect.options[mySelect.options.length] = new Option("Granger schools",'all=Granger');
mySelect.options[mySelect.options.length] = new Option("Lakeville schools",'all=Lakeville');
mySelect.options[mySelect.options.length] = new Option("Mishawaka schools",'all=Mishawaka');
mySelect.options[mySelect.options.length] = new Option("New Carlisle schools",'all=New_Carlisle');
mySelect.options[mySelect.options.length] = new Option("North Liberty schools",'all=North_Liberty');
mySelect.options[mySelect.options.length] = new Option("Osceola schools",'all=Osceola');
mySelect.options[mySelect.options.length] = new Option("South Bend schools",'all=South_Bend');
mySelect.options[mySelect.options.length] = new Option("Wakarusa schools",'all=Wakarusa');
mySelect.options[mySelect.options.length] = new Option("Walkerton schools",'all=Walkerton');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.22541809,41.66732788),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Adams High School",'South_Bend=' + South_Bend.length);
Mishawaka[Mishawaka.length] = createMarker(new GPoint(-86.17279053,41.66976166),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Battell Elementary School",'Mishawaka=' + Mishawaka.length);
Mishawaka[Mishawaka.length] = createMarker(new GPoint(-86.15266418,41.66259003),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Beiger Elementary School",'Mishawaka=' + Mishawaka.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.27246094,41.70629883),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bendix Building Adult Education High School",'South_Bend=' + South_Bend.length);
Mishawaka[Mishawaka.length] = createMarker(new GPoint(-86.10951233,41.68223572),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bittersweet Elementary School",'Mishawaka=' + Mishawaka.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.26046753,41.70003510),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Brown Intermediate Center",'South_Bend=' + South_Bend.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.23816681,41.73043823),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Clay High School",'South_Bend=' + South_Bend.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.24544525,41.72451401),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Clay Intermediate Center",'South_Bend=' + South_Bend.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.30297852,41.69105911),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Coquillard Primary Center",'South_Bend=' + South_Bend.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.27246094,41.70629883),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Council Oak Jr-sr High School",'South_Bend=' + South_Bend.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.23030853,41.72783661),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Darden Primary Center",'South_Bend=' + South_Bend.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.30770111,41.69346237),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Dickinson Intermediate Center",'South_Bend=' + South_Bend.length);
Granger[Granger.length] = createMarker(new GPoint(-86.06348419,41.73487473),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Discovery Middle School",'Granger=' + Granger.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.20980835,41.68863678),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Edison Intermediate Center",'South_Bend=' + South_Bend.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.20977020,41.68863678),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Edison Snap Elementary School",'South_Bend=' + South_Bend.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.23975372,41.75188446),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eggleston Center",'South_Bend=' + South_Bend.length);
Mishawaka[Mishawaka.length] = createMarker(new GPoint(-86.15856934,41.66220093),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Elm Road Elementary School",'Mishawaka=' + Mishawaka.length);
Mishawaka[Mishawaka.length] = createMarker(new GPoint(-86.12918091,41.67837143),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Elsie Rogers Elementary School",'Mishawaka=' + Mishawaka.length);
Mishawaka[Mishawaka.length] = createMarker(new GPoint(-86.18031311,41.64971542),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Emmons Elementary School",'Mishawaka=' + Mishawaka.length);
Mishawaka[Mishawaka.length] = createMarker(new GPoint(-86.12725067,41.65166092),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fred J Hums Elementary School",'Mishawaka=' + Mishawaka.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.34468079,41.59276199),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Greene Intermediate Center",'South_Bend=' + South_Bend.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.22739410,41.62206268),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hamilton Primary Center",'South_Bend=' + South_Bend.length);
Walkerton[Walkerton.length] = createMarker(new GPoint(-86.48841858,41.46901321),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Harold C Urey Middle School",'Walkerton=' + Walkerton.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.29498291,41.67184830),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Harrison Primary Center",'South_Bend=' + South_Bend.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.24758911,41.61683655),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hay Primary Center",'South_Bend=' + South_Bend.length);
Granger[Granger.length] = createMarker(new GPoint(-86.06366730,41.73490524),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Horizon Elementary School",'Granger=' + Granger.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.23498535,41.62404251),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Jackson Intermediate Center",'South_Bend=' + South_Bend.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.23480225,41.67119980),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Jefferson Intermediate Center",'South_Bend=' + South_Bend.length);
Walkerton[Walkerton.length] = createMarker(new GPoint(-86.48276400,41.46652500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("John Glenn High School",'Walkerton=' + Walkerton.length);
Mishawaka[Mishawaka.length] = createMarker(new GPoint(-86.18157959,41.67644501),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("John J Young Middle School",'Mishawaka=' + Mishawaka.length);
Mishawaka[Mishawaka.length] = createMarker(new GPoint(-86.15856934,41.66220093),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Joint Service Campus Program",'Mishawaka=' + Mishawaka.length);
Mishawaka[Mishawaka.length] = createMarker(new GPoint(-86.18031311,41.64897919),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Joint Service Program",'Mishawaka=' + Mishawaka.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.24991608,41.66336441),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Juvenile Justice Center",'South_Bend=' + South_Bend.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.28378296,41.68269730),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kennedy Primary Center",'South_Bend=' + South_Bend.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.31268311,41.67839050),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lafayette Early Childhood Center",'South_Bend=' + South_Bend.length);
Mishawaka[Mishawaka.length] = createMarker(new GPoint(-86.19896698,41.65526199),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lasalle Elementary School",'Mishawaka=' + Mishawaka.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.28759003,41.69393539),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Lasalle Intermediate Center",'South_Bend=' + South_Bend.length);
Lakeville[Lakeville.length] = createMarker(new GPoint(-86.27213287,41.52452087),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Laville Junior Senior High School",'Lakeville=' + Lakeville.length);
Mishawaka[Mishawaka.length] = createMarker(new GPoint(-86.17547607,41.68193817),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Liberty Elementary School",'Mishawaka=' + Mishawaka.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.22671509,41.65503693),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lincoln Primary Center",'South_Bend=' + South_Bend.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.24472809,41.68332291),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Madison Center",'South_Bend=' + South_Bend.length);
Wakarusa[Wakarusa.length] = createMarker(new GPoint(-86.03600311,41.53670120),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Madison Elementary School",'Wakarusa=' + Wakarusa.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.25356293,41.68540573),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Madison Primary Center",'South_Bend=' + South_Bend.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.27689362,41.70170975),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Marquette Primary Center",'South_Bend=' + South_Bend.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.22563934,41.63533783),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Marshall Intermediate Center",'South_Bend=' + South_Bend.length);
Granger[Granger.length] = createMarker(new GPoint(-86.12133026,41.75373840),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mary Frank/harris Elementary School",'Granger=' + Granger.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.22071838,41.67842865),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mckinley Primary Center",'South_Bend=' + South_Bend.length);
Mishawaka[Mishawaka.length] = createMarker(new GPoint(-86.17990112,41.60793686),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Meadow's Edge Elementary School",'Mishawaka=' + Mishawaka.length);
Mishawaka[Mishawaka.length] = createMarker(new GPoint(-86.16153717,41.66197968),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mishawaka High School",'Mishawaka=' + Mishawaka.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.24571991,41.64337921),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Monroe Primary Center",'South_Bend=' + South_Bend.length);
Osceola[Osceola.length] = createMarker(new GPoint(-86.08053589,41.66571426),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Moran Elementary School",'Osceola=' + Osceola.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.26760864,41.68821335),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Muessel Primary Center",'South_Bend=' + South_Bend.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.31266022,41.66926193),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Navarre Intermediate Center",'South_Bend=' + South_Bend.length);
North_Liberty[North_Liberty.length] = createMarker(new GPoint(-86.42430115,41.53882599),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("North Liberty School",'North_Liberty=' + North_Liberty.length);
Granger[Granger.length] = createMarker(new GPoint(-86.12500763,41.75643158),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Northpoint Elementary School",'Granger=' + Granger.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.20851898,41.66236115),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Nuner Primary Center",'South_Bend=' + South_Bend.length);
New_Carlisle[New_Carlisle.length] = createMarker(new GPoint(-86.51249695,41.70293427),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Olive Township Elementary School",'New_Carlisle=' + New_Carlisle.length);
Mishawaka[Mishawaka.length] = createMarker(new GPoint(-86.10941315,41.67894363),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Penn High School",'Mishawaka=' + Mishawaka.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.23514557,41.68543625),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Perley Primary Center",'South_Bend=' + South_Bend.length);
Granger[Granger.length] = createMarker(new GPoint(-86.16593933,41.73852539),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Prairie Vista Elementary School",'Granger=' + Granger.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.24982900,41.65520000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Riley High School",'South_Bend=' + South_Bend.length);
Mishawaka[Mishawaka.length] = createMarker(new GPoint(-86.10978699,41.67988968),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Schmucker Middle School",'Mishawaka=' + Mishawaka.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-87.78449300,35.76348000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Bend Snap",'South_Bend=' + South_Bend.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.24049377,41.65686417),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Studebaker Primary Center",'South_Bend=' + South_Bend.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.20970917,41.72481155),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Swanson Primary Center",'South_Bend=' + South_Bend.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.20050812,41.70186234),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Tarkington Traditional Center",'South_Bend=' + South_Bend.length);
Mishawaka[Mishawaka.length] = createMarker(new GPoint(-86.11989594,41.66333771),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Twin Branch Elementary School",'Mishawaka=' + Mishawaka.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.27246094,41.70629883),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Veritas Academy",'South_Bend=' + South_Bend.length);
Mishawaka[Mishawaka.length] = createMarker(new GPoint(-86.13556671,41.60805130),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Virgil I Grissom Middle School",'Mishawaka=' + Mishawaka.length);
Walkerton[Walkerton.length] = createMarker(new GPoint(-86.48851013,41.46252060),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Walkerton Elementary School",'Walkerton=' + Walkerton.length);
Mishawaka[Mishawaka.length] = createMarker(new GPoint(-86.16819763,41.69599533),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Walt Disney Elementary School",'Mishawaka=' + Mishawaka.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.38011169,41.68834686),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Warren Elementary School",'South_Bend=' + South_Bend.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.27246094,41.70629883),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Warren Primary Center",'South_Bend=' + South_Bend.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.28331757,41.67697906),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Washington High School",'South_Bend=' + South_Bend.length);
South_Bend[South_Bend.length] = createMarker(new GPoint(-86.33158875,41.67027283),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wilson Primary Center",'South_Bend=' + South_Bend.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(Granger);
map.removeOverlays(Lakeville);
map.removeOverlays(Mishawaka);
map.removeOverlays(New_Carlisle);
map.removeOverlays(North_Liberty);
map.removeOverlays(Osceola);
map.removeOverlays(South_Bend);
map.removeOverlays(Wakarusa);
map.removeOverlays(Walkerton);
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(South_Bend);map.removeOverlays(Granger);
map.removeOverlays(Lakeville);
map.removeOverlays(Mishawaka);
map.removeOverlays(New_Carlisle);
map.removeOverlays(North_Liberty);
map.removeOverlays(Osceola);
map.removeOverlays(South_Bend);
map.removeOverlays(Wakarusa);
map.removeOverlays(Walkerton);
map.addOverlays(Granger);
centerByArray(Granger, false, false);
cntMarker += Granger.length;
map.addOverlays(Lakeville);
centerByArray(Lakeville, false, false);
cntMarker += Lakeville.length;
map.addOverlays(Mishawaka);
centerByArray(Mishawaka, false, false);
cntMarker += Mishawaka.length;
map.addOverlays(New_Carlisle);
centerByArray(New_Carlisle, false, false);
cntMarker += New_Carlisle.length;
map.addOverlays(North_Liberty);
centerByArray(North_Liberty, false, false);
cntMarker += North_Liberty.length;
map.addOverlays(Osceola);
centerByArray(Osceola, false, false);
cntMarker += Osceola.length;
map.addOverlays(South_Bend);
centerByArray(South_Bend, false, false);
cntMarker += South_Bend.length;
map.addOverlays(Wakarusa);
centerByArray(Wakarusa, false, false);
cntMarker += Wakarusa.length;
map.addOverlays(Walkerton);
centerByArray(Walkerton, false, false);
cntMarker += Walkerton.length;
centerByArray(South_Bend,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');
}
}