-
Notifications
You must be signed in to change notification settings - Fork 40
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 offset possibility to Paths (add offset argument to add_path) #300
Comments
I've made a prototype on branch remotes::install_github("SymbolixAU/mapdeck", ref = "issue300")
library(sf)
sf <- mapdeck::roads
sf$offset <- sample(-10:10, size = nrow( sf ), replace = TRUE )
set_token( secret::get_secret("mapbox"))
mapdeck(
style = mapdeck_style("light")
) %>%
add_path(
data = sf
, stroke_colour = "ROAD_NAME"
, offset = "offset"
) |
That was fast! … and yes, it works. Great! Thank you very much. I really appreciate the quick update and I'm sorry if the part below sounds too greedy.... I noticed that the line width changes when zooming which is unfortunate. On a high level overview the lines are hard to distinguish (and hard to click on for additional info). When you zoom in, it’s OK. The example from deck.gl also include Having some control over how the width of the line is displayed would be good and probably a good addition to the package as well. |
in 4d85ad2 I've exposed the arguments
Can you reinstall branch |
They work perfectly! Thank you. In my experience you get the slickest result when using a min and max in pixels. Then, when zooming in the lines become a bit thicker, which feels natural (roads / streets etc. also become wider when zooming in). When zooming out, they become thinner just as the roads. Thank you again for the quick responses. |
I'm going to leave this open until I merge it into master - I still need to update the docs. |
Of course. |
When plotting traffic information on a map, each road has two directions. The road itself is often a single path, but the directions are actually two paths on the same road (with opposite directions). Via Leaflet there is an offset plugin to offset the lines a few pixels (indpendent of zoom level). That enables the two paths on the same road to always be shown in parallel (next to each other). An example of how I used that with Leaflet (using R Shiny) is here:
https://services.maptm.nl/tvdemo/?place=groningen
move the slider on the top left to 1 (instead of 0.5) to show all traffic and not only congested traffic and clearly see the offset at work for the lines/paths shown
The deck.gl solution also has such an offset feature as documented here:
Path Sytle Extension
I believe the
dash
option of the same extention was implemented last year into Mapdeck:Dash feature announcement on twitter
Since the offset function is similar to the dash function, I would think it is relatively straightforward to add that as well, but I'm no expert at this.
It would be great if adding the path offset option can be added. I would like to switch to Mapdeck instead of Leaflet because of the performance and the offset option is critical for the application.
TODO
width_*
argumentsoffset
argumentThe text was updated successfully, but these errors were encountered: