-
Notifications
You must be signed in to change notification settings - Fork 506
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
Added polyline offset plugin support with example data and script #614
base: main
Are you sure you want to change the base?
Conversation
Fernando Munoz Mendez seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
inst/htmlwidgets/leaflet.yaml
Outdated
- name: leaflet-polylineoffset | ||
version: 1.1.1 # match leaflet version | ||
src: "htmlwidgets/plugins/leaflet-polylineoffset" | ||
stylesheet: leaflet.polylineoffset.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be script
instead of stylesheet
. Otherwise the js-file would be added as css-link
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isnt the src in /lib
instead of /plugin
?
scripts/offset_example.R
Outdated
@@ -0,0 +1,6 @@ | |||
# example | |||
corunaroads <- readRDS("./data/corunaroads.rds") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not able to install your PR because of the .rds file. Could you either save it as .rda file or maybe just create some lines from sampled coordinates.
file 'corunaroads.rda' has magic number 'X'
Use of save versions prior to 2 is deprecated
Also I see that your example uses readRDS("./data/corunaroads.rds")
but the PR has only data/corunaroads.rda
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found out that the rda
file was a badly renamed rds
file hence the error. I've managed to fix it in the latest commit.
R/plugin-polylineoffset.R
Outdated
htmltools::htmlDependency( | ||
"leaflet-polylineoffset", | ||
"1.1.1", | ||
system.file("htmlwidgets/lib/leaflet-polylineoffset", package = "leafletfmm"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It probably should be package = "leaflet"
R/layers.R
Outdated
@@ -1128,6 +1128,7 @@ addPolylines <- function( | |||
fill = FALSE, | |||
fillColor = color, | |||
fillOpacity = 0.2, | |||
offset = NULL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think new parameters should be added at the end to keep backward compatibility for positional arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation for offset
is missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the documentation for the parameter but I'm not sure what's the best way to update the man
files. Is it just a case of using devtools::document()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, or you can change the settings in RStudio under Build > More > Configure Build Tools. In the Panel under "Build Tools" you can click the "Configure" Button and check "Install and Restart".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to leave the dataset "corunaroads" in the PR, then you need to document that aswell to pass the R checks. You can see the documentation for the other datasets in /R/data.R
. Then document & reinstall and resubmit the changes.
Then you should pass the Travis Checks for R. I'm not sure about the Javascript Check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work. I was also very interested in using this plugin.
I couldn't get your PR to run since I am having problems reading the .rda/.rds file with R 3.6.1, because it was probably saved with version = 2 which is for R 1.4.0 to R 3.5.0.
So this call:
remotes::install_github("rstudio/leaflet#614")
resulted in this warning:
file 'corunaroads.rda' has magic number 'X'
Use of save versions prior to 2 is deprecated
Could you maybe use some sampled coordinates or even the data atlStorms2005
? Thats a SpatialLinesDataFrame
which is already included in the package.
…ependencies, added corunaroads as a valid rda and updated the example
@trafficonese I've gone through your comments hopefully you'll be able to install it and test it now. |
removed corunaroad dependency, and changed the example for it to use atlStorms2005
I decided to do without |
I think it is because of the new roxygen version. But you should be able to look at the conflicts, resolve them and merge the results. |
@trafficonese The R checks are ok but as you said we are not passing the Javascript one. I'm a bit out of my depth in JS, unfortunately. It is entirely possible that I haven't properly followed these steps? I'm not sure since I prepared the pull request in April last year and I don't remember 😅 |
Unfortunately i'm no JS-Pro either and I dont know exactly what the checks are doing. |
Yes. Calling |
Success! Thanks @schloerke and @trafficonese, the fresh yarn build did the trick. |
I have a little suggestion: Could you include the So if offset is 0/NULL/NA, dont include the dependency. |
For some reason, I'm getting some error when installing, but I think is entirely due to my machine: I'll try to fix it but in the meanwhile, I haven't been able to install the package and test the new modifications. Edit: |
It looks like the Polylineoffset dependency is being added to the maps regardless we use |
Are issues with lines becoming circles or other erratic shapes solved in this version? The issues are discussed in the issue list of the bbecquet repository. For example here: bbecquet/Leaflet.PolylineOffset#1 I once adjusted a fork that had fixed such issues and made it compatible with the never version fo Leaflet (v2?). I use ShinyJS to include the .js source and then just use the offset parameter in the addPolylines function. Example: addPolylines(..., options=list(offset=3), ...) which works. The JS file I use can be found here: I have limited experience with package building and/or JavaScript. Otherwise I'd give it a go myself. |
Hi @AntonWijbenga, Those issues with erratic shapes exist in the version implemented here, particularly the circles problem would happen for very complex shapes. In the past I have managed to mitigate it by simplifying the shape with |
Hi, thanks for implementing this feature! I would really like to use it, but can't find any documentation regarding how to implement this. Could you please provide a gist? Thanks again, Aine |
Hi! This was never merged to the main branch, and it was implemented a while ago. Not sure how easy it would be to make it work but try |
Pull Request
Hi,
I have implemented https://github.com/bbecquet/Leaflet.PolylineOffset which is great for visualizing directional road flows on road networks. I was wondering if this would be the best way to share the work with the community.
Essentially I modify the layers file and js sources to accept 'offset' as a variable and add new dependencies for the plug-in
Best regards,
Fernando