Skip to content
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

allow options for addRasterImage #535

Closed
tim-salabim opened this issue Apr 24, 2018 · 4 comments
Closed

allow options for addRasterImage #535

tim-salabim opened this issue Apr 24, 2018 · 4 comments

Comments

@tim-salabim
Copy link
Contributor

Thanks for the recent update! It really brings some great new features. One feature I have been exploiting is map pane definition to control layer order in a map, e.g. points always on top of polygons.

This works great:

library(leaflet)
library(mapview) # for the data

leaflet() %>%
  addTiles() %>%
  addPolygons(data = franconia, 
              group = "polygons",
              opacity = 1,
              fillOpacity = 1,
              options = leafletOptions(pane = "tilePane")) %>%
  addCircleMarkers(data = breweries,
                   group = "points",
                   color = "black",
                   fillColor = "black",
                   options = leafletOptions(pane = "overlayPane")) %>%
  addLayersControl(overlayGroups = c("polygons", "points"))

However, this does not work for addRasterImage (throughing error unused argument (options = leafletOptions(pane = "overlayPane"))).

leaflet() %>%
  addTiles() %>%
  addRasterImage(poppendorf[[4]], 
                 project = TRUE,
                 options = leafletOptions(pane = "overlayPane"))

If I understand correctly, addRasterImage uses L.GridLayer for the image rendering which has an option to specify the pane.

It would be great of we could add an options argument to addRasterImage so we can define which pane it should be rendered in. There are situations where you'd want an image to overlay vector features.

Related to this, we have freshly implemented a method to create custom map panes in a leaflet map following this tutorial. The relevant js code is here and the R functions are here.
I think this is general enough to have this in leaflet rather than mapview and I am more than happy to migrate this over for the next CRAN release (until then, I'd prefer to keep it in mapview, where it will be part of the next CRAN release).
Let me know if you are interested in migrating this to leaflet.

For completeness, here is where we specify the panes for use in mapview such that by default points overlay lines overlay polygons.

Thanks again for the great work you've put into leaflet recently!!

@schloerke
Copy link
Contributor

Hi @tim-salabim

This has been exposed in #524. Has not been merged yet (waiting for CLA) and is set for next release.

Let me know how it works for you!.

devtools::install_github("rstudio/leaflet#524")

@schloerke
Copy link
Contributor

Going to make a new issue for the panes. I think it'd be great to have in leaflet, as it is a Leaflet.js library feature. Will mark for next release!

@tim-salabim
Copy link
Contributor Author

tim-salabim commented Apr 24, 2018

Yes, with the above PR it works as expected! Closing here as expected in next release. Thanks

@shandongfx
Copy link

Looks like the option feature in addRasterImage is not available?
Any clue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants