kangdon

Perfrom a queryTask onBufferComplete ??

Discussion created by kangdon on Nov 28, 2011
Latest reply on Dec 1, 2011 by khutchins-esristaff
Hello,
I am looking for a ways to create a buffer polygon and would like to select polygon features that are within the created buffer polygon.
Following are what I have so far.

1. Select a parcel polygon
2. With click of a button, "doBuffer" function gets called.
3. Based on the #1 selected parcel, a buffer polygon gets created and added to the map.
4. And then at the buffer "onBufferComplete" event, I would like to execute a query so select
all parcels within the buffer polygon.

This function works up until #3, but nothing happens on #4.

Can anyone see what is wrong with my doBuffer function.
Any suggestion of making this function work. Do any of you have working sample that would like to share?

thanks

Don Kang


function doBuffer() {
            var buffParams = new esri.tasks.BufferParameters();
            var extent = new esri.geometry.Extent(getGraphicsExtent(map.graphics.graphics));
            buffParams.geometries = [extent];  // var val = dojo.byId("txtSearchAPN").value
            buffParams.distances = [dojo.byId('bufferDistance').value];
            buffParams.unit = esri.tasks.GeometryService.UNIT_FOOT;
            buffParams.bufferSpatialReference = new esri.SpatialReference({ wkid: 3421 });
            buffParams.outSpatialReference = map.spatialReference;
            gsvc.buffer(buffParams);

            var link1 = dojo.connect(gsvc, "onBufferComplete", function (geometries) {
                var symbol1 = new esri.symbol.SimpleFillSymbol("none", new esri.symbol.SimpleLineSymbol("dashdot", new dojo.Color([255, 0, 0]), 2), new dojo.Color([255, 255, 0, 0.25]));
                var graphic = new esri.Graphic(geometries[0], symbol1);
                map.graphics.add(graphic);

                query.where = "";
                query.geometry = graphic.geometry;
                //query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_INTERSECTS;
                query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_CONTAINS;
    queryTask.execute(query);
    //alert('Hello test');
            });

            var link2 = dojo.connect(queryTask, "onComplete", function (featureSet) {
                alert('Hello test');
                alert(featureSet.features.length);

                dojo.disconnect(link1);
                dojo.disconnect(link2);
            });
        }

Outcomes