I am trying to make a simple interactive map with the package swemaps2 but i am having trouble getting it to work and i don't know why.
This is my code so far and the data county is in the package swemaps2:
library(shiny)
library(shinydashboard)
library(swemaps2)
library(simplevis)
library(leaflet)
library(dplyr)
ui <- dashboardPage(
dashboardHeader(title = "Map dashboard test"),
dashboardSidebar(
sidebarMenu(
menuItem("Map", tabName = "map", icon = icon("globe")),
menuItem("Widgets", tabName = "widgets")
)
),
dashboardBody(
tabItems(
# First tab content
tabItem(tabName = "map",
#tags$style(type = "text/css", "#map {height: calc(100vh - 80px) !important;}"),
leafletOutput("mymap")
),
# Second tab content
tabItem(tabName = "widgets",
h2("Widgets tab content")
)
)
)
)
server <- function(input, output) {
output$mymap = renderLeaflet(
county %>%
mutate(random_number = rnorm(nrow(.), mean = 100, sd = 10)) %>%
leaf_sf_col(col_var = random_number)
)
}
shinyApp(ui, server)
The code bit:
county %>%
mutate(random_number = rnorm(nrow(.), mean = 100, sd = 10)) %>%
leaf_sf_col(col_var = random_number)
works fine outside the shiny server. My current guess is that it has something to do with the interactive part of the map but i have hit a wall in knowing where to look next. Any help would be appreciated