0

I am trying to create a map with brazilians states, when I run this code in the UI file it works well. But I need to create a reactive map, so I wrote it on server file.

The map plots fine but the shape data doesnt...Any help?

 server <- shinyServer(function(session, input, output) {
    BrasilianStates <- readOGR("UFEBRASIL.shp",encoding = "UTF-8")
    output$map <- renderLeaflet

({                                                       #RENDERIZACAO DO MAPA


leaflet(data = BrasilianStates) %>% addTiles()%>%
addMarkers(data= CDDs,icon = iconeCDD, popup = nomes, clusterOptions = markerClusterOptions())%>%
addPolygons(data = BrasilianStates,weight = 2,
                        opacity = 1,
                        color = "#660000",
                        dashArray = "3",
                        fillOpacity = 0.7, highlight = highlightOptions(weight = 5, color = "#666",dashArray = "", fillOpacity = 0.7,
                                                                                                                bringToFront = TRUE)) })

When I run only in Console:

leaflet(data = BrasilianStates) %>% addTiles()%>%
addMarkers(data= CDDs,icon = iconeCDD, popup = nomes, clusterOptions = markerClusterOptions())%>%
addPolygons(data = BrasilianStates)

the plots Works perfectly in the viewer tab on the right of RStudio.

But when I try on the server file in the shiny app it doesn't render.

1 Answers1

0

I think it might be because BrasilianStates is local data. Look at this post to deploy shiny app that uses local data

i94pxoe
  • 577
  • 3
  • 11