leaflet.extras icon indicating copy to clipboard operation
leaflet.extras copied to clipboard

Function to convert feature collection in list to geojson

Open woodwards opened this issue 3 years ago • 1 comments

I am using addDrawToolbar to draw polygons on my leaflet("map"), and then I want to capture them (ideally to sf) using input$map_draw_all_features.

However it seems the returned list is not compatible with geojson_list. Am I doing something wrong or is this a "feature request"?

Thanks so much for this excellent tool(bar).

data <- input$map_draw_all_features # list
data <- geojson_list(data)
data <- geojson_sf(data)

woodwards avatar Sep 01 '20 04:09 woodwards

This seems to work? I'll test it more.

data <- input$map_draw_all_features # list
data <- jsonlite::toJSON(data, auto_unbox = TRUE) # string
data <- geojsonio::geojson_sf(data) # sf

woodwards avatar Sep 01 '20 04:09 woodwards