Frequently asked question

Can I get the geometry of a selected feature in the Recordset using Java Connector?

Last Published: April 25, 2020

Answer

Yes, set Geometry to true on Layers as shown below:

Code:
//Do not forget to set the geometry to true
map.getLayers().setGeometry(true);
FeatureLayer fLayer = (FeatureLayer)map.getLayers().item(5);
Filter filter = new Filter();
filter.setWhereExpression("NAME = 'Campbell'");
fLayer.setFilterObject(filter);
map.refresh();
//get number of geometries returned
int geometryCount = fLayer.getRecordset().getGeometryCount();
//get the geometry of first feature in recordset
Geometry geom = fLayer.getRecordset().getGeometry(0);

Article ID:000005614

Software:
  • Legacy Products

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options