leaflet
leaflet copied to clipboard
Added polyline offset plugin support with example data and script
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
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.
:white_check_mark: fermumen
:x: Fernando Munoz Mendez
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.
@trafficonese I've gone through your comments hopefully you'll be able to install it and test it now.
I decided to do without corunaroads
as it's probably a bit redundant. Somehow running document()
has created a conflict on map-shiny.Rd. Any idea why?
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.
But did you use yarn build
? This should build a fresh /htmlwidgest/leaflet.js
. Its not included in your PR so you probably skipped that part :)
Yes. Calling yarn build
in the terminal will be necessary for the JS check to pass.
Success! Thanks @schloerke and @trafficonese, the fresh yarn build did the trick.
I have a little suggestion:
Could you include the leafletPolylineoffsetDependencies
only if an offset is used?
Otherwise the dependency is always added, but not always needed/required.
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:
ERROR: dependency 'leaflet.providers' is not available for package 'leaflet'
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: I installed the latest dev version of 'leaflet.providers' I'm not sure why it stopped working but I'm guessing it could be an issue with MRAN
It looks like the Polylineoffset dependency is being added to the maps regardless we use leafletPolylineoffsetDependencies
or not. Any idea why?
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: https://github.com/bbecquet/Leaflet.PolylineOffset/issues/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: https://traphx.maptm.nl/leaflet.polylineoffset_arw.js
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 rmapshaper
package. I haven't touched this PR in ages (two years) but if there is a version of the polyline offset that solves it you should be able to include it in the appropriate folder in inst/htmlwodgets/lib/
to make it work.
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, 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 remotes::install_github("rstudio/leaflet#614")
and perhaps use a CRAN mirror for Early 2020, you can look at the example in scripts
from this PR. Alternatively if you can switch to python, the Folium team has this implemented here