1

Following the guidance of TimSalabim I separated the borders and fill of my neighbourhood polygons so that I could order them appropriately with zIndex.

https://lawsblog.netlify.com/post/leaflet-map/

Now if I place the highlightOptions() function within the addPolygons(neighbourhood fill) function I don't know how to increase the border of the polygon.

If I place the highlightOptions() function within the addPolylines(neighbourhood border) function I can CAREFULLY mouse over just the border and its width increases.

So now that I've separated the fill and borders of the polygons how do I increase the border width when I mouseover the fill area?

# Add hood borders
  addPolylines(data = borders, 
               color = "white",
               opacity = 1, 
               weight = 2,
               options = pathOptions(pane = "hood_borders")) %>% 

 # Add hood fill
  addPolygons(data = hood_shp,
              fillColor = ~pal(be_per_cap),
              fillOpacity = 1.0,
              color = NA,
              options = pathOptions(pane = "hoods",

              # Highlight neighbourhoods upon mouseover - NOT CORRECT
              highlight = highlightOptions(
                          stroke = 4),

              # Add label info when mouseover
              label = labels,
              labelOptions = labelOptions(
                style = list("font-weight" = "normal", padding = "3px 8px"),
                textsize = "15px",
                direction = "auto")))

1 Answer 1

1

I think if you add weight argument to your highlightOptions(), the border width should change on hover. For example:

 addPolygons( 
   ...
   highlightOptions = highlightOptions(stroke = 4, weight = 2),
   ...)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.