Sample height/altitude/dtm/terrain under a cursor

Hi all,

I would like to show the user the altitude of the point that is under the cursor.

Currently I call a REST API to get the altitude from a DTM Raster file in COG format, using gdal in server side.

The problem that it creates endless calls to that API as users move their cursors over the globe.

I guess I could think about a solution that the client will fetch DTM tiles from some overview based on the zoom level and cache them, instead of fetching individual pixels. Did anyone implemented something like that or another solution?

I’ve read about the option to use sampleTerrain,

I haven’t tried it yet, but I prefer to use the same DTM dataset model that I use for other calculations and not to have another model for sampling altitude.

Any pointers are welcome. Thanks!