Search code examples
htmlrshinyr-leaflet

Using leaflet on shiny with HTML ui


I am trying to plot a dynamic map with leaflet on a shiny app using an HTML interface but when i get the map it is static
When doing it the simple way using only the R interface it works fine
Is there a way of showing the map dynamically using index.html and not ui.r?

This is what I am trying to get using only the R interface

app <- shinyApp(
ui <- fluidPage(leafletOutput('myMap')),
server <- function(input, output) {
    map <- your.map
    output$myMap <- renderLeaflet(map)
}
)
 print(app)

This is my "index.html" file:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="application/shiny-singletons"></script>
<script type="application/html-dependencies">json2[2014.02.04];jquery[1.11.1];shiny[0.12.2];htmlwidgets[0.5];leaflet[0.7.3];leafletfix[1.0.0];leaflet-label[0.2.2];leaflet-binding[1.0.1.9000];bootstrap[3.3.1]</script>
<script src="shared/json2-min.js"></script>
<script src="jquery-1.11.1/jquery.min.js"></script>
<link href="shared/shiny.css" rel="stylesheet" />
<script src="shared/shiny.min.js"></script>
<script src="htmlwidgets-0.5/htmlwidgets.js"></script>
<link href="leaflet-0.7.3/leaflet.css" rel="stylesheet" />
<script src="leaflet-0.7.3/leaflet.js"></script>
<link href="leafletfix-1.0.0/leafletfix.css" rel="stylesheet" />
<link href="leaflet-label-0.2.2/leaflet.label.css" rel="stylesheet" />
<script src="leaflet-label-0.2.2/leaflet.label.js"></script>
<script src="leaflet-binding-1.0.1.9000/leaflet.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="shared/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
<script src="shared/bootstrap/js/bootstrap.min.js"></script>
<script src="shared/bootstrap/shim/html5shiv.min.js"></script>
<script src="shared/bootstrap/shim/respond.min.js"></script>

</head>
<body>
<div class="container-fluid">
<div id="myMap" style="width:100%; height:400px" class="leaflet html-widget html-widget-output"></div>
</div>
</body>
</html>

Solution

  • OK I worked it out
    Should om made my server function reactive