-
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
Add arguments to editFeatures allowing control over leafpm options #97
Conversation
New arguments `pmToolbarOpts`, `pmDrawOpts`, `pmEditOpts`, and `pmCutOpts` take lists of arguments that will be passed on to the corresponding `leafpm` functions. (The elements of `pmToolbarOpts`, for example, get passed on as supplied arguments to `leafpm::pmToolbarOptions()`.) This PR addresses (in part) Issue #92 . (Note that, unless overridden by an element in user-supplied `*Opts` argument, `editFeatures` retains its current leafpm defaults, such as `allowSelfIntersection = FALSE`.) This example demonstrates usage of one of the newly added arguments: library(sf) library(leaflet) library(mapview) library(mapedit) library(leafpm) ## make a polygon for testing 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) ## Demonstrate `pmDrawOpts` argument usage tst <- editFeatures(pp, editor = "leafpm", pmDrawOpts = list(snappable = FALSE, templineStyle = list(color="yellow")))
Thanks for this! One thing I'd like to avoid (if possible) is too many arguments. So, if we can have one set of @timelyportfolio I vaguely remember you were trying to implement |
@JoshOBrien Thanks so much for this pull request. @tim-salabim I have struggled with this decision since the inception of the project. Originally, I favored less arguments to the After a lot of thought I think I still like this behavior. Otherwise, we will have a significant number of additional arguments to mapedit functions. I can rewrite these lines similar to the module lines mentioned above to default to user supplied editor if available. If we elect to go this direction, I also think I should better document this expectation and add more examples. I'd love both of your thoughts on this approach. |
Thanks for your thoughts @timelyportfolio. How about we utilise |
Thanks to both of you for picking this back up. I've got the same sense as @timelyportfolio that it's important to avoid a proliferation of (likely to be rarely used) formal arguments. At the same time, I think it's important to provide more advanced users with some way to reach those lower-level leafpm and leaflet.extras options. It does seem possible to use My own inclination would be to add a single formal argument -- perhaps
The main downside of this approach might be that constructing a list of options suitable for passing to Please let me know if any of that doesn't make sense, and I'll be happy to explain in more detail. Looking forward to hearing your further thoughts! |
@JoshOBrien thanks for the lattice examples! I miss those olden days :-) Regarding my suggestion to utilise library(leaflet)
library(leafem)
m = leaflet() %>% addTiles()
m1 = garnishMap(m, addScaleBar, addMouseCoordinates,
position = "bottomleft")
m1 Though care needs to be taken to avoid unintended recycling of arguments in case they map to more than one of the provided functions. That said, I am absolutely fine with having an |
@tim-salabim Interesting. Thanks for sharing that Would you and @timelyportfolio like me to draw up a draft implementation of that? And if so, is there any reason not to do all of the processing of |
@JoshOBrien a PR with a draft implementation would be great! One last thing, I think in order to be concise with the whole leaflet-verse, we should name the argument |
Oh, and yes, moving those options to one place is preferable. |
@JoshOBrien this sounds great. Yes, if possible please move the quick patch to its better home. @tim-salabim, since the output of the I would like to express a preference for all other map customization to happen outside of the @JoshOBrien, thanks again for jumping in to participate. If @tim-salabim agrees, I think you deserve a spot in |
Absolutely! @JoshOBrien should be listed in DESCRIPTION @timelyportfolio I totally agree that no map custimisation should happen in mapedit (other than rendering a standard mapview map if no map object is supplied). I was not implying anything regarding map customisation with the example of |
OK, @tim-salabim , I just went ahead and submitted a PR (#100) with a draft implementation of the above. If it looks good to you all, I'd be happy to work a bit more on the documentation, to polish that for incorporation in the package. Also, @timelyportfolio, I heartily agree with your suggestion that mapedit should not attempt to support additional map customization. In case it's of interest, my real reason for wanting finer control over the leafpm editor was so that I could control its |
Hi @JoshOBrien I think this looks great! I feek like this is worth a vignette. Would you be ok with writing one up showcasing these new options? We could also think about writing a blog post for r-spatial.org with the new options implementation. |
@tim-salabim Super! I think a vignette would be an ideal way to document this, and will go ahead and draft one. I most likely won't be able to get to it in the next 10 days, but will pick it back up soon after that. |
No rush, as I said, I will be out of office too for the next week. And many thanks for implementing this! |
@JoshOBrien if I understand correctly, this is is superseded by #100. If so, I will close and go with what I consider to be the preferred option of #100. Thanks!!!!!! |
@timelyportfolio Super. That sounds good. Thanks! |
New arguments
pmToolbarOpts
,pmDrawOpts
,pmEditOpts
, andpmCutOpts
take lists of arguments that will be passed on to thecorresponding
leafpm
functions. (The elements ofpmToolbarOpts
,for example, get passed on as supplied arguments to
leafpm::pmToolbarOptions()
.) This PR addresses (in part) Issue #92 .(Note that, unless overridden by an element in user-supplied
*Opts
argument,
editFeatures
retains its current leafpm defaults, such asallowSelfIntersection = FALSE
.)This example demonstrates usage of one of the newly added arguments: