0

I am building a shiny app in which I have a leafletOutput in my UI named Florida_leaflet.

In my server, I have

   my_leaflet <- reactive({


if (input$speciesSelect == "ACR CERV" & input$yearSelect == "2016")

{
  my_leaflet <- sites%>%removeLayersControl()%>% addLayersControl(
     baseGroups = c("satellite"),
     position = "topleft",
     overlayGroups = c("Florida survey sites", "FKNMS Boundary"),
     options = layersControlOptions(collapsed = FALSE))  %>%
    addCircleMarkers(data = subset(SEFCRI2014_demo_data, CORAL_CD == "ACR CERV"), group = "Florida survey sites", lat = ~LAT_DEGREES, 
     lng = ~LON_DEGREES, radius = ~6,  color = "#F0E442", stroke = FALSE, fillOpacity = 1)
}

 else {
    my_leaflet <- sites%>%removeLayersControl()%>% addLayersControl(
     baseGroups = c("satellite"),
     position = "topleft",
     overlayGroups = c("Florida survey sites", "FKNMS Boundary"),
     options = layersControlOptions(collapsed = FALSE)) 
 }
 my_leaflet

                       })

output$Florida_leaflet <- renderLeaflet(my_leaflet())

where sites is a leaflet object.

Now, when I renderLeaflet(sites), the app works fine, but running the code as above, I get the error:

Error in c: unused argument ("satellite")Stack trace (innermost first):
    105: evalAll
    104: evalFormula
    103: invokeMethod
    102: addLayersControl
    101: function_list[[k]]
    100: withVisible
     99: freduce
     98: _fseq
     97: eval
     96: eval
     95: withVisible
     94: %>%
     93: <reactive:my_leaflet> [#35]
     82: my_leaflet
     81: func
     80: origRenderFunc
     79: output$Florida_leaflet
      4: <Anonymous>
      3: do.call
      2: print.shiny.appobj
      1: <Promise>

Any ideas why this might be happening? Thanks in advance

4

0 回答 0