function addMarkers() { mySelect = document.getElementById('selection'); Wynnewood = [];Elmore_City = [];Pauls_Valley = [];Lindsay = [];Maysville = [];Paoli = [];Stratford = [];mySelect.options[mySelect.options.length] = new Option("Elmore City schools",'all=Elmore_City'); mySelect.options[mySelect.options.length] = new Option("Lindsay schools",'all=Lindsay'); mySelect.options[mySelect.options.length] = new Option("Maysville schools",'all=Maysville'); mySelect.options[mySelect.options.length] = new Option("Paoli schools",'all=Paoli'); mySelect.options[mySelect.options.length] = new Option("Pauls Valley schools",'all=Pauls_Valley'); mySelect.options[mySelect.options.length] = new Option("Stratford schools",'all=Stratford'); mySelect.options[mySelect.options.length] = new Option("Wynnewood schools",'all=Wynnewood'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Wynnewood[Wynnewood.length] = createMarker(new GPoint(-97.16274261,34.64386368),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Wynnewood=' + Wynnewood.length); Elmore_City[Elmore_City.length] = createMarker(new GPoint(-97.39392853,34.62313843),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Elmore City-pernell Elementary School",'Elmore_City=' + Elmore_City.length); Elmore_City[Elmore_City.length] = createMarker(new GPoint(-97.39392853,34.62313843),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Elmore City-pernell Junior High School",'Elmore_City=' + Elmore_City.length); Pauls_Valley[Pauls_Valley.length] = createMarker(new GPoint(-97.21869659,34.73860168),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jackson Elementary School",'Pauls_Valley=' + Pauls_Valley.length); Pauls_Valley[Pauls_Valley.length] = createMarker(new GPoint(-97.21869659,34.73860168),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jefferson Early Lrning Center",'Pauls_Valley=' + Pauls_Valley.length); Wynnewood[Wynnewood.length] = createMarker(new GPoint(-97.16274261,34.64386368),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Joy Ec Center",'Wynnewood=' + Wynnewood.length); Pauls_Valley[Pauls_Valley.length] = createMarker(new GPoint(-97.21869659,34.73860168),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Lee Elementary School",'Pauls_Valley=' + Pauls_Valley.length); Lindsay[Lindsay.length] = createMarker(new GPoint(-97.61269379,34.83373642),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lindsay Elementary School",'Lindsay=' + Lindsay.length); Lindsay[Lindsay.length] = createMarker(new GPoint(-97.61269379,34.83373642),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Lindsay High School",'Lindsay=' + Lindsay.length); Lindsay[Lindsay.length] = createMarker(new GPoint(-97.61269379,34.83373642),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Lindsay Middle School",'Lindsay=' + Lindsay.length); Maysville[Maysville.length] = createMarker(new GPoint(-97.40986633,34.82183838),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Maysville Elementary School",'Maysville=' + Maysville.length); Maysville[Maysville.length] = createMarker(new GPoint(-97.40986633,34.82183838),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Maysville High School",'Maysville=' + Maysville.length); Paoli[Paoli.length] = createMarker(new GPoint(-97.26969910,34.82759857),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Paoli Elementary School",'Paoli=' + Paoli.length); Paoli[Paoli.length] = createMarker(new GPoint(-97.26969910,34.82759857),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Paoli High School",'Paoli=' + Paoli.length); Pauls_Valley[Pauls_Valley.length] = createMarker(new GPoint(-97.21869659,34.73860168),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Pauls Valley High School",'Pauls_Valley=' + Pauls_Valley.length); Pauls_Valley[Pauls_Valley.length] = createMarker(new GPoint(-97.21869659,34.73860168),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Pauls Valley Junior High School",'Pauls_Valley=' + Pauls_Valley.length); Elmore_City[Elmore_City.length] = createMarker(new GPoint(-97.39392853,34.62313843),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Senior High School",'Elmore_City=' + Elmore_City.length); Stratford[Stratford.length] = createMarker(new GPoint(-96.97760010,34.77460098),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Stratford Elementary School",'Stratford=' + Stratford.length); Stratford[Stratford.length] = createMarker(new GPoint(-96.96167900,34.79665500),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Stratford High School",'Stratford=' + Stratford.length); Stratford[Stratford.length] = createMarker(new GPoint(-96.97760010,34.77460098),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Stratford Junior Senior High School",'Stratford=' + Stratford.length); Pauls_Valley[Pauls_Valley.length] = createMarker(new GPoint(-97.28340149,34.76509857),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Whitebead Elementary School",'Pauls_Valley=' + Pauls_Valley.length); Wynnewood[Wynnewood.length] = createMarker(new GPoint(-97.16274261,34.64386368),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Wynnewood High School",'Wynnewood=' + Wynnewood.length); Wynnewood[Wynnewood.length] = createMarker(new GPoint(-97.16274261,34.64386368),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Wynnewood Middle School",'Wynnewood=' + Wynnewood.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(Elmore_City); map.removeOverlays(Lindsay); map.removeOverlays(Maysville); map.removeOverlays(Paoli); map.removeOverlays(Pauls_Valley); map.removeOverlays(Stratford); map.removeOverlays(Wynnewood); 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(Wynnewood);map.removeOverlays(Elmore_City); map.removeOverlays(Lindsay); map.removeOverlays(Maysville); map.removeOverlays(Paoli); map.removeOverlays(Pauls_Valley); map.removeOverlays(Stratford); map.removeOverlays(Wynnewood); map.addOverlays(Elmore_City); centerByArray(Elmore_City, false, false); cntMarker += Elmore_City.length; map.addOverlays(Lindsay); centerByArray(Lindsay, false, false); cntMarker += Lindsay.length; map.addOverlays(Maysville); centerByArray(Maysville, false, false); cntMarker += Maysville.length; map.addOverlays(Paoli); centerByArray(Paoli, false, false); cntMarker += Paoli.length; map.addOverlays(Pauls_Valley); centerByArray(Pauls_Valley, false, false); cntMarker += Pauls_Valley.length; map.addOverlays(Stratford); centerByArray(Stratford, false, false); cntMarker += Stratford.length; map.addOverlays(Wynnewood); centerByArray(Wynnewood, false, false); cntMarker += Wynnewood.length; centerByArray(Wynnewood,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'); } }