Skip to main content
added 28 characters in body
Source Link

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

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.

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

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

Source Link

R Leaflet - Problem Highlighting Features Underneath Layer

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.

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