Html created with Shiny tags for uiOutput different from includeHTML

I am trying to include a map from an API in my Shiny app, which uses an html page with a JavaScript script tag in the header and another one in the body.

When using an html template, saving it as an html file and then including it in a Shiny App via includeHTML("originalFile.html"), the map is displayed correctly. However, since I want the coordinates for the map to be interactive (without saving it to file in-between), I tried to create the html in a renderUI using shiny tags, and display it via uiOutput. When doing so, the JavaScript part does not seem to be processed at all. The header above the map is shown, as is the text below it, but the map is ignored without error message. Interestingly, the same happens when I replace the tag tags$head by tags$header.

Here is my app.R:


# Define UI for application that draws a histogram
ui <- fluidPage(

    # Application title
    titlePanel("Outdooractive Map"),

    # Sidebar with a text input for coordinates
            textInput ("lng",
                       value = "10.000",
                      value = "45.555")

        # Show the map 
            #includeHTML("originalFile.html") # This works
            textOutput("text"), # This shows the correct longitude/latitude
            uiOutput("map") # This seems to ignore the script

# Define server logic required to access API
server <- function(input, output) {
    output$map <- renderUI({
        lng = input$lng
        lat = input$lat
                          HTML('<meta charset="utf-8">'),
                              src = '//;key=yourtest-outdoora-ctiveapi&amp;lang=en'
                              '.oax .oax-cluster-marker-cont, .oax-cluster-marker-cont {background-color: red;}'
                    h2("Outdooractive Routes"),
                    div(class = 'oax-top-cont'),
                        'var conf = {frontendtype: "tour", zoom: 11, center:[ ', lng, ", ",  lat, ']}; var fvp = oa.api.flexviewpage( conf );')
                    HTML('There should be a map on top of me.')

    output$text <- renderText ({
        paste(input$lng, input$lat)

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

To fully replicate the example, this would be the originalFile.html (which works when line 23 in app.R is uncommented):

<!DOCTYPE html>
    <title>outdooractive platform - API Template</title>
    <meta charset="utf-8">

    <!-- load Outdooractive Javascript API -->
    <script type="text/javascript" 

      .oax .oax-cluster-marker-cont, .oax-cluster-marker-cont {
          background-color: red;

    <h2>Outdooractive Routes</h2>

    <!-- container used by FlexView API -->
    <div class="oax-top-cont"></div>

    <!-- and some lines of javascript inside a script tag -->
    <script type="text/javascript">

      var conf = {
          frontendtype:   "tour",          // choose content type
          zoom:           11,              // set initial zoom level
          center:       [ 10.292, 47.546 ] // set initial map center
      var fvp = oa.api.flexviewpage( conf );


Any pointers would be much appreciated.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.