I'm building a dashboard which has a Leaflet visualisation. When an area is clicked, a rather large popup with a picture and information is displayed, as below (information is blurred because data is proprietary):
However, depending on where the user clicks on the map, the popup may be cut off, as below:
I want the popup to always be in view when the user clicks, i.e. no cutting off. Calling
popupOptions = popupOptions(keepInView = T)
seems to only work intermittently at best. I don't know much JS, so I'm not sure how to make it work.
I can't include a code example for aforementioned reasons, but the popup is called as follows:
leaflet() %>%
addPolygons(
popup = paste0(*popup content*),
popupOptions = popupOptions(keepInView = T)
)

