When the zoom value is not an integer and the dl.TileLayer is updated via callback the initial tiles requests are wrong and therefore failing. The URL for these requests is using the zoom value instead of it corresponding zoom level, which should be the closest integer.
The zoom value shouldn't be used to build the tiles requests in any case as these requests are incorrect. It's closest zoom level should be used instead.
Description
When the
zoom
value is not an integer and thedl.TileLayer
is updated via callback the initial tiles requests are wrong and therefore failing. The URL for these requests is using thezoom
value instead of it corresponding zoom level, which should be the closest integer.For example, if the
zoom
is set to17.5
and thechildren
prop is updated via callback to a differentdl.TileLayer
the first requests would be https://b.tile.openstreetmap.org/17.5/52778/63857.png (which is shows an invalid tile error) when it should instead be https://b.tile.openstreetmap.org/18/52778/63857.pngAfter these failed requests if the
zoom
value changes it then generates the correct URLs for the tiles requests.Reproduce the bug running the code below:
Scenario 1: before changing
zoom
valuedl.TileLayer
center
coordinatesScenario 2: using
zoomControl
tooltip to have integerzoom
valueszoomControl
tooltip. (Nowzoom
value will be equal to 18 and any zoom in/out using this control will be an integer value)dl.TileLayer
Demo
https://github.com/emilhe/dash-leaflet/assets/35932204/3e1489fe-d519-4ec9-81f9-2485e92b2d0c
Expected result
The
zoom
value shouldn't be used to build the tiles requests in any case as these requests are incorrect. It's closest zoom level should be used instead.