Select to view content in your preferred language

Buffer problem

644
3
06-30-2014 02:55 AM
RyanSmith1
Deactivated User
Hi, i have the following piece of code to perform a buffer operation after an onclick event on a button component, but for some reason the Buffer only gets produced after the second click.
 function doBuffer(geometryToBuffer)
{
  var params = new esri.tasks.BufferParameters();
  params.geometries = [geometryToBuffer];
  params.distances = [5,15];
  params.unit = esri.tasks.GeometryService.UNIT_KILOMETER;
  params.outSpatialReference = map.spatialReference;

  gsvc.buffer(params, showBuffer);
}

   function showBuffer(geometries) 
   {
        var symbol = new esri.symbol.SimpleFillSymbol(
          esri.symbol.SimpleFillSymbol.STYLE_SOLID,
          new esri.symbol.SimpleLineSymbol(
            esri.symbol.SimpleLineSymbol.STYLE_SOLID,
            new dojo.Color([0, 0, 255, 0.65]), 2
          ),
          new dojo.Color([0, 0, 255, 0.35])
        );

        dojo.forEach(geometries, function (geometry) {
            var graphic = new esri.Graphic(geometry, symbol);
            map.graphics.add(graphic);
        });
    }
0 Kudos
3 Replies
AlexeiB
Deactivated User
Does the doBuffer(..) function get called on the first click?
0 Kudos
RyanSmith1
Deactivated User
Does the doBuffer(..) function get called on the first click?


Thanks for the reply Alex, Yes it does get called on the first click
0 Kudos
JeffPace
MVP Alum
on first click, is geometryToBuffer valid or is it null
0 Kudos