leaflet icon indicating copy to clipboard operation
leaflet copied to clipboard

Use of 'white' iconColor results in black awesomeIcons

Open atlight opened this issue 5 months ago • 0 comments

The use of the string 'white' as the iconColor for awesomeIcons results in black icons being displayed

library(shiny)
library(leaflet)

d <- data.frame(x=c(2, 3), y=c(7, 2))

ui <- leafletOutput('mymap')

server <- function(input, output, session) {
  output$mymap <- renderLeaflet({
    leaflet(d) %>% 
      addAwesomeMarkers(lng=~x, lat=~y,
                        icon=~awesomeIcons(library='fa',
                                           icon='plus-square',
                                           iconColor='white',
                                           markerColor='blue'))
  })
}

shinyApp(ui, server)

image

The issue is specific to the string 'white'. The equivalent hex code, '#ffffff', results in a white icon.

There is some special-casing of 'white' at https://github.com/rstudio/leaflet/blob/9bf137b8f58d62a199e1eceb906f5b705030b75a/inst/htmlwidgets/plugins/Leaflet.awesome-markers/leaflet.awesome-markers.js#L78-L84 which may be to blame.

atlight avatar Sep 05 '24 06:09 atlight