Understanding mapedit with mapview for leaflet

Hello,

Alright, I have the following simple map working in Shiny. I just want to understand the following things as it is not obvious from everything I have read so far.

My main question: After drawing a spatial polygon with 4 points that are connected and clicking finish, how can I save and retrieve that information in the background from Shiny?

Secondly: Why is the call up like this function(object()$state)@map when looking at mapview(CM_edit()$finished)@map ? It just doesn't feel intuitive at all to me. The convention is very different

library(mapedit)
library(mapview)
library(shiny)
library(leaflet)


m <- mapview()@map 
testsf = NULL
ui <- tagList(
  editModUI("test-edit", width = "100%", height = "100vh"),
  #h1("What You Draw"),
  leafletOutput("edited")
)
server <- function(input, output, session) {
  
  #callModule creates a small module
  CM_edit <- callModule(editMod, "test-edit", m, record = TRUE)

  output$edited <- renderLeaflet({
    req(CM_edit()$finished)
    mapview(CM_edit()$finished)@map
  })
}
shinyApp(ui, server)

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