'Openlayers: Is there a way to create a *fixed* overlay?

I am using Openlayers 3.

I am trying to display a fixed graticule showing the center of the view on a map with a popup displayed in an overlay.

I have created a custom control (by simplifying the example) which displays passively the graticule. Unfortunately, the popup appears below the graticule (ie. the popup is hidden by the graticule lines).

I want the popup to appear above the graticule (ie. the graticule lines are hidden by the popup)

It looks like the overlays and the controls are in a different stacking context.

This means that I have either to:

  • Move the popup to the control stacking context, which means that I have to move it every time the center/resolution changes, maybe by listening to change events and adjusting dynamically the popup's CSS

  • Or move the graticule to the overlay stacking context, and find a way to avoid it moving when resolution/center changes, maybe by creating a custom projection.

Any suggestions or pointers?

Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source