rstudio / shinydashboard

Shiny Dashboarding framework
https://rstudio.github.io/shinydashboard/
Other
894 stars 298 forks source link

Sidebar icons disappearing when using awesome markers in leaflet map #339

Open fcecinati opened 4 years ago

fcecinati commented 4 years ago

I am using awesome markers with leaflet in a dashboard shiny app. When the app loads, the sidebar tab icons from Font Awesome are rendering correctly. However, once the awesome markers are loaded the tab icons disappear. Leaflet awesome markers are using Font Awesome icons as well. Note that not all icons disappear. The problem doesnot occur using normal markers in Leaflet or awesome markers with other libraries. Here I include two snapshots of the behaviour, a reproducible example (you may need to adjust the number of points to create sufficient delay), and my session info: image image

library(tidyverse)
library(magrittr)
library(shiny)
library(shinydashboard)
library(shinyWidgets)
library(shinycssloaders)
library(shinydashboardPlus)
library(leaflet)
library(leaflet.extras)
library(sf)
library(sp)

points <- tibble(ID=c(1:2000),
                 Lat=53+runif(2000, 0, 1),
                 Lon=runif(2000, 0, 1))

points %<>%
    st_as_sf(coords=c('Lon', 'Lat'), crs=4326)

# Define UI
ui <- dashboardPage(

    dashboardHeader(title = "App"),

    dashboardSidebar(
        sidebarMenu(
            menuItem("Map", tabName = "Map", icon = icon("map-marked-alt", lib="font-awesome")),
            menuItem("Other tab", tabName = "Other", icon = icon("volume-up", lib="font-awesome")),
            menuItem("Third tab", tabName = "Third", icon = icon("file-medical-alt", lib="font-awesome"))
        )
    ),

    dashboardBody(
        tabItems(
            tabItem(
                tabName = "Map",
                # Map box
                boxPlus(width=12,
                        height=800,
                        status='warning',
                        withSpinner(leafletOutput("Network", height = 750))
                        )
                )
            )
        )
)

server <- function(input, output) {

    # Calculate bounding box
    bb <- reactive({
        points %>%
            as(., 'Spatial') %>%
            .@bbox %>%
            unname
    })

    # Map
    output$Network <- renderLeaflet({

        Icon <- awesomeIcons(icon = 'circle', iconColor = 'black', library = 'fa', markerColor = 'lightgreen')
        leaflet(options = providerTileOptions(minZoom = 1, maxZoom = 32)) %>%
            addTiles() %>% 
            addAwesomeMarkers(data=points, icon=Icon, label=~ID, layerId=~ID) %>%
            fitBounds(lng1=bb()[1,1], lat1=bb()[2,1], lng2=bb()[1,2], lat2=bb()[2,2])
    })
}

# Run the application 
shinyApp(ui = ui, server = server)

image

woodwards commented 4 years ago

I am having the same problem.

Workaround was to use icons from a different library (glyphicon) in place of the (fa) ones that were disappearing.

etiennecampione commented 4 years ago

Same problem too.

ronaldoalves-ms commented 3 years ago

Me too

earnaud commented 2 years ago

Same here, the red box is supposed to have a trash icon. image