Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

R sf point Popups inaccessible after adding polygon via simplevis

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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)

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading