Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function to convert feature collection in list to geojson #197

Closed
woodwards opened this issue Sep 1, 2020 · 2 comments
Closed

Function to convert feature collection in list to geojson #197

woodwards opened this issue Sep 1, 2020 · 2 comments

Comments

@woodwards
Copy link

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
Copy link
Author

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

@trafficonese
Copy link
Owner

This seems to work well!
I have included this approach in this example:
browseURL(system.file("examples/shiny/draw-events/app.R", package = "leaflet.extras"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants