Select to view content in your preferred language

Buffer query result polygon

1875
15
08-01-2012 09:05 AM
DonCaviness
New Contributor III
I am trying to buffer the result of a query which is a polygon.  I have tried several different approaches but my code always fails when calling the geometry service's buffer function.  Once I buffer the selected polygon (the query result) I'm going to use the geometry of the buffer to do a spatial query.  Can anyone see what is the issue with my code?  Thanks, Don.

function performParcelSearch(){
    var parcelVal = $("#inputParcel").val();
    var bufferDist = $("#inputBuffer").val();
    var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASHDOT, new dojo.Color([255, 0, 0]), 2), new dojo.Color([255, 255, 0, 0.25]));
    var queryTask = new esri.tasks.QueryTask(searchLayer);
    if (!parcelVal) {
        alert("Please enter a parcel number.");
    }
    else {
        var qryExp = "parcel_f = '" + parcelVal + "'";
        //initialize query
        var parcelQuery = new esri.tasks.Query();
        parcelQuery.returnGeometry = true;
        parcelQuery.outFields = ["*"];
        parcelQuery.where = qryExp;
        
        //execute query
        queryTask.execute(parcelQuery, function showResults(featureSet){
            //remove all graphics on the maps graphics layer
            map.graphics.clear();
            var features = featureSet.features;
            
            //QueryTask returns a featureSet.  Loop through features in the featureSet and add them to the map.
            dojo.forEach(features, function(feature){
                var graphic = feature;
                graphic.setSymbol(symbol);
                console.log("BB");
                
                //Add graphic to the map graphics layer.
                var featureextent = graphic.geometry.getExtent();
                map.setExtent(featureextent, true);
                map.graphics.add(graphic);
                
                /*------------------------------------*/
                // Performs Buffer Search
                /*------------------------------------*/
                if (bufferDist > 0) {
                
                    $("#exportDiv").show("slow");
                    $("#bufferResultsDiv").show("slow");
                    var params = new esri.tasks.BufferParameters();
                    params.distances = bufferDist;
                    params.bufferSpatialReference = map.spatialReference;
                    params.outSpatialReference = map.spatialReference;
                    params.unit = esri.tasks.GeometryService.UNIT_FOOT;
                    params.geometries = feature.geometry;
                    
     geometryService.buffer(params, showBuffer);
                }
            });
        });
    }
}
0 Kudos
15 Replies
JohnGravois
Frequent Contributor
Don,

are you referencing a proxy in your application?  The Javascript API requires that you use one to pass complex geometries in a request to a geometry operation.

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp/ags_proxy.htm
0 Kudos
DonCaviness
New Contributor III
I am aware of the use of a proxy page while using complex geometries.  That actually bit me a year or so ago on another project.  I am however using a proxy in this case as well.  I would think it might have something to do with a proxy if the geometry service itself was actually getting called and nothing worked, however that isn't the case here.  The code is failing before the call is made to the geometry service.
0 Kudos
StephenLead
Regular Contributor III
Can you post a link to your site?
0 Kudos
DonCaviness
New Contributor III
Steve, unfortunately the site I am working on is not public as of now.  All I can do is post the snippet of the code that I'm having an issue with, which I posted here originally.
0 Kudos
ReddaiahPurma
New Contributor
May b this will help you...

Buffer along Selected Feature with two distances.................. Code in attachment........

<div id="FeatureIntersectBufferdialog" title="Query Intersect Buffer" style="display: none;">
        <div id="FeatureIntersectd">
        <table cellspacing="0" cellpadding="3" border="0" width="100%" height="100%">
          <tr>
           <td width="180px;">
            <span style="font-weight:bold;" >Select Main Service </span>
           </td>
           <td width="200px;">
             <select id="FIBService" style="width:180px;" onchange="FIBMainDrpServiceChange();" ></select>
           </td>
          </tr>
          <tr>
           <td width="180px;">
           <span style="font-weight:bold;" >Select Main Layer </span>
           </td>
           <td width="200px;">
           <select id="FeatureIntersectdrp" style="width:180px;"></select>
           </td>
          </tr>
          <tr>
           <td width="180px;">
            <span style="font-weight:bold;" >Buffer Distances </span>
           </td>
           <td width="200px;" style="padding:3px;">
           <input type="text" id="distanceIntersectFeatureBuffer" size="5" value="10" style="width:80px;" />
              <input type="text" id="distanceIntersectFeatureBuffer0" size="5" value="100" style="width:80px;"/><br/>
              <select id="unitIntersectFeatureBuffer" style="width:180px;">
                  <option value="UNIT_STATUTE_MILE">Miles</option>
                  <option value="UNIT_FOOT">Feet</option>
                  <option value="UNIT_KILOMETER">Kilometers</option>
                  <option value="UNIT_METER">Meters</option>
                  <option value="UNIT_NAUTICAL_MILE">Nautical Miles</option>
                  <option value="UNIT_US_NAUTICAL_MILE">US Nautical Miles</option>
                  <option value="UNIT_DEGREE">Degrees</option>
              </select>
             
           </td>
          </tr>
          <tr>
           <td width="180px;">
            <span style="font-weight:bold;" >Select Intersection Service </span>
           </td>
           <td width="200px;">
             <select id="FIBInterService" style="width:180px;"></select>
           </td>
          </tr>
          <tr>
           <td width="180px;">
           
           </td>
           <td width="200px;">
            <button onclick="clrGraphics(map);initFuntionalityFeatureIntersecttBuffer(map);" dojotype="dijit.form.Button">
                  Submit</button>
               <button onclick="clrGraphics(map);" dojotype="dijit.form.Button">
                   Clear</button><br />
                   <span style="font-style:italic;" >Click on Map after Submit...</span>
           </td>
          </tr>
         
          <tr>
           <td width="180px;">
            <span style="font-weight:bold;" >select Affected Layer</span>
           </td>
           <td width="200px;">
            <select id="FeatureIntersectdrpAffectedLayer" style="width:180px;"></select>
            <br />
                <button onclick="clrGraphics(map);initGetFeatureFeatureIntersectBuffer(map);" dojotype="dijit.form.Button">
                   Get Features</button>
           </td>
          </tr>
          <tr>
           <td colspan="2" ><br /><span style="font-style:italic;" id="messagesFeatureIntersect"></span>
           </td>          
          </tr>
          
    </table><div id="FeatureIntersectPost" dojotype="dijit.layout.ContentPane" title="Feature Buffer Results" ></div>
        </div>
    </div>
0 Kudos
DonCaviness
New Contributor III
Thank  you all for your help.  However the issue I was having was a simple one and it was caused by me over looking the details.  I needed to pass the distance to the geometry service as an array.  Once I did this it worked beautifully.
0 Kudos