function addMarkers() { mySelect = document.getElementById('selection'); Fort_Smith = [];Barling = [];Greenwood = [];Hackett = [];Hartford = [];Lavaca = [];Mansfield = [];mySelect.options[mySelect.options.length] = new Option("Barling schools",'all=Barling'); mySelect.options[mySelect.options.length] = new Option("Fort Smith schools",'all=Fort_Smith'); mySelect.options[mySelect.options.length] = new Option("Greenwood schools",'all=Greenwood'); mySelect.options[mySelect.options.length] = new Option("Hackett schools",'all=Hackett'); mySelect.options[mySelect.options.length] = new Option("Hartford schools",'all=Hartford'); mySelect.options[mySelect.options.length] = new Option("Lavaca schools",'all=Lavaca'); mySelect.options[mySelect.options.length] = new Option("Mansfield schools",'all=Mansfield'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Fort_Smith[Fort_Smith.length] = createMarker(new GPoint(-94.38713837,35.37853622),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Albert Pike Elementary School",'Fort_Smith=' + Fort_Smith.length); Fort_Smith[Fort_Smith.length] = createMarker(new GPoint(-94.40497589,35.36658859),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Ballman Elementary School",'Fort_Smith=' + Fort_Smith.length); Barling[Barling.length] = createMarker(new GPoint(-94.31169128,35.32883835),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Barling Elementary School",'Barling=' + Barling.length); Fort_Smith[Fort_Smith.length] = createMarker(new GPoint(-94.41744995,35.31194687),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Beard Elementary School",'Fort_Smith=' + Fort_Smith.length); Fort_Smith[Fort_Smith.length] = createMarker(new GPoint(-94.41790009,35.37263870),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Belle Point Alternative Center",'Fort_Smith=' + Fort_Smith.length); Fort_Smith[Fort_Smith.length] = createMarker(new GPoint(-94.37326813,35.35836411),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bonneville Elementary School",'Fort_Smith=' + Fort_Smith.length); Fort_Smith[Fort_Smith.length] = createMarker(new GPoint(-94.40892029,35.33505249),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Carnall Elementary School",'Fort_Smith=' + Fort_Smith.length); Fort_Smith[Fort_Smith.length] = createMarker(new GPoint(-94.42579651,35.31124878),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cavanaugh Elementary School",'Fort_Smith=' + Fort_Smith.length); Fort_Smith[Fort_Smith.length] = createMarker(new GPoint(-94.37631226,35.40021515),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Dora Kimmons Junior High School",'Fort_Smith=' + Fort_Smith.length); Greenwood[Greenwood.length] = createMarker(new GPoint(-94.24173737,35.20124435),"",iconBl); mySelect.options[mySelect.options.length] = new Option("East Hills Middle School",'Greenwood=' + Greenwood.length); Fort_Smith[Fort_Smith.length] = createMarker(new GPoint(-94.39879608,35.29444122),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Elmer H. Cook Elementary School",'Fort_Smith=' + Fort_Smith.length); Fort_Smith[Fort_Smith.length] = createMarker(new GPoint(-94.35941315,35.36333084),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Euper Lane Elementary School",'Fort_Smith=' + Fort_Smith.length); Fort_Smith[Fort_Smith.length] = createMarker(new GPoint(-94.41250610,35.35331345),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Fairview Elementary School",'Fort_Smith=' + Fort_Smith.length); Greenwood[Greenwood.length] = createMarker(new GPoint(-94.25393677,35.21866226),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Greenwood High School",'Greenwood=' + Greenwood.length); Hackett[Hackett.length] = createMarker(new GPoint(-94.40962982,35.18664932),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hackett Elementary School",'Hackett=' + Hackett.length); Hackett[Hackett.length] = createMarker(new GPoint(-94.40962982,35.18664932),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Hackett High School",'Hackett=' + Hackett.length); Fort_Smith[Fort_Smith.length] = createMarker(new GPoint(-94.39229584,35.42973709),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Harry C. Morrison Elementary School",'Fort_Smith=' + Fort_Smith.length); Hartford[Hartford.length] = createMarker(new GPoint(-94.37390137,35.02249908),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hartford Elementary School",'Hartford=' + Hartford.length); Hartford[Hartford.length] = createMarker(new GPoint(-94.37390137,35.02249908),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Hartford High School",'Hartford=' + Hartford.length); Fort_Smith[Fort_Smith.length] = createMarker(new GPoint(-94.41373444,35.39599609),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Howard Elementary School",'Fort_Smith=' + Fort_Smith.length); Fort_Smith[Fort_Smith.length] = createMarker(new GPoint(-94.34037018,35.35119629),"",iconRd); mySelect.options[mySelect.options.length] = new Option("John P. Woods Elementary School",'Fort_Smith=' + Fort_Smith.length); Fort_Smith[Fort_Smith.length] = createMarker(new GPoint(-94.34033203,35.35265350),"",iconBl); mySelect.options[mySelect.options.length] = new Option("L. A. Chaffin Junior High School",'Fort_Smith=' + Fort_Smith.length); Lavaca[Lavaca.length] = createMarker(new GPoint(-94.17310333,35.33168030),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lavaca Elementary School",'Lavaca=' + Lavaca.length); Lavaca[Lavaca.length] = createMarker(new GPoint(-94.17566681,35.33278275),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Lavaca High School",'Lavaca=' + Lavaca.length); Lavaca[Lavaca.length] = createMarker(new GPoint(-94.17312622,35.33134842),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Lavaca Middle School",'Lavaca=' + Lavaca.length); Mansfield[Mansfield.length] = createMarker(new GPoint(-94.18558400,35.05853800),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Mansfield High School",'Mansfield=' + Mansfield.length); Greenwood[Greenwood.length] = createMarker(new GPoint(-94.25533295,35.21866226),"",iconRd); mySelect.options[mySelect.options.length] = new Option("North Main Elementary School",'Greenwood=' + Greenwood.length); Fort_Smith[Fort_Smith.length] = createMarker(new GPoint(-94.40795135,35.37850571),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Northside High School",'Fort_Smith=' + Fort_Smith.length); Fort_Smith[Fort_Smith.length] = createMarker(new GPoint(-94.41304016,35.35335159),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Ramsey Junior High School",'Fort_Smith=' + Fort_Smith.length); Fort_Smith[Fort_Smith.length] = createMarker(new GPoint(-94.39422607,35.33853149),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Raymond E. Orr Elementary School",'Fort_Smith=' + Fort_Smith.length); Greenwood[Greenwood.length] = createMarker(new GPoint(-94.23777771,35.20503998),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Raymond E. Wells Jr. High Sch.",'Greenwood=' + Greenwood.length); Fort_Smith[Fort_Smith.length] = createMarker(new GPoint(-94.38842773,35.34896469),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Southside High School",'Fort_Smith=' + Fort_Smith.length); Fort_Smith[Fort_Smith.length] = createMarker(new GPoint(-94.37625122,35.41483688),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Spradling Elementary School",'Fort_Smith=' + Fort_Smith.length); Fort_Smith[Fort_Smith.length] = createMarker(new GPoint(-94.38502502,35.39303589),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sunnymede Elementary School",'Fort_Smith=' + Fort_Smith.length); Fort_Smith[Fort_Smith.length] = createMarker(new GPoint(-94.37710571,35.40383530),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sutton Elementary School",'Fort_Smith=' + Fort_Smith.length); Fort_Smith[Fort_Smith.length] = createMarker(new GPoint(-94.41006470,35.38747787),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Tilles Elementary School",'Fort_Smith=' + Fort_Smith.length); Fort_Smith[Fort_Smith.length] = createMarker(new GPoint(-94.39426422,35.41284561),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Trusty Elementary School",'Fort_Smith=' + Fort_Smith.length); Fort_Smith[Fort_Smith.length] = createMarker(new GPoint(-94.42163300,35.38482400),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Western Arkansas Technical Center",'Fort_Smith=' + Fort_Smith.length); Greenwood[Greenwood.length] = createMarker(new GPoint(-94.29283142,35.21793747),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Westwood Elementary School",'Greenwood=' + Greenwood.length); Fort_Smith[Fort_Smith.length] = createMarker(new GPoint(-94.41308594,35.38709641),"",iconBl); mySelect.options[mySelect.options.length] = new Option("William O. Darby Junior High School",'Fort_Smith=' + Fort_Smith.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(Barling); map.removeOverlays(Fort_Smith); map.removeOverlays(Greenwood); map.removeOverlays(Hackett); map.removeOverlays(Hartford); map.removeOverlays(Lavaca); map.removeOverlays(Mansfield); 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(Fort_Smith);map.removeOverlays(Barling); map.removeOverlays(Fort_Smith); map.removeOverlays(Greenwood); map.removeOverlays(Hackett); map.removeOverlays(Hartford); map.removeOverlays(Lavaca); map.removeOverlays(Mansfield); map.addOverlays(Barling); centerByArray(Barling, false, false); cntMarker += Barling.length; map.addOverlays(Fort_Smith); centerByArray(Fort_Smith, false, false); cntMarker += Fort_Smith.length; map.addOverlays(Greenwood); centerByArray(Greenwood, false, false); cntMarker += Greenwood.length; map.addOverlays(Hackett); centerByArray(Hackett, false, false); cntMarker += Hackett.length; map.addOverlays(Hartford); centerByArray(Hartford, false, false); cntMarker += Hartford.length; map.addOverlays(Lavaca); centerByArray(Lavaca, false, false); cntMarker += Lavaca.length; map.addOverlays(Mansfield); centerByArray(Mansfield, false, false); cntMarker += Mansfield.length; centerByArray(Fort_Smith,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'); } }