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

Problem with rotation and heatmap #58

Open
tomasmalioesnaola opened this issue Sep 23, 2024 · 1 comment
Open

Problem with rotation and heatmap #58

tomasmalioesnaola opened this issue Sep 23, 2024 · 1 comment

Comments

@tomasmalioesnaola
Copy link

I'm having problems with the rotated map and the heatmap.
When I load them, the heatmap is very bad, it positions me in the place where it is not rotated and when I zoom in it breaks.

Has anyone had this happen to them and managed to get it working?

Thank you all, best regards.

@gagwithgaffer
Copy link

gagwithgaffer commented Oct 4, 2024

I'm experienceing the same issue, I am seeing this with both heatmap libraries:

A more detailed description of my own oberservations so far:

If I rotate the map clockwise, say 10 degree as an example, if i then pan (move) the map a notch or zoom in or out just one step, on this this first interaction I see that the heatmap data rotates around by 10 degress on the same axis and direction as the previous rotation.

In essence when the map rotates, the heatmap correctly follows that rotation, but the problem arises when the map is panned or zoomed—it unnecessarily re-applies the previous rotation.

Here’s what might be happening:

  • Map rotation and heatmap: When the map rotates, the heatmap rotates correctly. However, on subsequent interactions like panning or zooming, Leaflet may be triggering an additional transformation on the heatmap.
  • Heatmap.js does not handle map rotations natively. So, after the rotation is applied by Leaflet, each subsequent map action (like pan or zoom) triggers a re-rendering of the heatmap, including a re-application of the previous rotation.

Potential Fix:
What we need to do is stop the heatmap from re-rotating after the initial rotation. This might be done by ensuring that when the map is rotated, the heatmap "locks" into place and does not rotate further when panning or zooming.

Possible Solution Steps: (im still working on this part...)

  1. Track the rotation: Listen for the map's rotate event, and store the rotation value.
  2. Disable re-rotation: On subsequent move or zoom events, ensure the heatmap doesn't re-apply the stored rotation.
  3. Force re-render: After the rotation is complete, force the heatmap to re-render only once and keep that orientation, without rotating again.

The challenge in achieving the above is we still want the heatmap data to follow the correct positioning of the map tiles which will continue to change as we do further panning/zoomingIN/ZoomingOUT actions, we just dont want the heatmap data to continue rotating around on the axis based upon the value of the previous rotation step.

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

No branches or pull requests

2 participants