function addMarkers() { mySelect = document.getElementById('selection'); Tullahoma = [];Manchester = [];Hillsboro = [];Normandy = [];mySelect.options[mySelect.options.length] = new Option("Hillsboro schools",'all=Hillsboro'); mySelect.options[mySelect.options.length] = new Option("Manchester schools",'all=Manchester'); mySelect.options[mySelect.options.length] = new Option("Normandy schools",'all=Normandy'); mySelect.options[mySelect.options.length] = new Option("Tullahoma schools",'all=Tullahoma'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Tullahoma[Tullahoma.length] = createMarker(new GPoint(-86.22870636,35.35899353),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bel Aire Elementary School",'Tullahoma=' + Tullahoma.length); Manchester[Manchester.length] = createMarker(new GPoint(-86.09652710,35.44796371),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Coffee County Central High School",'Manchester=' + Manchester.length); Manchester[Manchester.length] = createMarker(new GPoint(-86.07608032,35.48679352),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Coffee County Middle School",'Manchester=' + Manchester.length); Manchester[Manchester.length] = createMarker(new GPoint(-86.08245087,35.47961807),"",iconRd); mySelect.options[mySelect.options.length] = new Option("College Street Elementary School",'Manchester=' + Manchester.length); Manchester[Manchester.length] = createMarker(new GPoint(-86.00519562,35.53668594),"",iconRd); mySelect.options[mySelect.options.length] = new Option("East Coffee Elementary School",'Manchester=' + Manchester.length); Tullahoma[Tullahoma.length] = createMarker(new GPoint(-86.20045471,35.36809540),"",iconRd); mySelect.options[mySelect.options.length] = new Option("East Lincoln Elementary School",'Tullahoma=' + Tullahoma.length); Tullahoma[Tullahoma.length] = createMarker(new GPoint(-86.20499420,35.37611389),"",iconBl); mySelect.options[mySelect.options.length] = new Option("East Middle School",'Tullahoma=' + Tullahoma.length); Tullahoma[Tullahoma.length] = createMarker(new GPoint(-86.14066315,35.40097427),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hickerson Elementary School",'Tullahoma=' + Tullahoma.length); Hillsboro[Hillsboro.length] = createMarker(new GPoint(-85.97345734,35.40843964),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hillsboro Elementary School",'Hillsboro=' + Hillsboro.length); Tullahoma[Tullahoma.length] = createMarker(new GPoint(-86.21791840,35.35377502),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jack T Farrar Elementary School",'Tullahoma=' + Tullahoma.length); Normandy[Normandy.length] = createMarker(new GPoint(-86.23281860,35.41927338),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jones Elementary School",'Normandy=' + Normandy.length); Manchester[Manchester.length] = createMarker(new GPoint(-86.08023071,35.53430939),"",iconRd); mySelect.options[mySelect.options.length] = new Option("New Union Elementary School",'Manchester=' + Manchester.length); Manchester[Manchester.length] = createMarker(new GPoint(-86.16764832,35.54133224),"",iconRd); mySelect.options[mySelect.options.length] = new Option("North Coffee Elementary School",'Manchester=' + Manchester.length); Manchester[Manchester.length] = createMarker(new GPoint(-86.07923126,35.47782516),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Riverview Training Center",'Manchester=' + Manchester.length); Tullahoma[Tullahoma.length] = createMarker(new GPoint(-86.21173900,35.36210500),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Robert E. Lee Elementary School",'Tullahoma=' + Tullahoma.length); Tullahoma[Tullahoma.length] = createMarker(new GPoint(-86.22026062,35.37125778),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Tullahoma High School",'Tullahoma=' + Tullahoma.length); Tullahoma[Tullahoma.length] = createMarker(new GPoint(-86.20943451,35.35690308),"",iconBl); mySelect.options[mySelect.options.length] = new Option("West Middle School",'Tullahoma=' + Tullahoma.length); Manchester[Manchester.length] = createMarker(new GPoint(-86.09383392,35.47252655),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Westwood Elementary School",'Manchester=' + Manchester.length); Manchester[Manchester.length] = createMarker(new GPoint(-86.08905029,35.47376633),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Westwood Junior High School",'Manchester=' + Manchester.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(Hillsboro); map.removeOverlays(Manchester); map.removeOverlays(Normandy); map.removeOverlays(Tullahoma); 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(Tullahoma);map.removeOverlays(Hillsboro); map.removeOverlays(Manchester); map.removeOverlays(Normandy); map.removeOverlays(Tullahoma); map.addOverlays(Hillsboro); centerByArray(Hillsboro, false, false); cntMarker += Hillsboro.length; map.addOverlays(Manchester); centerByArray(Manchester, false, false); cntMarker += Manchester.length; map.addOverlays(Normandy); centerByArray(Normandy, false, false); cntMarker += Normandy.length; map.addOverlays(Tullahoma); centerByArray(Tullahoma, false, false); cntMarker += Tullahoma.length; centerByArray(Tullahoma,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'); } }