leaflet in shiny error message
Thank you ?kos! It works! Have a great day! Basile. Sent with ProtonMail Secure Email. ??????? Original Message ???????
On Monday 3 January 2022 09:22, Bede-Fazekas ?kos <bfalevlist at gmail.com> wrote:
Dear Basile, the %>% operator is accidentally commented out! Change fillOpacity = 0.7)#%>% to fillOpacity = 0.7) %>% and then setView() will get its first parameter called "map". HTH, ?kos Bede-Fazekas Centre for Ecological Research, Hungary 2022.01.03. 1:49 keltez?ssel, basile.lenormand via R-sig-Geo ?rta:
Hello everyone!
I am trying to create a shiny app with leaflet stuff in it. I have a problem when I am displaying the application, I got this error message :
"Error in dispatch: argument "map" is missing, with no default".
I searched some clues on the net, I found some examples which are working but I do not get where I going wrong. I double checked the brackets, try to change the name of the map, put the name of the spatial data frame that I am using, etc.
If someone can give me some clues I will be really glad.
Have a great day,
thank you for your time,
Basile.
Here is my code:
ui <- fluidPage(
titlePanel(""),
sidebarLayout(
sidebarPanel(
helpText(""),
selectInput("var",
label = "Choose a variable to display",
choices = spdf$koppen,
selected = ""
),
sliderInput("range", "surface br?l?e en hectare", min(spdf$V11), max(spdf$V11),
value = range(df$V11), step = 2500
),
sliderInput("range", "Nombre d'incendie", min(spdf$n), max(spdf$n),
value = range(df$V11), step = 2
),
checkboxInput("legend", "Show legend", TRUE)),
mainPanel(leafletOutput("map"))
)
)
server <- function(input, output, session) {
output$map <- renderLeaflet({
leaflet(df) %>%
addTiles(group = "OSM") %>%
addProviderTiles("Esri.NatGeoWorldMap", group="ESRI") %>%
addProviderTiles("CartoDB.DarkMatter", group= "CartoDB") %>%
#fitBounds(~min(long), ~min(lat), ~max(long), ~max(lat))%>%
addPolygons(
data=spdf,
fillColor = "viridis",
weight = 0,
opacity = 1,
color = "white",
dashArray = "3",
fillOpacity = 0.7)#%>%
setView(lat= 44.2, lng=5.9, zoom=5)
})
}
shinyApp(ui, server)
Sent with ProtonMail Secure Email.
[[alternative HTML version deleted]]
R-sig-Geo mailing list
R-sig-Geo at r-project.org
R-sig-Geo mailing list R-sig-Geo at r-project.org