function addMarkers() { mySelect = document.getElementById('selection'); Clinton = [];Andersonville = [];Briceville = [];Powell = [];Heiskell = [];Oak_Ridge = [];Lake_City = [];Norris = [];Oliver_Springs = [];mySelect.options[mySelect.options.length] = new Option("Andersonville schools",'all=Andersonville'); mySelect.options[mySelect.options.length] = new Option("Briceville schools",'all=Briceville'); mySelect.options[mySelect.options.length] = new Option("Clinton schools",'all=Clinton'); mySelect.options[mySelect.options.length] = new Option("Heiskell schools",'all=Heiskell'); mySelect.options[mySelect.options.length] = new Option("Lake City schools",'all=Lake_City'); mySelect.options[mySelect.options.length] = new Option("Norris schools",'all=Norris'); mySelect.options[mySelect.options.length] = new Option("Oak Ridge schools",'all=Oak_Ridge'); mySelect.options[mySelect.options.length] = new Option("Oliver Springs schools",'all=Oliver_Springs'); mySelect.options[mySelect.options.length] = new Option("Powell schools",'all=Powell'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Clinton[Clinton.length] = createMarker(new GPoint(-84.08020020,36.16830063),"
",iconGr); mySelect.options[mySelect.options.length] = new Option("Anderson Co. Career Technical Center",'Clinton=' + Clinton.length); Clinton[Clinton.length] = createMarker(new GPoint(-84.08020020,36.16830063),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Anderson County High School",'Clinton=' + Clinton.length); Andersonville[Andersonville.length] = createMarker(new GPoint(-84.07489777,36.15373993),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Andersonville Elementary School",'Andersonville=' + Andersonville.length); Briceville[Briceville.length] = createMarker(new GPoint(-84.18344116,36.17761230),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Briceville Elementary School",'Briceville=' + Briceville.length); Powell[Powell.length] = createMarker(new GPoint(-84.11020660,36.04202271),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Claxton Elementary School",'Powell=' + Powell.length); Clinton[Clinton.length] = createMarker(new GPoint(-84.13369751,36.10279846),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Clinton Elementary School",'Clinton=' + Clinton.length); Clinton[Clinton.length] = createMarker(new GPoint(-84.14292908,36.09473419),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Clinton High School",'Clinton=' + Clinton.length); Clinton[Clinton.length] = createMarker(new GPoint(-84.13524628,36.10066986),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Clinton Middle School",'Clinton=' + Clinton.length); Clinton[Clinton.length] = createMarker(new GPoint(-84.20150757,36.12811661),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Dutch Valley Elementary School",'Clinton=' + Clinton.length); Heiskell[Heiskell.length] = createMarker(new GPoint(-84.02853394,36.15345001),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Fairview Elementary School",'Heiskell=' + Heiskell.length); Oak_Ridge[Oak_Ridge.length] = createMarker(new GPoint(-84.21366882,36.04732132),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Glenwood Elementary School",'Oak_Ridge=' + Oak_Ridge.length); Clinton[Clinton.length] = createMarker(new GPoint(-84.23906708,36.05495071),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Grand Oaks Elementary School",'Clinton=' + Clinton.length); Oak_Ridge[Oak_Ridge.length] = createMarker(new GPoint(-84.22779083,36.02218628),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Jefferson Middle School",'Oak_Ridge=' + Oak_Ridge.length); Lake_City[Lake_City.length] = createMarker(new GPoint(-84.15127563,36.21931076),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lake City Elementary School",'Lake_City=' + Lake_City.length); Lake_City[Lake_City.length] = createMarker(new GPoint(-84.15003967,36.21120071),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Lake City Middle School",'Lake_City=' + Lake_City.length); Clinton[Clinton.length] = createMarker(new GPoint(-84.13215637,36.10316086),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Learn Center",'Clinton=' + Clinton.length); Oak_Ridge[Oak_Ridge.length] = createMarker(new GPoint(-84.30480957,36.00131607),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Linden Elementary School",'Oak_Ridge=' + Oak_Ridge.length); Norris[Norris.length] = createMarker(new GPoint(-84.06765747,36.19499969),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Norris Elementary School",'Norris=' + Norris.length); Norris[Norris.length] = createMarker(new GPoint(-84.07036591,36.19701385),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Norris Middle School",'Norris=' + Norris.length); Clinton[Clinton.length] = createMarker(new GPoint(-84.12815094,36.11251450),"",iconRd); mySelect.options[mySelect.options.length] = new Option("North Clinton Elementary School",'Clinton=' + Clinton.length); Oliver_Springs[Oliver_Springs.length] = createMarker(new GPoint(-84.32473755,36.03113937),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Norwood Elementary School",'Oliver_Springs=' + Oliver_Springs.length); Oliver_Springs[Oliver_Springs.length] = createMarker(new GPoint(-84.32473755,36.03113937),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Norwood Middle School",'Oliver_Springs=' + Oliver_Springs.length); Oak_Ridge[Oak_Ridge.length] = createMarker(new GPoint(-84.25885010,36.01819992),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Oak Ridge High School",'Oak_Ridge=' + Oak_Ridge.length); Oak_Ridge[Oak_Ridge.length] = createMarker(new GPoint(-84.26580048,35.99860001),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Preschool Elementary School",'Oak_Ridge=' + Oak_Ridge.length); Oak_Ridge[Oak_Ridge.length] = createMarker(new GPoint(-84.27822113,36.01107407),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Robertsville Middle School",'Oak_Ridge=' + Oak_Ridge.length); Clinton[Clinton.length] = createMarker(new GPoint(-84.13375092,36.07704926),"",iconRd); mySelect.options[mySelect.options.length] = new Option("South Clinton Elementary School",'Clinton=' + Clinton.length); Oak_Ridge[Oak_Ridge.length] = createMarker(new GPoint(-84.28057098,36.01027298),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Willow Brook Elementary School",'Oak_Ridge=' + Oak_Ridge.length); Oak_Ridge[Oak_Ridge.length] = createMarker(new GPoint(-84.24299622,36.01166916),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Woodland Elementary School",'Oak_Ridge=' + Oak_Ridge.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(Andersonville); map.removeOverlays(Briceville); map.removeOverlays(Clinton); map.removeOverlays(Heiskell); map.removeOverlays(Lake_City); map.removeOverlays(Norris); map.removeOverlays(Oak_Ridge); map.removeOverlays(Oliver_Springs); map.removeOverlays(Powell); 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(Clinton);map.removeOverlays(Andersonville); map.removeOverlays(Briceville); map.removeOverlays(Clinton); map.removeOverlays(Heiskell); map.removeOverlays(Lake_City); map.removeOverlays(Norris); map.removeOverlays(Oak_Ridge); map.removeOverlays(Oliver_Springs); map.removeOverlays(Powell); map.addOverlays(Andersonville); centerByArray(Andersonville, false, false); cntMarker += Andersonville.length; map.addOverlays(Briceville); centerByArray(Briceville, false, false); cntMarker += Briceville.length; map.addOverlays(Clinton); centerByArray(Clinton, false, false); cntMarker += Clinton.length; map.addOverlays(Heiskell); centerByArray(Heiskell, false, false); cntMarker += Heiskell.length; map.addOverlays(Lake_City); centerByArray(Lake_City, false, false); cntMarker += Lake_City.length; map.addOverlays(Norris); centerByArray(Norris, false, false); cntMarker += Norris.length; map.addOverlays(Oak_Ridge); centerByArray(Oak_Ridge, false, false); cntMarker += Oak_Ridge.length; map.addOverlays(Oliver_Springs); centerByArray(Oliver_Springs, false, false); cntMarker += Oliver_Springs.length; map.addOverlays(Powell); centerByArray(Powell, false, false); cntMarker += Powell.length; centerByArray(Clinton,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'); } }