HTML display on shiny application

Hello,

I try to insert html page (leaflet maps created with shiny widgets) in a shiny dahsboard. First, please find below code to create 3 leaflets maps :

#LEAFLET MAPS EXAMPLES
library(leaflet)
library(htmlwidgets)
rand_lng = function(n = 10) rnorm(n, -93.65, .01)
rand_lat = function(n = 10) rnorm(n, 42.0285, .01)
m = leaflet() %>% addTiles() %>% addCircles(rand_lng(50), rand_lat(50), radius = runif(50, 10, 200))
saveWidget(m, file="map_type_1.html")
m = leaflet() %>% addTiles() %>% addCircles(rand_lng(10), rand_lat(10), radius = runif(50, 10, 200))
saveWidget(m, file="map_type_2.html")
m = leaflet() %>% addTiles() %>% addCircles(rand_lng(2), rand_lat(2), radius = runif(50, 10, 200))
saveWidget(m, file="map_type_3.html")

Dynamic maps should react on user input choice, and this not the case. textOutput does not work correctly with uiOutput activated. The code of shinydashboard page here :

library(shiny)
library(shinydashboard)
#---HEADER
header <- dashboardHeader(
title = "Basic dashboard"
)#end header

#---SIDEBAR
sidebar <- dashboardSidebar(
  sidebarMenu(
      menuItem("Menu 1", tabName = "Menu1", icon = icon("comment")))
) #end sidebar

#---BODY
body <- dashboardBody(
 tabItems(

      # Tab items
      tabItem(tabName = "Menu1",h2("TITLE Menu 1"),
      sidebarPanel(width=4,h3("Choice"),
  radioButtons("choice", label = h4("Choose"),choices = list("Type 1" = "type_1","Type 2" = "type_2","Type 3" = "type_3"), selected = "type_1")      
      ),#end sidebar panel1

      sidebarPanel(width=8,h3("Dynamic map"),
      uiOutput('mymap'),#DO NOT WORK
      textOutput("selected_nam")      
      )#end sidebar panel2
      ) #end tabItem
    )#end tabItems
) #end dashboardBody


#---UI DASHBOARDPAGE----------------------------------
ui <- dashboardPage(header, sidebar, body)

#SERVER
server <- function(input, output,session) {

#DO NOT WORK
output$mymap <- renderUI({
	nam=paste0("map_",input$choice,".html")
	includeHTML(path = paste0(nam))
	})
       
output$selected_nam <- renderText({ 
	paste0("map_",input$choice,".html")
  })
  
} #end server
shinyApp(ui = ui, server = server)

Any help is welcome, Thanks,
Echoes

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.