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

add event listener for all_features and add it to the featurelist #98

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions R/modules.R
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,16 @@ editMod <- function(
drawn = list(),
edited_all = list(),
deleted_all = list(),
finished = list()
finished = list(),
all = list()
)

recorder <- list()

EVT_DRAW <- "map_draw_new_feature"
EVT_EDIT <- "map_draw_edited_features"
EVT_DELETE <- "map_draw_deleted_features"
EVT_ALL <- "map_draw_all_features"

shiny::observeEvent(input[[EVT_DRAW]], {
featurelist$drawn <- c(featurelist$drawn, list(input[[EVT_DRAW]]))
Expand Down Expand Up @@ -211,10 +213,17 @@ editMod <- function(
featurelist$deleted_all <- c(featurelist$deleted_all, list(deleted))
})

shiny::observeEvent(input[[EVT_ALL]], {
featurelist$all <- list(input[[EVT_ALL]])
if (any(unlist(input[[EVT_ALL]]$geometry$coordinates) < -180) ||
any(unlist(input[[EVT_ALL]]$geometry$coordinates) > 180))
insane_longitude_warning()
})

# record events if record = TRUE
if(record == TRUE) {
lapply(
c(EVT_DRAW, EVT_EDIT, EVT_DELETE),
c(EVT_DRAW, EVT_EDIT, EVT_DELETE, EVT_ALL),
function(evt) {
observeEvent(input[[evt]], {
recorder <<- c(
Expand All @@ -240,7 +249,8 @@ editMod <- function(
drawn = featurelist$drawn,
edited = featurelist$edited_all,
deleted = featurelist$deleted_all,
finished = featurelist$finished
finished = featurelist$finished,
all = featurelist$all
)
# if sf argument is TRUE then convert to simple features
if(sf) {
Expand Down