Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tooltip dynamic top/bottom position #7230

Open
artemgafarov666 opened this issue Aug 4, 2020 · 1 comment
Open

Tooltip dynamic top/bottom position #7230

artemgafarov666 opened this issue Aug 4, 2020 · 1 comment
Labels

Comments

@artemgafarov666
Copy link

Hello! How to make it possible will dynamically switch tooltip between top and bottom according to the tooltip position on the map? Now this opportunity is only for left and right.

@Malvoz Malvoz added the feature label Apr 7, 2022
@tanthammar
Copy link

tanthammar commented Sep 13, 2023

You can add a function that updates the tooltip position if you have the layer

updateLayerTooltipDirection(layer) {
         if ('getTooltip' in layer) {
                const options = layer.getTooltip()?.options
                if (options) {
                    options.direction = layer.tooltipDirection
                    layer.bindTooltip(layer.tooltip, options)
                }
            }
        },

Example from an Alpine.js component showing the concept

<select 
    x-model="label.tooltipDirection"
    x-on:change="updateLayerTooltipDirection(label)"
>
    <option value="top">Top</option>
    <option value="right">Right</option>
    <option value="bottom">Bottom</option>
    <option value="left">Left</option>
</select>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants