Hello,
I'm trying to read the x & y coordinates of selected data records in a custom widget. My data source is a layer of points. Retrieving the data attributes of the selected records works perfectly fine, but I can't figure out, how to get the points' coordinates. getGeometry() returns null. I'm using the current version (v1.5) of the developer edition. Am I missing something?
const ds = DataSourceManager.getInstance().getDataSource(
props.useDataSources[0].dataSourceId
);
ds.getSelectedRecords().map((r) => {
console.log(r.getGeometry()); // null
});
Thanks
Solved! Go to Solution.
I've figured out, what caused the issue for me.
I was using the DataSourceComponent with an empty query. Setting returnGeometry in the query solved the problem.
<DataSourceComponent
useDataSource={props.useDataSources[0]}
query={{where: '1=1',outFields: ['*'],returnGeometry: true,}}
widgetId={props.id}
>
{dataRender}
</DataSourceComponent>
I've figured out, what caused the issue for me.
I was using the DataSourceComponent with an empty query. Setting returnGeometry in the query solved the problem.
<DataSourceComponent
useDataSource={props.useDataSources[0]}
query={{where: '1=1',outFields: ['*'],returnGeometry: true,}}
widgetId={props.id}
>
{dataRender}
</DataSourceComponent>