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

Allow setting opacity of popup when behind surface #5079

Open
kamil-sienkiewicz-asi opened this issue Nov 20, 2024 · 5 comments
Open

Allow setting opacity of popup when behind surface #5079

kamil-sienkiewicz-asi opened this issue Nov 20, 2024 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers PR is more than welcomed Extra attention is needed

Comments

@kamil-sienkiewicz-asi
Copy link
Contributor

maplibre-gl-js version: 5.0.0-pre.6

browser: Google chrome Version 130.0.6723.117 (Official Build) (arm64)

Steps to Trigger Behaviour

  1. Add popup
  2. Rotate globe so popup is behind sphere

Link to Demonstration

https://jsbin.com/xihuyikuxo/3/edit?html,css,output

Expected Behaviour

Popup is hidden when its behind the globe (?) Maybe it's a conscious decision that it shouldn't be hidden, but maybe adding some boolean value to popup config indicating if popup should respect globe (should hide) would be nice addition?

@HarelM HarelM added bug Something isn't working PR is more than welcomed Extra attention is needed globe Globe related issues labels Nov 20, 2024
@HarelM
Copy link
Collaborator

HarelM commented Nov 20, 2024

Thanks for taking the time to report this.
This should be an easy fix like it was with the terrain I suppose.

@HarelM HarelM added good first issue Good for newcomers enhancement New feature or request and removed bug Something isn't working labels Nov 20, 2024
@HarelM
Copy link
Collaborator

HarelM commented Nov 20, 2024

The current logic for both terrain and globe view is that the marker get the relevant opacity and the popup that is assigned to it gets closed in case of occlusion.

So I think that in case you would like to have something react to the globe you should you a marker instead of a popup, will this solve your issue?

@HarelM HarelM added the need more info Further information is requested label Nov 20, 2024
@HarelM
Copy link
Collaborator

HarelM commented Nov 20, 2024

BTW, as a work around, you can do the following (this uses internal knowledge of how things are build, so this shouldn't be used as is if you don't want it to break in the future):

    map.on('move', () => {
        if (map.transform.isLocationOccluded(popup.getLngLat())) {
            popup._container.style.opacity = "0.2";
        } else {
            popup._container.style.opacity = "1";
        }
    });

@kamil-sienkiewicz-asi
Copy link
Contributor Author

Thanks for the workaround!

I've never used marker before so I'm not exactly sure what's the difference, marker is an icon on map that will react to click and spawn new popup anchored to it? Where popup is just a standalone HTML container?
In my case I want to display popup when clicking on polygons, lines, symbols etc. I don't want a visible marker on map.

Nevertheless, wouldn't hiding popup behind the globe be nice addition to popup logic? (maybe allow to opt out of such logic if for whatever reason someone would like to render popup when it's behind the globe) WDYT

@HarelM
Copy link
Collaborator

HarelM commented Nov 21, 2024

A marker can be any HTML element you might need.
It's a question if we want to duplicate the logic from marker to popup, I honestly don't know.
If you want to champion this, feel free to do so. :-)

@HarelM HarelM changed the title Popup is not hidden behind globe Allow setting opacity of popup when behind surface Nov 21, 2024
@HarelM HarelM removed need more info Further information is requested globe Globe related issues labels Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers PR is more than welcomed Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants