function addMarkers() { mySelect = document.getElementById('selection'); Lagrange = [];Howe = [];Shipshewana = [];Wolcottville = [];Topeka = [];mySelect.options[mySelect.options.length] = new Option("Howe schools",'all=Howe'); mySelect.options[mySelect.options.length] = new Option("Lagrange schools",'all=Lagrange'); mySelect.options[mySelect.options.length] = new Option("Shipshewana schools",'all=Shipshewana'); mySelect.options[mySelect.options.length] = new Option("Topeka schools",'all=Topeka'); mySelect.options[mySelect.options.length] = new Option("Wolcottville schools",'all=Wolcottville'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Lagrange[Lagrange.length] = createMarker(new GPoint(-85.41099548,41.65216446),"
Lakeland High School
0805 E 075 N
Lagrange, IN 46761

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Lakeland High School",'Lagrange=' + Lagrange.length); Lagrange[Lagrange.length] = createMarker(new GPoint(-85.40830231,41.65249252),"
Lakeland Middle School
1055 E 075 N
Lagrange, IN 46761

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Lakeland Middle School",'Lagrange=' + Lagrange.length); Howe[Howe.length] = createMarker(new GPoint(-85.37550354,41.72600174),"
Lima-brighton Elementary School
Box 158
Howe, IN 46746

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lima-brighton Elementary School",'Howe=' + Howe.length); Shipshewana[Shipshewana.length] = createMarker(new GPoint(-85.57868195,41.63276291),"
Meadowview Elementary School
7950 W 050 S
Shipshewana, IN 46565

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Meadowview Elementary School",'Shipshewana=' + Shipshewana.length); Wolcottville[Wolcottville.length] = createMarker(new GPoint(-85.24920654,41.56901550),"
Milford Elementary School
9245 E 500 S
Wolcottville, IN 46795

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Milford Elementary School",'Wolcottville=' + Wolcottville.length); Lagrange[Lagrange.length] = createMarker(new GPoint(-85.40969849,41.64369965),"
Parkside Elementary School
1 Lemaster Cir
Lagrange, IN 46761

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Parkside Elementary School",'Lagrange=' + Lagrange.length); Lagrange[Lagrange.length] = createMarker(new GPoint(-85.20184326,41.63508224),"
Prairie Heights Elementary School
0455 S 1150 E
Lagrange, IN 46761

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Prairie Heights Elementary School",'Lagrange=' + Lagrange.length); Lagrange[Lagrange.length] = createMarker(new GPoint(-85.20182800,41.63599777),"
Prairie Heights Middle School
0395 S 1150 E
Lagrange, IN 46761

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Prairie Heights Middle School",'Lagrange=' + Lagrange.length); Lagrange[Lagrange.length] = createMarker(new GPoint(-85.20185852,41.63823318),"
Prairie Heights Senior High School
0245 S 1150 E
Lagrange, IN 46761

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Prairie Heights Senior High School",'Lagrange=' + Lagrange.length); Shipshewana[Shipshewana.length] = createMarker(new GPoint(-85.57192230,41.67639923),"
Shipshewana-scott Elementary School
Middlebury St Po Box 217
Shipshewana, IN 46565

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Shipshewana-scott Elementary School",'Shipshewana=' + Shipshewana.length); Topeka[Topeka.length] = createMarker(new GPoint(-85.53939819,41.53927994),"
Topeka Elementary School
Main St Po Box 39
Topeka, IN 46571

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Topeka Elementary School",'Topeka=' + Topeka.length); Topeka[Topeka.length] = createMarker(new GPoint(-85.54077911,41.62395859),"
Westview Elementary School
1715 S 600 W
Topeka, IN 46571

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Westview Elementary School",'Topeka=' + Topeka.length); Topeka[Topeka.length] = createMarker(new GPoint(-85.54092407,41.60485458),"
Westview Junior Senior High School
1635 S 600 W
Topeka, IN 46571

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Westview Junior Senior High School",'Topeka=' + Topeka.length); Wolcottville[Wolcottville.length] = createMarker(new GPoint(-85.34519958,41.55149841),"
Wolcott Mills Elementary School
Po Box 308 - Myers Sr 9
Wolcottville, IN 46795

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Wolcott Mills Elementary School",'Wolcottville=' + Wolcottville.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(Howe); map.removeOverlays(Lagrange); map.removeOverlays(Shipshewana); map.removeOverlays(Topeka); map.removeOverlays(Wolcottville); 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(Lagrange);map.removeOverlays(Howe); map.removeOverlays(Lagrange); map.removeOverlays(Shipshewana); map.removeOverlays(Topeka); map.removeOverlays(Wolcottville); map.addOverlays(Howe); centerByArray(Howe, false, false); cntMarker += Howe.length; map.addOverlays(Lagrange); centerByArray(Lagrange, false, false); cntMarker += Lagrange.length; map.addOverlays(Shipshewana); centerByArray(Shipshewana, false, false); cntMarker += Shipshewana.length; map.addOverlays(Topeka); centerByArray(Topeka, false, false); cntMarker += Topeka.length; map.addOverlays(Wolcottville); centerByArray(Wolcottville, false, false); cntMarker += Wolcottville.length; centerByArray(Lagrange,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'); } }