Turns an input$<output_id>$sketch or input$<output_id>$edits event into
an sf object. Both carry their features as Esri feature JSON, which is
what arcgisutils::parse_esri_json() reads.
Value
An sf object, or NULL when the event carried no features - a
cleared sketch, or an edit that only deleted.
Details
A drawn shape is returned in longitude/latitude, since the view draws in Web Mercator and metres are rarely what the next line of R wants. Edited features come back in the layer's own coordinate reference system, the one the data frame was sent in.
Examples
# Inside a Shiny server:
if (interactive()) {
observeEvent(input$map$sketch, {
drawn <- arc_sf(input$map$sketch)
print(sf::st_area(drawn))
})
}