2

I followed the tutorial here (https://rstudio.github.io/leaflet/) and made this map:

library(leaflet)

m <- leaflet() %>%
  addTiles() %>%  # Add default OpenStreetMap map tiles
  addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R") %>% setView(174.768, -36.852, zoom = 12)

When I run this code, the map comes out like this:

enter image description here

However, I would like the map to have the "zoom out" option disabled (I would like to keep the "zoom in" option, as well as the side-to-side scroll option).

  • Is there some way that prevents the user from being abled to "zoom out" from the specified zoom level, and only allows the user to "zoom in"?

I tried:

# source: https://stackoverflow.com/questions/36365897/r-leaflet-zoomcontrol-option

m <- leaflet((options = leafletOptions(zoomControl = FALSE,
                                 minZoom = 3, maxZoom = 3,
                                 dragging = FALSE)) %>%
  addTiles() %>% 
  addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")) %>% setView(174.768, -36.852, zoom = 12)

But this gives me an error: Error in dispatch(map, method, leaflet = { : Invalid map parameter

Thank you!

0

Browse other questions tagged or ask your own question.