Feature Layer not returning geometry Extent of Selected Feature

1249
3
04-08-2013 11:46 PM
VishakhaDubey
New Contributor II
Hi Everyone

I am using an ArcGIS rest service in my map. I want to zoom to the feature selected by user. Although I have set returngeometry = "true" I am not able to get the extent of selected feature. The extent returned in the application is null. But when querying directly on the layer i.e. not from the application geometry points are returned. The features are being selected from a combo box. The service I am using is using a gdb and has a related table too. Can anyone suggest something.
0 Kudos
3 Replies
JanJeske
New Contributor III
Can you post the explained code please
0 Kudos
VishakhaDubey
New Contributor II
Heer is the function that is called on the onchange event of combobox.
function zoomToPst(item)
{

        var id;
        var psname=item.value.toString();
        var selectedTaxLot;
       // alert("acname" + acname);
       var queryTask1 = new esri.tasks.QueryTask
                ("http://mrsac.maharashtra.gov.in/ArcGIS/rest/services/MRSACServices/election/MapServer/0");

       var symbol = new esri.symbol.PictureMarkerSymbol({
          "angle":0,
          "xoffset":0,
          "yoffset":10,
          "type":"esriPMS",
          "url":"http://static.arcgis.com/images/Symbols/Shapes/BluePin1LargeB.png",
          "contentType":"image/png",
          "width":24,
          "height":24
        });

       var query1 = new esri.tasks.Query();
       query1.returnGeometry = true;
       query1.outFields = ["OBJECTID"];
       query1.where = "District= 'Nagpur' and AC_Name='"+ddl1+"' and PopupInfo='"+psname+"' ";
       //alert("qry rdy");
       alert(""+"District= 'Nagpur' and AC_Name='"+ddl1+"' and PopupInfo='"+psname+"' ");
       queryTask1.execute(query1,function(results)
       {
           var zone;
            var values = [];
            var testVals={};
            //alert("in exe qry");
            //Add option to display all zoning types to the ComboBox
            values.push({name:"ALL"})

            //Loop through the QueryTask results and populate an array
            //with the unique values
            var features = results.features;
            
            dojo.forEach (features, function(feature) {
              id=feature.attributes.OBJECTID;
        });
       
        alert("id"+id);
        dojo.forEach(map.graphics.graphics,function(graphic)
        {
           if(graphic.attributes)
            {
                alert("gid"+graphic.attributes.OBJECTID);
                if(graphic.attributes.OBJECTID === id)
                {
                    selectedTaxLot = graphic;
                    alert("slct");
                    return ;
                }
            }
        });
        alert("sext"+selectedTaxLot.geometry.getExtent())
        var taxLotExtent = selectedTaxLot.geometry.getExtent();
        map.setExtent(taxLotExtent);
       });
}
0 Kudos
JohnGravois
Frequent Contributor
when querying directly on the layer i.e. not from the application geometry points are returned


do you mean that the geometry type for this layer is point?  if so, getExtent() is expected to return null, because only polyline, polygon and multipoint geometries have a precalculated extent.

as an alternative, you should be able to construct your own extent object using the point geometry of the feature instead (by adding and subtracting fixed values).
0 Kudos