Select to view content in your preferred language

Clean way to put custom UI on the map at specific map point?

270
2
08-07-2024 06:29 AM
D_R_
by
Occasional Contributor

Sorry for using another lib as example but my goal is to create something like this: https://openlayers.org/en/latest/examples/overlay.html

My goal is to place html div on the map so that it stays at the same position when map zooms/pans...

Does SDK have this functionality natively? In the same spirit like Spinner widget stays at provided point when you add it and pan map? Couldn't find that at first glance, maybe it is buried somewhere..

0 Kudos
2 Replies
ReneRubalcava
Honored Contributor

Not specific to it, but you could do something like that manually.

Views have a toScreen() method that converts map coordinates to screen coordinates.

https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#toScreen

And a toMap to turn screen coords to map coords.

https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#methods-summar...

You can then use reactiveUtils to watch some view property like interacting, maybe navigating to know when the map is being panned/zoomed and update the elements location.

https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#interacting

 

D_R_
by
Occasional Contributor

Thank you! It was my plan B to do that actually 🙂