0

I am encountering a problem where I can't see highlighted features underneath a transparent top layer.

I have a simple map setup, where I have a US county choropleth layer with a transparent US state layer on top. The state layer has opacity of 0 but a black outline. I am encountering a problem that when my state layer is placed on top, it is not possible to see highlighted counties underneath when hovering over with a cursor. See the linked image below.

From playing around with the code, it seems that when I comment out the state layer, I am able to see the highlighted counties underneath when hovering over with a cursor. However, I don't want to disable the state layer because it adds definition to the map.

Is there anyway to have the counties highlight on hover over, even with the state layer on top?

adult_map <- leaflet() %>%
 addPolygons(data = county_shp, 
              color = "white",
              weight = 1,
              fillOpacity = .3,
              fillColor = ~paletteNum_Adult(county_shp$adult_rate),
              highlightOptions = highlightOptions(
                color = "blue", 
                weight = 7,
                bringToFront = TRUE),
              group = "Adult") %>%
 addPolygons(data = state_shp,
              color = "black",
              weight = 3,
              fillOpacity = 0,
              group = "Adult") 

example

1
  • your code does not run, as county_shp is not provided, neither ~paletteNum_Adult. Please consider using available data, such as gadmCHE. Did you consider adding the outline-layer as addPolylines instead of addPolygons.
    – Beni
    Commented Feb 27 at 8:26

0

Browse other questions tagged or ask your own question.