HOW TO
When you set a filter to a FeatureLayer by calling yourFeatureLayer.setFilterObject(yourFilter) method, this will return a new Recordset which contains the selected features as per filter definition. This article explains about how to get the Bounding Envelope of the individual features as well as Global Envelope of all features from the Recordset.
Code:
yourFilter.setBoundingEnvelope(true);
yourFilter.setGlobalEnvelope(true);
Note:
You may only set Global Envelope to true and leave Bounding Envelope to a default false if you choose not to have Bounding Envelope returned in the Recordset.
Code:
int count = yourFeatureLayer.getRecordset().getCount();
Envelope globalEnvelope = yourFeatureLayer.getRecordset().getEnvelope(count);
Note:
If you did not set Bounding Envelope to true in the filter, use this code instead:
Code:
yourFeatureLayer.getRecordset().getEnvelope(0);
Code:
for (int i=0;i<fLayer.getRecordset().getCount();i++)
env [i] =fLayer.getRecordset().getEnvelope(i);
Note:
If you did not set the Bounding Envelope to true in the filter, you won't be able to get the bounding envelope as above.
Get help from ArcGIS experts
Download the Esri Support App