editMod to change geometries made up in the past - mapedit r package

Hi everyone,

I would like to figure out how to use editMod (Shiny modules present in mapedit package) to edit a set of polygons already that are already present in the app or that are called from a database.

That is, I would like to allow the user to be able to edit polygons already in the app or delete them or add more.

I will attach the r code that i am using.
Thanks in advance for everyone who will help me solve this problem.

library(shiny)
library(mapview)
library(mapedit)
library(leafem)
library(sf)

ui <- fluidPage(
    
    editModUI("editMod_UI"),
    actionButton("save_polygons",
                 label="Save the modified polygons"),
    mapviewOutput(outputId = "new_polygons")
    
)

server <- function(input, output) {
    
    franconia<-franconia
    
    edits <- callModule(editMod, 
                        "editMod_UI", 
                        leaflet() %>% addFeatures(franconia))
    
    observeEvent(input$save_polygons, {
        
        polygon<-edits()$finished
        
        polygon<-st_as_sf(polygon)
        
        output$new_polygons<-renderMapview({
            mapview(polygon)
        })
        
    })
}

shinyApp(ui = ui, server = server)

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.