-
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
Add options to addRasterImage #692
Conversation
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.
Just want to make sure it's suppose to be gridOptions()
(or not). Otherwise, LGTM!
Thanks for the quick action! I can confirm that this works, although, as @schloerke points out, we currently need to use library(raster)
library(leaflet)
library(leaflet.extras2)
r1 <- raster(xmn = -2.8, xmx = -2.79, ymn = 54.04, ymx = 54.05, nrows = 30, ncols = 30)
values(r1) <- matrix(1:900, nrow(r1), ncol(r1), byrow = TRUE)
crs(r1) <- CRS("+init=epsg:4326")
r2 <- raster(xmn = -2.8, xmx = -2.79, ymn = 54.04, ymx = 54.05, nrows = 30, ncols = 30)
values(r2) <- matrix(1:900, nrow(r2), ncol(r2), byrow = FALSE)
crs(r2) <- CRS("+init=epsg:4326")
leaflet(
options = leafletOptions(maxZoom = 20)
) %>%
addMapPane("left", zIndex = 1) %>%
addMapPane("right", zIndex = 1) %>%
addTiles(
group = "base"
, layerId = "baseid"
, options = tileOptions(pane = "right")
) %>%
addProviderTiles(
providers$CartoDB.DarkMatter
, group = "carto"
, layerId = "cartoid"
, options = tileOptions(pane = "left")
) %>%
addRasterImage(
r1
, group = "leftImg"
, opacity = 0.6
, options = tileOptions(
, pane = "left"
, maxZoom = 20
)
) %>%
addRasterImage(
r2
, group = "rightImg"
, opacity = 1
, options = tileOptions(
, pane = "right"
, maxZoom = 20
)
) %>%
addLayersControl(overlayGroups = c("leftImg", "rightImg")) %>%
addSidebyside(
layerId = "sidecontrols"
, rightId = "baseid"
, leftId = "cartoid"
) FWIW, there have been PRs in the past for this: Not sure whether it's better to have a dedicated |
Shoot, I didn't see the past PRs. 🤦♂️ I created |
I think |
Rebase to master before merging |
By not needing the pane option in the rasters, the specific version of leaflet (rstudio/leaflet#692) isn't required.
I would also love to have gridOptions. |
Hi, Is there any update on the status on merging the raster options ("joe/feature/raster-options") for an earlier version of leaflet into the main and newest version of leaflet? |
It would be great to have gridOptions |
I would also love to see the options argument added |
Just re-iterating that options for |
2cd8742
to
783b32b
Compare
@jeremyash Thanks for the nudge. I've now updated the |
@jcheng5 Just ran some code using terra and raster objects, and it worked fine on my end. Really appreciate your responsiveness here! Many thanks! |
Co-authored-by: Barret Schloerke <[email protected]>
a60e75d
to
4dfb58f
Compare
The other layer methods have
options
parameters, not sure whyaddRasterImage
didn't. Apparently @tim-salabim needs this for pane support. https://twitter.com/TimSalabim3/status/1279105173378531335(Note: Lots of .Rd files changed, this is because I used a more recent roxygen version)
PR task list:
tests/testthat/
R/zzz_viztest.R
devtools::document()