How can I zoom in finer steps in leaflet?

Viewed 1111

I plotted a map with leaflet in r. Now I'd like to create a static map. I can zoom into the map an with each step of zooming the mapscale shrinks by 2km.

How can I adjust the zoom levels so the mapscale shrinks by 1km per "zoom"?

1 Answers

zoomSnap and zoomDelta control zoom increments:

leaflet(data = NULL,
        options = leafletOptions(zoomControl = TRUE,
                                 zoomSnap = 0.25,
                                 zoomDelta = 1)) |>
  addTiles() |> 
  addMarkers(lng = 30.52418, lat = 50.44999,
             label = "#StandWithUkraine") |> 
  addScaleBar(position = "bottomright",
              options = scaleBarOptions(imperial = FALSE)) |>
  fitBounds(lng1 = 30.2989, lat1 = 50.5318,
            lng2 = 30.8249, lat2 = 50.3595)
Related