I am trying to create an interactive
map (using the simplevis
and leaflet
packages) to be used in an RMarkdown
HTML
presentation
. The popups work fine when no polygon is added but as soon as the polygon is added the popups can no longer be accessed.
The purpose is to have popups for the sf point data and to only show the legend of the point data. The polygon is added to show the boundries.
How can I fix this?
Sample data and code
library(sf)
library(leaflet)
library(simplevis)
leaf_sf_col(example_point,
col_var = trend_category,
popup = TRUE) %>%
leaflet::addPolygons(data = sf::st_transform(example_borders, 4326),
color = "#35B779",
weight = 3,
fillOpacity = 0,
opacity = 1)
CodePudding user response:
Use addPolylines
instead of addPolygons
, then the polygon feature won't be capturing the click events (which is what I think is happening) because its only lines instead of an area-covering polygon.