StatisticsNZ / simplevis

Simple visualisation with ggplot2 and leaflet wrappers
https://StatisticsNZ.github.io/simplevis
Other
86 stars 11 forks source link

R sf point Popups inaccessible after adding polygon via simplevis #449

Closed Saadi4469 closed 2 years ago

Saadi4469 commented 2 years ago

Good day,

First of all thank you for creating this wonderful package.

I am trying to create an interactive map (using the simplevis package) to 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?

This question has also been posted here, and it would be great if you could add a tag for your package on Stackoverflow

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)
Saadi4469 commented 2 years ago

Using addPolylines instead of addPolygons fixes the popup problem.

davidhodge931 commented 2 years ago

Great :) I don't have enough stackoverflow points to add a tag