-
Notifications
You must be signed in to change notification settings - Fork 33
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
version 0.6 combining changes from multiple pull requests #107
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Previously, some of that logic was in `editMod()` and some (the part that conditionally set `allowSelfIntersection = FALSE` for 2-D features) was in `editFeatures.sf()`. Migrating this logic involved one complication. Whereas in `editFeatures.sf()` one can directly query the `sf` object being edited for its dimension, in the farther downstream `editMod()`, that object is no longer available. By then, the `sf` object has been processed (in `editFeatures.sf()`) by `leafem::addFeatures()` which adds the features to the map object. As a result, in `editMod()`, I now test for the presence of calls to `addPolylines()` or `addPolygons()` among the `methods` elements in `leafmap$x$calls`. I believe that covers all of the possibilities that were formerly caught by `if(any(sf::st_dimension(x) == 2))`, but I have not exhaustively tested this. This commit also replaces repeated use of `editor[1]` with an equivalent but clearer initial call to `editor <- match.arg(editor)`.
The new `editOptions=` argument takes a user-supplied list of named options that are ultimately passed on to either `leafpm::addPmToolbar()` or `leaflet.extras::addDrawToolbar()`, depending on the value of the `editor=` argument. When `editor = "leafpm"`, the list can consist of one or more elements with names `"toolbarOptions"`, `"drawOptions"`, `"editOptions"`, and `"cutOptions"`. For details, see `?leafpm::addPmToolbar`. When `editor = "leaflet.extras"`, allowable names for list elements are `"polylineOptions`, `"polygonOptions"`, `"circleOptions"`, `"rectangleOptions"`, `"makerOptions"`, `"circleMarkerOptions"`, and `"editOptions"`. For details, see `?leaflet.extras::addDrawToolbar`. Currently, there is no checking or validation of the list passed in to `editorOptions=`, so users will need to take particular care that the list's structure (including the names of all of its elements) match with what is expected by the `leafpm::addPmToolbar()` or `leaflet.extras::addDrawToolbar()` functions. Here are few simple examples demonstrating the new argument's usage: ```r library(sf) library(mapedit) x <- list(matrix(c(11,0,11,1,12,1,12,0,11,0), ncol = 2, byrow = TRUE)) pp <- st_sf(geom = st_sfc(st_polygon(x)), crs = 4326) optsA <- list(drawOptions = list(snappable = FALSE, hintlineStyle = list(color = "red", opacity = 0.5), templineStyle = list(color = "red")), editOptions = list(snappable = FALSE)) x <- editFeatures(pp, editor = "leafpm", editorOptions = optsA) optsB <- list(editOptions = list(remove = FALSE), circleOptions = FALSE, markerOptions = FALSE, circleMarkerOptions = FALSE, rectangleOptions = FALSE) x <- editFeatures(pp, editor = "leaflet.extras", editorOptions = optsB) ```
Make new editorOptions() argument available in drawFeatures
Great. Thanks for pulling this all together and pushing it up to CRAN. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull should represent the combination of #100, #103, and #97 thanks to the very generous contributions from @JoshOBrien @Gutschlhofer. Hopefully, this will be on CRAN soon. Sorry for the inexcusable delay.