function addMarkers() { mySelect = document.getElementById('selection'); Jacksboro = [];Caryville = [];Pioneer = [];Jellico = [];La_Follette = [];Speedwell = [];Duff = [];mySelect.options[mySelect.options.length] = new Option("Caryville schools",'all=Caryville'); mySelect.options[mySelect.options.length] = new Option("Duff schools",'all=Duff'); mySelect.options[mySelect.options.length] = new Option("Jacksboro schools",'all=Jacksboro'); mySelect.options[mySelect.options.length] = new Option("Jellico schools",'all=Jellico'); mySelect.options[mySelect.options.length] = new Option("La Follette schools",'all=La_Follette'); mySelect.options[mySelect.options.length] = new Option("Pioneer schools",'all=Pioneer'); mySelect.options[mySelect.options.length] = new Option("Speedwell schools",'all=Speedwell'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Jacksboro[Jacksboro.length] = createMarker(new GPoint(-84.18250275,36.32189941),"
Campbell Co Adult High School
P O Box 445
Jacksboro, TN 37757

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Campbell Co Adult High School",'Jacksboro=' + Jacksboro.length); Jacksboro[Jacksboro.length] = createMarker(new GPoint(-84.14832306,36.35086441),"
Campbell County Comprehensive High School
150 Cougar La
Jacksboro, TN 37757

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Campbell County Comprehensive High School",'Jacksboro=' + Jacksboro.length); Caryville[Caryville.length] = createMarker(new GPoint(-84.21927643,36.29927063),"
Caryville Elementary School
140 Lake La
Caryville, TN 37714

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Caryville Elementary School",'Caryville=' + Caryville.length); Pioneer[Pioneer.length] = createMarker(new GPoint(-84.25591278,36.48156738),"
Elk Valley Elementary School
6691 Hwy 297
Pioneer, TN 37847

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Elk Valley Elementary School",'Pioneer=' + Pioneer.length); Jacksboro[Jacksboro.length] = createMarker(new GPoint(-84.18554687,36.32944870),"
Jacksboro Elementary School
B0x 437
Jacksboro, TN 37757

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Jacksboro Elementary School",'Jacksboro=' + Jacksboro.length); Jacksboro[Jacksboro.length] = createMarker(new GPoint(-84.19015503,36.33190918),"
Jacksboro Middle School
P O Box 438
Jacksboro, TN 37757

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Jacksboro Middle School",'Jacksboro=' + Jacksboro.length); Jellico[Jellico.length] = createMarker(new GPoint(-84.12966919,36.57572174),"
Jellico Elementary School
551 Sunset Tr
Jellico, TN 37762

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Jellico Elementary School",'Jellico=' + Jellico.length); Jellico[Jellico.length] = createMarker(new GPoint(-84.11573029,36.57850266),"
Jellico High School
141 High School
Jellico, TN 37762

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Jellico High School",'Jellico=' + Jellico.length); La_Follette[La_Follette.length] = createMarker(new GPoint(-84.11133575,36.38565063),"
La Follette East Elementary School
860 East Chestnut St
La Follette, TN 37766

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("La Follette East Elementary School",'La_Follette=' + La_Follette.length); La_Follette[La_Follette.length] = createMarker(new GPoint(-84.10191345,36.38927460),"
La Follette Middle School
1309 East Central Av
La Follette, TN 37766

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("La Follette Middle School",'La_Follette=' + La_Follette.length); La_Follette[La_Follette.length] = createMarker(new GPoint(-84.12342834,36.37710190),"
La Follette West Elementary School
318 W Beech St
La Follette, TN 37766

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("La Follette West Elementary School",'La_Follette=' + La_Follette.length); Speedwell[Speedwell.length] = createMarker(new GPoint(-83.82250214,36.47660065),"
Powell Valley Elementary School
Rt 1 Box 275
Speedwell, TN 37870

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Powell Valley Elementary School",'Speedwell=' + Speedwell.length); Caryville[Caryville.length] = createMarker(new GPoint(-84.18284607,36.25647354),"
Ridgewood Elementary School
1970 Hwy 116
Caryville, TN 37714

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Ridgewood Elementary School",'Caryville=' + Caryville.length); Caryville[Caryville.length] = createMarker(new GPoint(-84.22821045,36.29480743),"
Stony Fork School
125 Clinchmore Rd
Caryville, TN 37714

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Stony Fork School",'Caryville=' + Caryville.length); La_Follette[La_Follette.length] = createMarker(new GPoint(-84.02093506,36.42205811),"
Valley View Elementary School
1187 Old Middlesboro Hw
La Follette, TN 37766

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Valley View Elementary School",'La_Follette=' + La_Follette.length); Duff[Duff.length] = createMarker(new GPoint(-84.00350189,36.51451111),"
White Oak Elementary School
5634 White Oak Rd
Duff, TN 37729

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("White Oak Elementary School",'Duff=' + Duff.length); Duff[Duff.length] = createMarker(new GPoint(-84.07656097,36.51269913),"
Wynn Habersham School
174 Habersham Rd
Duff, TN 37729

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Wynn Habersham School",'Duff=' + Duff.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(Caryville); map.removeOverlays(Duff); map.removeOverlays(Jacksboro); map.removeOverlays(Jellico); map.removeOverlays(La_Follette); map.removeOverlays(Pioneer); map.removeOverlays(Speedwell); 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(Jacksboro);map.removeOverlays(Caryville); map.removeOverlays(Duff); map.removeOverlays(Jacksboro); map.removeOverlays(Jellico); map.removeOverlays(La_Follette); map.removeOverlays(Pioneer); map.removeOverlays(Speedwell); map.addOverlays(Caryville); centerByArray(Caryville, false, false); cntMarker += Caryville.length; map.addOverlays(Duff); centerByArray(Duff, false, false); cntMarker += Duff.length; map.addOverlays(Jacksboro); centerByArray(Jacksboro, false, false); cntMarker += Jacksboro.length; map.addOverlays(Jellico); centerByArray(Jellico, false, false); cntMarker += Jellico.length; map.addOverlays(La_Follette); centerByArray(La_Follette, false, false); cntMarker += La_Follette.length; map.addOverlays(Pioneer); centerByArray(Pioneer, false, false); cntMarker += Pioneer.length; map.addOverlays(Speedwell); centerByArray(Speedwell, false, false); cntMarker += Speedwell.length; centerByArray(Jacksboro,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'); } }