Getting the geometry from a DataRecord

490
2
Jump to solution
06-23-2022 04:03 AM
MarkJTurnbull
New Contributor III

Hi All

I am building an ExB app with a custom widget.

In the widget I have a FeatureLayerDataSource with a single record in it (its actually a filtered dataview). I am trying to get the geometry of that feature but everything I tried returns null. I have traced the issue back to getting the dataRecord from the dataSource. I have tried the following commands and they all return a populated attribute object but a null geometry property for the feature object in the returned dataRecord:

dataSource.getRecord(0)

dataSource.getRecord(0) as FeatureDataRecord

dataSource.getRecords()[0]

dataSource.getRecordsWithSelection()[0]

Can someone assist me with getting the geometry from a record in a dataSource and/or can this be confirmed as a bug?

Thanks

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
YueyangLi
New Contributor II

Please make sure returnGeometry of your query params is true, and get geometry:

dataSource.getRecords()[0].getGeometry()

 

View solution in original post

2 Replies
DougLogsdon2
New Contributor III

Double-check the query parameters:

 

{
  returnGeometry: true
}

 

It defaults to false.

YueyangLi
New Contributor II

Please make sure returnGeometry of your query params is true, and get geometry:

dataSource.getRecords()[0].getGeometry()