function addMarkers() { mySelect = document.getElementById('selection'); Michigantown = [];Frankfort = [];Rossville = [];mySelect.options[mySelect.options.length] = new Option("Frankfort schools",'all=Frankfort'); mySelect.options[mySelect.options.length] = new Option("Michigantown schools",'all=Michigantown'); mySelect.options[mySelect.options.length] = new Option("Rossville schools",'all=Rossville'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Michigantown[Michigantown.length] = createMarker(new GPoint(-86.38890076,40.32550049),"
Clinton Central Elementary School
Po Box 238
Michigantown, IN 46057

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Clinton Central Elementary School",'Michigantown=' + Michigantown.length); Michigantown[Michigantown.length] = createMarker(new GPoint(-86.38890076,40.32550049),"
Clinton Central Junior-senior High School
Po Box 178
Michigantown, IN 46057

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Clinton Central Junior-senior High School",'Michigantown=' + Michigantown.length); Frankfort[Frankfort.length] = createMarker(new GPoint(-86.51200104,40.27967834),"
Clinton Prairie Elementary School
2500 S Cr 450 W
Frankfort, IN 46041

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Clinton Prairie Elementary School",'Frankfort=' + Frankfort.length); Frankfort[Frankfort.length] = createMarker(new GPoint(-86.51200104,40.27967834),"
Clinton Prairie Junior Senior High School
2400 S Cr 450 W
Frankfort, IN 46041

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Clinton Prairie Junior Senior High School",'Frankfort=' + Frankfort.length); Frankfort[Frankfort.length] = createMarker(new GPoint(-86.48691559,40.28129578),"
Frankfort Middle School
329 N Maish Rd
Frankfort, IN 46041

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Frankfort Middle School",'Frankfort=' + Frankfort.length); Frankfort[Frankfort.length] = createMarker(new GPoint(-86.48691559,40.28076172),"
Frankfort Senior High School
1 S Maish Rd
Frankfort, IN 46041

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Frankfort Senior High School",'Frankfort=' + Frankfort.length); Frankfort[Frankfort.length] = createMarker(new GPoint(-86.50112152,40.27874374),"
James Whitcomb Riley Elementary School
303 S Williams St
Frankfort, IN 46041

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("James Whitcomb Riley Elementary School",'Frankfort=' + Frankfort.length); Rossville[Rossville.length] = createMarker(new GPoint(-86.60829926,40.42330170),"
Rossville Elementary School
Po Box 530
Rossville, IN 46065

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Rossville Elementary School",'Rossville=' + Rossville.length); Rossville[Rossville.length] = createMarker(new GPoint(-86.59636900,40.41694000),"
Rossville Middle School
P O Box 530
Rossville, IN 46065

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Rossville Middle School",'Rossville=' + Rossville.length); Rossville[Rossville.length] = createMarker(new GPoint(-86.60829926,40.42330170),"
Rossville Middle/sr High School
Po Box 530
Rossville, IN 46065

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Rossville Middle/sr High School",'Rossville=' + Rossville.length); Frankfort[Frankfort.length] = createMarker(new GPoint(-86.51697540,40.27856064),"
Samuel P Kyger Elementary School
300 S 3rd St
Frankfort, IN 46041

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Samuel P Kyger Elementary School",'Frankfort=' + Frankfort.length); Frankfort[Frankfort.length] = createMarker(new GPoint(-86.50656891,40.26812363),"
South Side Elementary School
1007 Alhambra Ave
Frankfort, IN 46041

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("South Side Elementary School",'Frankfort=' + Frankfort.length); Frankfort[Frankfort.length] = createMarker(new GPoint(-86.52887726,40.29013824),"
Suncrest Elementary School
1608 W Kyger St
Frankfort, IN 46041

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Suncrest Elementary School",'Frankfort=' + Frankfort.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(Frankfort); map.removeOverlays(Michigantown); map.removeOverlays(Rossville); 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(Michigantown);map.removeOverlays(Frankfort); map.removeOverlays(Michigantown); map.removeOverlays(Rossville); map.addOverlays(Frankfort); centerByArray(Frankfort, false, false); cntMarker += Frankfort.length; map.addOverlays(Michigantown); centerByArray(Michigantown, false, false); cntMarker += Michigantown.length; map.addOverlays(Rossville); centerByArray(Rossville, false, false); cntMarker += Rossville.length; centerByArray(Michigantown,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'); } }