2

i want to disable zooming on my leaflet map in R while having the mouse hover over it.

I tried the suspendScroll(hoverToWake = FALSE) function from the leaflet.extras package as well as leaflet(options = leafletOptions(scrollWheelZoom = FALSE)), but both not working.

leaflet(width = "100%") %>%
  setView(0, 0, 1) %>%
  addTiles() %>%
  suspendScroll(hoverToWake = FALSE)

The map is still zooming in and out when i hover the mouse over it and start scrolling. Am i the only one having this problem? My R Version is 3.6.1

alxlives
  • 5,084
  • 4
  • 28
  • 50
VSZ
  • 21
  • 1
  • unfotunatly not, because it is only working like this when using leaflet javascript, i am using leaflet in R – VSZ Sep 25 '19 at 07:53

1 Answers1

2

If you want to disable all zooming, you can set the minZoom and maxZoom to the same number as the zoom in setView. Like this reproducible example:

map <- leaflet(options = leafletOptions(minZoom = 10, maxZoom = 10)) %>% 
addTiles() %>% 
setView(lng = 7.35, lat = 50.05, zoom = 10)
map
Laura Siepman
  • 76
  • 1
  • 4