function addMarkers()
{
mySelect = document.getElementById('selection');
Michigan_City = [];Laporte = [];Kingsford_Heights = [];Lacrosse = [];New_Carlisle = [];Rolling_Prairie = [];Union_Mills = [];Wanatah = [];Westville = [];mySelect.options[mySelect.options.length] = new Option("Kingsford Heights schools",'all=Kingsford_Heights');
mySelect.options[mySelect.options.length] = new Option("Lacrosse schools",'all=Lacrosse');
mySelect.options[mySelect.options.length] = new Option("Laporte schools",'all=Laporte');
mySelect.options[mySelect.options.length] = new Option("Michigan City schools",'all=Michigan_City');
mySelect.options[mySelect.options.length] = new Option("New Carlisle schools",'all=New_Carlisle');
mySelect.options[mySelect.options.length] = new Option("Rolling Prairie schools",'all=Rolling_Prairie');
mySelect.options[mySelect.options.length] = new Option("Union Mills schools",'all=Union_Mills');
mySelect.options[mySelect.options.length] = new Option("Wanatah schools",'all=Wanatah');
mySelect.options[mySelect.options.length] = new Option("Westville schools",'all=Westville');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Michigan_City[Michigan_City.length] = createMarker(new GPoint(-86.90492249,41.69696045),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("A K Smith Area Career Center",'Michigan_City=' + Michigan_City.length);
Michigan_City[Michigan_City.length] = createMarker(new GPoint(-86.88725281,41.68736267),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Barker Middle School",'Michigan_City=' + Michigan_City.length);
Laporte[Laporte.length] = createMarker(new GPoint(-86.71003723,41.59725952),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Camp Summit",'Laporte=' + Laporte.length);
Michigan_City[Michigan_City.length] = createMarker(new GPoint(-86.87668610,41.65140533),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Coolspring Elementary School",'Michigan_City=' + Michigan_City.length);
Michigan_City[Michigan_City.length] = createMarker(new GPoint(-86.88568115,41.69145584),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Edgewood Elementary School",'Michigan_City=' + Michigan_City.length);
Laporte[Laporte.length] = createMarker(new GPoint(-86.76289368,41.64226151),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("F Willard Crichfield Elementary School",'Laporte=' + Laporte.length);
Laporte[Laporte.length] = createMarker(new GPoint(-86.70199585,41.61023712),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hailmann Elementary School",'Laporte=' + Laporte.length);
Laporte[Laporte.length] = createMarker(new GPoint(-86.72332001,41.59844208),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Handley Elementary School",'Laporte=' + Laporte.length);
Laporte[Laporte.length] = createMarker(new GPoint(-86.72280121,41.60729980),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Indian Trail Elementary School",'Laporte=' + Laporte.length);
Michigan_City[Michigan_City.length] = createMarker(new GPoint(-86.87341309,41.69483566),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Joy Elementary School",'Michigan_City=' + Michigan_City.length);
Laporte[Laporte.length] = createMarker(new GPoint(-86.71701050,41.59126282),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Kesling Middle School",'Laporte=' + Laporte.length);
Laporte[Laporte.length] = createMarker(new GPoint(-86.71628571,41.54688263),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kingsbury Elementary School",'Laporte=' + Laporte.length);
Kingsford_Heights[Kingsford_Heights.length] = createMarker(new GPoint(-86.69635773,41.48203659),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kingsford Heights Elementary School",'Kingsford_Heights=' + Kingsford_Heights.length);
Michigan_City[Michigan_City.length] = createMarker(new GPoint(-86.90615845,41.69621277),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Knapp Elementary School",'Michigan_City=' + Michigan_City.length);
Lacrosse[Lacrosse.length] = createMarker(new GPoint(-86.89019775,41.31875992),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("La Crosse Elementary & High School",'Lacrosse=' + Lacrosse.length);
Lacrosse[Lacrosse.length] = createMarker(new GPoint(-86.89019775,41.31875992),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("La Crosse High School",'Lacrosse=' + Lacrosse.length);
Michigan_City[Michigan_City.length] = createMarker(new GPoint(-86.90492249,41.69696045),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lakeside Correctional Facility High School",'Michigan_City=' + Michigan_City.length);
Laporte[Laporte.length] = createMarker(new GPoint(-86.72558594,41.60194778),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Laporte High School",'Laporte=' + Laporte.length);
Laporte[Laporte.length] = createMarker(new GPoint(-86.71665192,41.61030197),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Laporte=' + Laporte.length);
Michigan_City[Michigan_City.length] = createMarker(new GPoint(-86.89201355,41.70763779),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Marsh Elementary School",'Michigan_City=' + Michigan_City.length);
Michigan_City[Michigan_City.length] = createMarker(new GPoint(-86.85507965,41.71673584),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Martin T Krueger Middle School",'Michigan_City=' + Michigan_City.length);
Michigan_City[Michigan_City.length] = createMarker(new GPoint(-86.88478851,41.71233749),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Michigan City Alternative High School",'Michigan_City=' + Michigan_City.length);
Michigan_City[Michigan_City.length] = createMarker(new GPoint(-86.86526489,41.68006134),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Michigan City High School",'Michigan_City=' + Michigan_City.length);
Michigan_City[Michigan_City.length] = createMarker(new GPoint(-86.89470673,41.71066284),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Michigan City Junior High School",'Michigan_City=' + Michigan_City.length);
Michigan_City[Michigan_City.length] = createMarker(new GPoint(-86.88446045,41.72769547),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mullen Elementary School",'Michigan_City=' + Michigan_City.length);
New_Carlisle[New_Carlisle.length] = createMarker(new GPoint(-86.56441498,41.68761444),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Prairie High School",'New_Carlisle=' + New_Carlisle.length);
New_Carlisle[New_Carlisle.length] = createMarker(new GPoint(-86.56441498,41.68755341),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("New Prairie Junior High School",'New_Carlisle=' + New_Carlisle.length);
Michigan_City[Michigan_City.length] = createMarker(new GPoint(-86.84056854,41.72317505),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Niemann Elementary School",'Michigan_City=' + Michigan_City.length);
Michigan_City[Michigan_City.length] = createMarker(new GPoint(-86.91617584,41.71193314),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Park Elementary School",'Michigan_City=' + Michigan_City.length);
Laporte[Laporte.length] = createMarker(new GPoint(-86.72280121,41.60729980),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Park School",'Laporte=' + Laporte.length);
Laporte[Laporte.length] = createMarker(new GPoint(-86.72336578,41.60681152),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Paul F Boston Middle School",'Laporte=' + Laporte.length);
Rolling_Prairie[Rolling_Prairie.length] = createMarker(new GPoint(-86.56983948,41.70959854),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Prairie View Elementary School",'Rolling_Prairie=' + Rolling_Prairie.length);
Laporte[Laporte.length] = createMarker(new GPoint(-86.73466492,41.61412430),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Riley Elementary School",'Laporte=' + Laporte.length);
Rolling_Prairie[Rolling_Prairie.length] = createMarker(new GPoint(-86.61103058,41.67598343),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Rolling Prairie Elementary School",'Rolling_Prairie=' + Rolling_Prairie.length);
Union_Mills[Union_Mills.length] = createMarker(new GPoint(-86.81503296,41.46455002),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South Central Elementary School",'Union_Mills=' + Union_Mills.length);
Union_Mills[Union_Mills.length] = createMarker(new GPoint(-86.81503296,41.46455002),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Central Junior Senior High School",'Union_Mills=' + Union_Mills.length);
Michigan_City[Michigan_City.length] = createMarker(new GPoint(-86.75931549,41.72247696),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Springfield Elementary School",'Michigan_City=' + Michigan_City.length);
Wanatah[Wanatah.length] = createMarker(new GPoint(-86.89182281,41.42755890),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wanatah Public School",'Wanatah=' + Wanatah.length);
Westville[Westville.length] = createMarker(new GPoint(-86.89450836,41.54093552),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Westville Elementary School",'Westville=' + Westville.length);
Westville[Westville.length] = createMarker(new GPoint(-86.91149902,41.55820084),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Westville High School",'Westville=' + Westville.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(Kingsford_Heights);
map.removeOverlays(Lacrosse);
map.removeOverlays(Laporte);
map.removeOverlays(Michigan_City);
map.removeOverlays(New_Carlisle);
map.removeOverlays(Rolling_Prairie);
map.removeOverlays(Union_Mills);
map.removeOverlays(Wanatah);
map.removeOverlays(Westville);
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(Michigan_City);map.removeOverlays(Kingsford_Heights);
map.removeOverlays(Lacrosse);
map.removeOverlays(Laporte);
map.removeOverlays(Michigan_City);
map.removeOverlays(New_Carlisle);
map.removeOverlays(Rolling_Prairie);
map.removeOverlays(Union_Mills);
map.removeOverlays(Wanatah);
map.removeOverlays(Westville);
map.addOverlays(Kingsford_Heights);
centerByArray(Kingsford_Heights, false, false);
cntMarker += Kingsford_Heights.length;
map.addOverlays(Lacrosse);
centerByArray(Lacrosse, false, false);
cntMarker += Lacrosse.length;
map.addOverlays(Laporte);
centerByArray(Laporte, false, false);
cntMarker += Laporte.length;
map.addOverlays(Michigan_City);
centerByArray(Michigan_City, false, false);
cntMarker += Michigan_City.length;
map.addOverlays(New_Carlisle);
centerByArray(New_Carlisle, false, false);
cntMarker += New_Carlisle.length;
map.addOverlays(Rolling_Prairie);
centerByArray(Rolling_Prairie, false, false);
cntMarker += Rolling_Prairie.length;
map.addOverlays(Union_Mills);
centerByArray(Union_Mills, false, false);
cntMarker += Union_Mills.length;
map.addOverlays(Wanatah);
centerByArray(Wanatah, false, false);
cntMarker += Wanatah.length;
map.addOverlays(Westville);
centerByArray(Westville, false, false);
cntMarker += Westville.length;
centerByArray(Michigan_City,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');
}
}