Using the leaflet R package, is there a way to set zoom
to a non-integer (i.e. decimal) value?
That is, something inbetween these two zoom levels:
As zoom
moves from level 3 through to 4, it appears as though it's being rounded to the nearest integer
The only thing changing below is the zoom
parameter
library(leaflet)
library(dplyr)
leaflet() %>%
addTiles() %>%
setView(lng=174.768, lat=-36.852, zoom = 3) %>%
addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")
leaflet() %>%
addTiles() %>%
setView(lng=174.768, lat=-36.852, zoom = 3.2) %>%
addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")
leaflet() %>%
addTiles() %>%
setView(lng=174.768, lat=-36.852, zoom = 3.4) %>%
addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")
leaflet() %>%
addTiles() %>%
setView(lng=174.768, lat=-36.852, zoom = 3.6) %>%
addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")
leaflet() %>%
addTiles() %>%
setView(lng=174.768, lat=-36.852, zoom = 3.8) %>%
addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")
leaflet() %>%
addTiles() %>%
setView(lng=174.768, lat=-36.852, zoom = 4) %>%
addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")
Is there a way to set a non-integer (decimal) zoom?
Note ?setView
leads to zoom pan options, which returns a 404
You need Fractional Zoom:
var map = L.map('map', {zoomSnap: 0.25});
There is more about it here: https://leafletjs.com/examples/zoom-levels/
I use it on one of my maps like this:
var map = L.map('map', {attributionControl: false, crs: L.CRS.Simple, zoomSnap: 0.25, minZoom: -3});
...
map.setView(xy(<%= @image.width.to_i/2 %>, <%= @image.height.to_i/2 %>), -1.5);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With