emilhe / dash-leaflet

MIT License
214 stars 40 forks source link

Add custom redraw method for TileLayer #242

Closed Farkites closed 1 month ago

Farkites commented 5 months ago

Description

Adds custom redraw method to TileLayer to round Zoom levels and fix the issue #236

This fix is a workaround suggested in this comment by Leaflet.js maintainers.

Test fix:

emilhe commented 4 months ago

Could you elaborate on what the code is doing? Apart from the fix copied from https://github.com/Leaflet/Leaflet/pull/8613, I am not sure why the rest is needed. I tried your example using just that code ( implemented in https://github.com/emilhe/dash-leaflet/pull/244), and it seems to work as intended. I have pushed the build as dash-leaflet==1.0.16rc3. Could you check if it works as intended, or if there are edge cases not covered?

Farkites commented 4 months ago

Thanks for reviewing @emilhe! I have checked your implementation in #244 and it works exactly as expected both for #236 and for the issue in dash-cytoscape with the cytoscape + leaflet all in one component.

Apologies for the confusing code, I run into some issues overwriting the redraw() function that lead me to this rather convoluted logic. With my initial approach the redraw function was being called in an infinite loop, probably due to the adding and removing layers to useMap that was calling the redraw again, so I had to add the redrawNeeded state.

Your implementation is also clearer than mine and I haven't found any edge cases not covered. So I'm very happy to proceed with your approach and close this PR.

emilhe commented 1 month ago

Obsolete after merging https://github.com/emilhe/dash-leaflet/pull/244