I'm building a map tool in R using leaflet, and I would like to restrict the zoom to a certain area, but the setMaxBounds
function doesn't seem to have any effect.
library(dplyr)
library(leaflet)
library(tigris)
ohio_map <- leaflet(counties('OH', cb = TRUE)) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(weight = .3,
color = "#229922",
layerId = ~NAME) %>%
setMaxBounds(lng1 = -84.800,
lat1 = 42.000,
lng2 = -80.500,
lat2 = 38.400)
ohio_map
This shows the right area of the map, but doesn't prevent zooming out.
It would be even better to remove the zoom controls altogether, so that I could replace the navigation with something more suitable to the application at hand. I found a zoomControl option, but haven't been able to figure out where to put that in R to get it to work.
EDIT: As pointed out by @Symbolix, setMaxBounds really is something different than what I'm looking for. I really just want to disable zooming altogether, and remove the controls. The zoomControl option described in the leaflet JavaScript API docs appears to be what I want, but I cannot find that option in the R package.