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

Mouse events are shifted after a css transform scale on the map container #1160

Closed
nedasoo opened this issue Apr 3, 2022 · 6 comments · Fixed by #3437
Closed

Mouse events are shifted after a css transform scale on the map container #1160

nedasoo opened this issue Apr 3, 2022 · 6 comments · Fixed by #3437
Labels
bug Something isn't working PR is more than welcomed Extra attention is needed

Comments

@nedasoo
Copy link

nedasoo commented Apr 3, 2022

maplibre-gl-js version: 2.1.7

browser: Google Chrome 100.0.4896.60

Steps to Trigger Behavior

1.Create a map
2. Downscale the map container (Set transform:scale(0.8))
3. Use map.resize() to update the canvas.

Link to Demonstration

Here is an example with a downscaled map (since the scale was set initially, no need for map.resize() )
https://jsfiddle.net/bjwtcqo6/

Expected Behavior

All mouse events should match the updated map.

Actual Behavior

All mouse events are shifted.

@DaveHeng
Copy link

solution:

.map {
    width: calc(100% * 0.8);
    height: calc(100% * 0.8);
    position: absolute;
    transform: translate(-50%, -50%) scale(calc(1 / 0.8));
    transform-origin: center center;
    top: 50%;
    left: 50%;
  }

@HarelM HarelM added bug Something isn't working PR is more than welcomed Extra attention is needed labels Aug 21, 2022
@divlek
Copy link

divlek commented Nov 14, 2022

We are facing the same issue when the parent container has a transform scale applied. Here is a jsfiddle showing the issue with the parent map container with transform:scale(1.5) applied. Mouse over on choropleth feature highlights a different feature with scale.

Wondering if any possible workaround (tried the suggestion above, didnt work) for this issue or any potential ETA for the bug fix? Appreciate any input. Thanks!

@thehoneymad
Copy link

@HarelM, @louwers this is a blocker for AWS to migrate a service to MapLibre. :) Any chance we can prioritize this?

@louwers
Copy link
Collaborator

louwers commented Mar 15, 2023

@HarelM, @louwers this is a blocker for AWS to migrate a service to MapLibre. :) Any chance we can prioritize this?

@thehoneymad I am maintainer for Native, not JS. In general I can say that only fixing cricical bugs is within the responsibilities of us maintainers. And since we do not manage a team it is hard for us to prioritize anything aside from calling attention to it.

@IvanSanchez
Copy link
Contributor

@thehoneymad Sounds like you might want to convince @HarelM to assign a bounty here.

@wipfli
Copy link
Contributor

wipfli commented Mar 15, 2023

You are right @IvanSanchez that Bounties can be a good tool for fixing bug. However, we have to make sure that the work falls within one of the Bounty directions (https://github.com/maplibre/maplibre/issues?q=is%3Aissue+is%3Aopen+label%3A%22bounty+direction%22) which are approved by the MapLibre Governing Board. I am not sure if the ticket here is aligned with one of the Bounty directions, so at the moment we probably cannot assign a Bounty here.

IvanSanchez added a commit to IvanSanchez/maplibre-gl-js that referenced this issue Mar 15, 2023
This **partially** fixes maplibre#1160, by using an adaptation of Leaflet's
`L.DOMUtil.getMousePosition()`.

The `DOM.touchPos()` static method should still display the bug.

Signed-off-by: Iván Sánchez Ortega <[email protected]>
IvanSanchez added a commit to IvanSanchez/maplibre-gl-js that referenced this issue Mar 15, 2023
This **partially** fixes maplibre#1160, by using an adaptation of Leaflet's
`L.DOMEvent.getMousePosition()`.

The `DOM.touchPos()` static method should still display the bug.

Signed-off-by: Iván Sánchez Ortega <[email protected]>
IvanSanchez added a commit to IvanSanchez/maplibre-gl-js that referenced this issue Mar 15, 2023
This **partially** fixes maplibre#1160, by using an adaptation of Leaflet's
`L.DOMEvent.getMousePosition()`.

The `DOM.touchPos()` static method should still display the bug.

Signed-off-by: Iván Sánchez Ortega <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working PR is more than welcomed Extra attention is needed
Projects
None yet
8 participants