function addMarkers() { mySelect = document.getElementById('selection'); Greeneville = [];Afton = [];Chuckey = [];Greenville = [];Mohawk = [];Mosheim = [];mySelect.options[mySelect.options.length] = new Option("Afton schools",'all=Afton'); mySelect.options[mySelect.options.length] = new Option("Chuckey schools",'all=Chuckey'); mySelect.options[mySelect.options.length] = new Option("Greeneville schools",'all=Greeneville'); mySelect.options[mySelect.options.length] = new Option("Greenville schools",'all=Greenville'); mySelect.options[mySelect.options.length] = new Option("Mohawk schools",'all=Mohawk'); mySelect.options[mySelect.options.length] = new Option("Mosheim schools",'all=Mosheim'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Greeneville[Greeneville.length] = createMarker(new GPoint(-82.83841705,36.33330154),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Baileyton Elementary School",'Greeneville=' + Greeneville.length); Greeneville[Greeneville.length] = createMarker(new GPoint(-82.84023285,36.15265274),"",iconRd); mySelect.options[mySelect.options.length] = new Option("C Hal Henard Elementary School",'Greeneville=' + Greeneville.length); Greeneville[Greeneville.length] = createMarker(new GPoint(-82.76718140,36.06143570),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Camp Creek Elementary School",'Greeneville=' + Greeneville.length); Afton[Afton.length] = createMarker(new GPoint(-82.73242950,36.18791199),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Chuckey Doak High School",'Afton=' + Afton.length); Afton[Afton.length] = createMarker(new GPoint(-82.73223000,36.18791800),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Chuckey Doak Middle School",'Afton=' + Afton.length); Chuckey[Chuckey.length] = createMarker(new GPoint(-82.69587708,36.21455765),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Chuckey Elementary School",'Chuckey=' + Chuckey.length); Greeneville[Greeneville.length] = createMarker(new GPoint(-82.87563324,36.11246490),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Debusk Elementary School",'Greeneville=' + Greeneville.length); Greeneville[Greeneville.length] = createMarker(new GPoint(-82.75817871,36.17580032),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Doak Elementary School",'Greeneville=' + Greeneville.length); Greeneville[Greeneville.length] = createMarker(new GPoint(-82.81254578,36.16658401),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Eastview Elementary School",'Greeneville=' + Greeneville.length); Greeneville[Greeneville.length] = createMarker(new GPoint(-82.91604614,36.13274765),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Glenwood Elementary School",'Greeneville=' + Greeneville.length); Greenville[Greenville.length] = createMarker(new GPoint(-82.88091278,36.15574265),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Greene Vocational Center",'Greenville=' + Greenville.length); Greeneville[Greeneville.length] = createMarker(new GPoint(-82.82667542,36.16626358),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Greeneville High School",'Greeneville=' + Greeneville.length); Greeneville[Greeneville.length] = createMarker(new GPoint(-82.84069061,36.15237808),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Greeneville Middle School",'Greeneville=' + Greeneville.length); Greeneville[Greeneville.length] = createMarker(new GPoint(-82.83623505,36.16817856),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Highland Elementary School",'Greeneville=' + Greeneville.length); Mohawk[Mohawk.length] = createMarker(new GPoint(-83.12492371,36.16369629),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mcdonald Elementary School",'Mohawk=' + Mohawk.length); Mosheim[Mosheim.length] = createMarker(new GPoint(-82.95594025,36.19452286),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mosheim Elementary School",'Mosheim=' + Mosheim.length); Greeneville[Greeneville.length] = createMarker(new GPoint(-82.92205811,36.03519821),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Nolachuckey Elementary School",'Greeneville=' + Greeneville.length); Greeneville[Greeneville.length] = createMarker(new GPoint(-82.80371094,36.30937576),"",iconGr); mySelect.options[mySelect.options.length] = new Option("North Greene High School",'Greeneville=' + Greeneville.length); Greeneville[Greeneville.length] = createMarker(new GPoint(-82.86579132,36.26721954),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Ottway Elementary School",'Greeneville=' + Greeneville.length); Greeneville[Greeneville.length] = createMarker(new GPoint(-82.85889435,36.05250168),"",iconGr); mySelect.options[mySelect.options.length] = new Option("South Greene High School",'Greeneville=' + Greeneville.length); Greeneville[Greeneville.length] = createMarker(new GPoint(-82.78823853,36.17869186),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Tusculum View Elementary School",'Greeneville=' + Greeneville.length); Mosheim[Mosheim.length] = createMarker(new GPoint(-82.97718811,36.18686676),"",iconGr); mySelect.options[mySelect.options.length] = new Option("West Greene High School",'Mosheim=' + Mosheim.length); Greeneville[Greeneville.length] = createMarker(new GPoint(-82.71769714,36.34156418),"",iconRd); mySelect.options[mySelect.options.length] = new Option("West Pines Elementary School",'Greeneville=' + Greeneville.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(Afton); map.removeOverlays(Chuckey); map.removeOverlays(Greeneville); map.removeOverlays(Greenville); map.removeOverlays(Mohawk); map.removeOverlays(Mosheim); 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(Greeneville);map.removeOverlays(Afton); map.removeOverlays(Chuckey); map.removeOverlays(Greeneville); map.removeOverlays(Greenville); map.removeOverlays(Mohawk); map.removeOverlays(Mosheim); map.addOverlays(Afton); centerByArray(Afton, false, false); cntMarker += Afton.length; map.addOverlays(Chuckey); centerByArray(Chuckey, false, false); cntMarker += Chuckey.length; map.addOverlays(Greeneville); centerByArray(Greeneville, false, false); cntMarker += Greeneville.length; map.addOverlays(Greenville); centerByArray(Greenville, false, false); cntMarker += Greenville.length; map.addOverlays(Mohawk); centerByArray(Mohawk, false, false); cntMarker += Mohawk.length; map.addOverlays(Mosheim); centerByArray(Mosheim, false, false); cntMarker += Mosheim.length; centerByArray(Greeneville,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'); } }