function addMarkers() { mySelect = document.getElementById('selection'); Newport = [];Cosby = [];Del_Rio = [];Hartford = [];Parrottsville = [];mySelect.options[mySelect.options.length] = new Option("Cosby schools",'all=Cosby'); mySelect.options[mySelect.options.length] = new Option("Del Rio schools",'all=Del_Rio'); mySelect.options[mySelect.options.length] = new Option("Hartford schools",'all=Hartford'); mySelect.options[mySelect.options.length] = new Option("Newport schools",'all=Newport'); mySelect.options[mySelect.options.length] = new Option("Parrottsville schools",'all=Parrottsville'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Newport[Newport.length] = createMarker(new GPoint(-83.18627930,35.96677017),"
Bridgeport Elementary School
1935 Edwina Bridgeport R
Newport, TN 37821

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bridgeport Elementary School",'Newport=' + Newport.length); Newport[Newport.length] = createMarker(new GPoint(-83.17850494,36.07450867),"
Centerview Elementary School
2400 Hwy 160
Newport, TN 37821

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Centerview Elementary School",'Newport=' + Newport.length); Newport[Newport.length] = createMarker(new GPoint(-83.19781494,35.96430206),"
Cocke County Adult High School
241 Hedrick Dr
Newport, TN 37821

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cocke County Adult High School",'Newport=' + Newport.length); Newport[Newport.length] = createMarker(new GPoint(-83.19692230,35.96443558),"
Cocke County High School
216 Hedrick Dr
Newport, TN 37821

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cocke County High School",'Newport=' + Newport.length); Cosby[Cosby.length] = createMarker(new GPoint(-83.22490692,35.84199905),"
Cosby Elementary School
3320 Cosby Highway
Cosby, TN 37722

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Cosby Elementary School",'Cosby=' + Cosby.length); Cosby[Cosby.length] = createMarker(new GPoint(-83.22475433,35.84205246),"
Cosby High School
3318 Cosby Hw
Cosby, TN 37722

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cosby High School",'Cosby=' + Cosby.length); Del_Rio[Del_Rio.length] = createMarker(new GPoint(-83.01595306,35.90230179),"
Del Rio Elementary School
500 South Highway 107
Del Rio, TN 37727

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Del Rio Elementary School",'Del_Rio=' + Del_Rio.length); Newport[Newport.length] = createMarker(new GPoint(-83.25585175,35.95946503),"
Edgemont Elementary School
375 Carson Springs Rd
Newport, TN 37821

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Edgemont Elementary School",'Newport=' + Newport.length); Hartford[Hartford.length] = createMarker(new GPoint(-83.09632111,35.84306335),"
Grassy Fork Elementary School
4120 Big Creek Rd
Hartford, TN 37753

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Grassy Fork Elementary School",'Hartford=' + Hartford.length); Newport[Newport.length] = createMarker(new GPoint(-83.18652344,35.96400070),"
Newport Grammar Elementary School
301 College St
Newport, TN 37821

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Newport Grammar Elementary School",'Newport=' + Newport.length); Newport[Newport.length] = createMarker(new GPoint(-83.17758942,35.98860931),"
Northwest Elementary School
344 Woodson Rd
Newport, TN 37821

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Northwest Elementary School",'Newport=' + Newport.length); Parrottsville[Parrottsville.length] = createMarker(new GPoint(-83.10129547,36.00854111),"
Parrottsville Elementary School
1901 Highway 321
Parrottsville, TN 37843

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Parrottsville Elementary School",'Parrottsville=' + Parrottsville.length); Cosby[Cosby.length] = createMarker(new GPoint(-83.23319244,35.79091263),"
Smoky Mountain Elementary School
135 South 32 Hw
Cosby, TN 37722

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Smoky Mountain Elementary School",'Cosby=' + Cosby.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(Cosby); map.removeOverlays(Del_Rio); map.removeOverlays(Hartford); map.removeOverlays(Newport); map.removeOverlays(Parrottsville); 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(Newport);map.removeOverlays(Cosby); map.removeOverlays(Del_Rio); map.removeOverlays(Hartford); map.removeOverlays(Newport); map.removeOverlays(Parrottsville); map.addOverlays(Cosby); centerByArray(Cosby, false, false); cntMarker += Cosby.length; map.addOverlays(Del_Rio); centerByArray(Del_Rio, false, false); cntMarker += Del_Rio.length; map.addOverlays(Hartford); centerByArray(Hartford, false, false); cntMarker += Hartford.length; map.addOverlays(Newport); centerByArray(Newport, false, false); cntMarker += Newport.length; map.addOverlays(Parrottsville); centerByArray(Parrottsville, false, false); cntMarker += Parrottsville.length; centerByArray(Newport,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'); } }