AnsweredAssumed Answered

GeometryService Buffer Method - Hanging

Question asked by TommyThomp on May 21, 2016
Latest reply on May 22, 2016 by TommyThomp

Hey developers,


Attempting to have a buffer drawn around a graphic which the user has drawn on the map using the draw toolbar. Everything appears to be in order and the developer console returns no errors. The user clicks the buffer button and nothing happens.

 

Below is the method invoked when the user clicks the buffer button.

 

        _createBuffers: function () {

            this.inherited(arguments);

 

 

            //Internal variables

            var params = new BufferParameters();

            var gsvc = new GeometryService();

            var bufferGraphicsLayer = new GraphicsLayer();

            var gsvc = new GeometryService('http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer');

            var graphics = new Graphic();

 

 

            //Enable Button

            this._enableBtn(this.btnApply, true);

  

            //getGeometires method to pull geometries from AOI drawn into the graphics layer.

            graphics = this._graphicsLayer.graphics;

            var geometries = graphicsUtils.getGeometries(graphics);

 

 

            //parameters for the buffer <-- Need error handling for if user attempts to run the buffer without a drawn AOI

            params.bufferSpatialReference = new esri.SpatialReference({"wkid": this.map.spatialReference.wkid});

            params.distances = [document.getElementById("distance").value];

            params.geometries = geometries;         //<-------------------------- Potential Issue with buffer #1; geometries issue.

            params.geodesic = false;

            params.outSpatialReference = new esri.SpatialReference({ "wkid": this.map.spatialReference.wkid });

            params.unionResults = true;

            params.unit = GeometryService[document.getElementById("unit").value];

         

            //Place here the invoking of the geometry service and the creation of the symbols for the buffer layer.

            gsvc.buffer(params, showBuffer);

 

 

            //Function to draw buffers

            function showBuffer(buffer) {

                // Add the buffer graphic to the map

                var symbol = new SimpleFillSymbol()

                  .setColor(new Color([56, 102, 164, 0.4]))

                  .setOutline(

                    new SimpleLineSymbol()

                      .setColor(new Color([56, 102, 164, 0.8]))

                  );

                    bufferGraphics = new Graphic(buffer, symbol);

                    console.dir(bufferGraphicsLayer);   //<------------------- Potential Issue with buffer #2; graphicsLayer issue.

                    bufferGraphicsLayer.add(bufferGraphics);

            }

         

        },

 

Thanks in advance!

Outcomes