Mides
Mides

Reputation: 39

How to fix popup position?

In this example how to fix popup position when I zoom ?

Popup example

Before zoom After zomm

Upvotes: 0

Views: 1702

Answers (1)

Alvin Lindstam
Alvin Lindstam

Reputation: 3142

The popup (an ol.Overlay) is already fixed to a given coordinate, the one you click. When zoomed, the visual distance between the popup and the marker changes but they are still at their given coordinates.

If you don't want two objects to move apart when zoomed in, make sure that they are positioned on the same coordinates.

You can set the clicked features coordinates as the overlay coordinates, and still show it X number of pixels above the point by using the offset option on the overlay.

Upvotes: 1

Related Questions