I am using R, RStudio and the leaflet package to visualise a map.
I would like to get the the min and max lat-longs of of the bounding box of a leaflet object. I think this can be done using Shiny (by using something like input$mapobj_bounds) but is there a non-shiny method to do this.
m <- leaflet(width=500,height=400) %>%
addTiles() %>%
setView(lng = -0.106831, lat = 51.515328, zoom = 18) %>%
addCircleMarkers(lng = -0.106831, lat = 51.515328)
What i need is a function to get the bounding box using the input argument m.
Can this be done?
Also, the parameter values when looking into the object m look incorrect.
e.g.
> m$x$limits
$lat
[1] 51.51533 51.51533
$lng
[1] -0.106831 -0.106831
EDIT
I think the javascript function map.getBounds() may be of help here...as suggested here (Get the bounding box of the visible leaflet map?), but do not know how to apply this to our problem. Any help on this would be much appreciated.