function addMarkers() { mySelect = document.getElementById('selection'); Bloomfield = [];Linton = [];Lyons = [];Jasonville = [];Switz_City = [];Worthington = [];mySelect.options[mySelect.options.length] = new Option("Bloomfield schools",'all=Bloomfield'); mySelect.options[mySelect.options.length] = new Option("Jasonville schools",'all=Jasonville'); mySelect.options[mySelect.options.length] = new Option("Linton schools",'all=Linton'); mySelect.options[mySelect.options.length] = new Option("Lyons schools",'all=Lyons'); mySelect.options[mySelect.options.length] = new Option("Switz City schools",'all=Switz_City'); mySelect.options[mySelect.options.length] = new Option("Worthington schools",'all=Worthington'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Bloomfield[Bloomfield.length] = createMarker(new GPoint(-86.87439728,39.02930069),"
Bloomfield Elementary School
Po Box 266 500 W South St
Bloomfield, IN 47424

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bloomfield Elementary School",'Bloomfield=' + Bloomfield.length); Bloomfield[Bloomfield.length] = createMarker(new GPoint(-86.87439728,39.02930069),"
Bloomfield Junior Senior High School
Po Box 266 501 W Spring St
Bloomfield, IN 47424

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bloomfield Junior Senior High School",'Bloomfield=' + Bloomfield.length); Bloomfield[Bloomfield.length] = createMarker(new GPoint(-86.87439728,39.02930069),"
Eastern District Elementary School
Rr 4 Box 623
Bloomfield, IN 47424

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Eastern District Elementary School",'Bloomfield=' + Bloomfield.length); Bloomfield[Bloomfield.length] = createMarker(new GPoint(-86.87439728,39.02930069),"
Eastern Greene Elementary School
Rr 4 Box 623
Bloomfield, IN 47424

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Eastern Greene Elementary School",'Bloomfield=' + Bloomfield.length); Bloomfield[Bloomfield.length] = createMarker(new GPoint(-86.93792900,39.02675000),"
Eastern Greene High School
Rr 4 Box 623
Bloomfield, IN 47424

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Eastern Greene High School",'Bloomfield=' + Bloomfield.length); Linton[Linton.length] = createMarker(new GPoint(-94.68143800,43.11098100),"
Greene-sullivan Sp Ed School
77 ''a'' St Ne
Linton, IN 47441

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Greene-sullivan Sp Ed School",'Linton=' + Linton.length); Linton[Linton.length] = createMarker(new GPoint(-87.16172028,39.04123688),"
Linton-stockton Elementary School
900 4th St Ne
Linton, IN 47441

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Linton-stockton Elementary School",'Linton=' + Linton.length); Linton[Linton.length] = createMarker(new GPoint(-87.16576385,39.04109573),"
Linton-stockton High School
10 Ne ''h'' St
Linton, IN 47441

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Linton-stockton High School",'Linton=' + Linton.length); Linton[Linton.length] = createMarker(new GPoint(-87.16771900,39.03495000),"
Linton-stockton Jr High School
109 Ne ''i'' St
Linton, IN 47441

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Linton-stockton Jr High School",'Linton=' + Linton.length); Lyons[Lyons.length] = createMarker(new GPoint(-87.11360168,38.96110153),"
Lyons Elem/jr High School
Rr 1 Box 70a
Lyons, IN 47443

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lyons Elem/jr High School",'Lyons=' + Lyons.length); Jasonville[Jasonville.length] = createMarker(new GPoint(-87.20986176,39.16699982),"
Shakamak Elementary School
Rr 2 Box 42
Jasonville, IN 47438

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Shakamak Elementary School",'Jasonville=' + Jasonville.length); Jasonville[Jasonville.length] = createMarker(new GPoint(-87.20986176,39.16699982),"
Shakamak Junior Senior High School
Rr 2 Box 42
Jasonville, IN 47438

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Shakamak Junior Senior High School",'Jasonville=' + Jasonville.length); Switz_City[Switz_City.length] = createMarker(new GPoint(-87.03540039,39.04050064),"
White River Valley High School
Hwy 54 Po Box 1470
Switz City, IN 47465

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("White River Valley High School",'Switz_City=' + Switz_City.length); Worthington[Worthington.length] = createMarker(new GPoint(-86.98072052,39.11339951),"
Worthington Elem/jr High School
484 W Main St
Worthington, IN 47471

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Worthington Elem/jr High School",'Worthington=' + Worthington.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(Bloomfield); map.removeOverlays(Jasonville); map.removeOverlays(Linton); map.removeOverlays(Lyons); map.removeOverlays(Switz_City); map.removeOverlays(Worthington); 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(Bloomfield);map.removeOverlays(Bloomfield); map.removeOverlays(Jasonville); map.removeOverlays(Linton); map.removeOverlays(Lyons); map.removeOverlays(Switz_City); map.removeOverlays(Worthington); map.addOverlays(Bloomfield); centerByArray(Bloomfield, false, false); cntMarker += Bloomfield.length; map.addOverlays(Jasonville); centerByArray(Jasonville, false, false); cntMarker += Jasonville.length; map.addOverlays(Linton); centerByArray(Linton, false, false); cntMarker += Linton.length; map.addOverlays(Lyons); centerByArray(Lyons, false, false); cntMarker += Lyons.length; map.addOverlays(Switz_City); centerByArray(Switz_City, false, false); cntMarker += Switz_City.length; map.addOverlays(Worthington); centerByArray(Worthington, false, false); cntMarker += Worthington.length; centerByArray(Bloomfield,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'); } }