I am trying to create a buffer that will have the distance and units inputted by the user.
I'm having trouble getting the JavaScript to recognize the which Unit of Measurement the buffer is being set to. When I click on the map to generate the buffer nothing shows up. This is the JavaScript I wrote:
function doBuffer(evt) {
map.graphics.clear();
var params = new esri.tasks.BufferParameters();
params.geometries = [ evt.mapPoint ];
//buffer in linear units such as meters, km, miles etc.
params.distances = [ document.getElementById("distance").value];
params.unit = document.getElementById("units").value;
params.outSpatialReference = map.spatialReference;
gsvc.buffer(params, showBuffer);
}
This is the HTML I wrote:
<div id="featureCount">Enter the unit and distance to set the buffer.</div>
<p>Distance</p>
<input id="distance" type="number" name="Distance">
<p>Unit of Measurement</p>
<select id="units">
<option value="esri.tasks.GeometryService.UNIT_FOOT">Feet (ft)</option>
<option value="esri.tasks.GeometryService.UNIT_METER">Meters (m)</option>
<option value="esri.tasks.GeometryService.UNIT_KILOMETER">Kilometers (km)</option>
<option value="esri.tasks.GeometryService.UNIT_STATUTE_MILE">Miles (mi)</option>
<option value="esri.tasks.GeometryService.UNIT_NAUTICAL_MILE">Nautical Miles (NM)</option>
</select>
How can I get my code to recognize which unit of measurement I am setting the buffer to so it can load correctly?
params.unit = document.getElementById("units").options[document.getElementById("units").selectedIndex].value;
reference: stackoverflow.com/questions/1085801/…