Select to view content in your preferred language

Getting the geometry from a DataRecord

1100
4
Jump to solution
06-23-2022 04:03 AM
Labels (1)
MarkJTurnbull
Regular Contributor

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
Esri Contributor

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

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

 

View solution in original post

4 Replies
DougLogsdon2
Regular Contributor

Double-check the query parameters:

 

{
  returnGeometry: true
}

 

It defaults to false.

YueyangLi
Esri Contributor

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

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

 

tzhaigeo
Emerging Contributor

There is a problem with .getGeometry(), that is: it does NOT return the Z and M values! I don't see any documentation specifying where we can set: returnZ: true and/or returnM: true.

Please advise.

0 Kudos
YueyangLi
Esri Contributor

Hi @tzhaigeo, please use the returnZ and returnM in your query parameters. We don't doc it, but it should support using these two parameters.

0 Kudos