-
-
Notifications
You must be signed in to change notification settings - Fork 981
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
Leaflet Basemaps on Panes not visible #1949
Comments
Hi, I can reproduce the issue but I am not sure this is something to be fixed with rmarkdown. I don't see which configuration in the 📦 conflicts with leaflet. Have you asked already in leaflet ? Maybe this is something to handle in there. @jcheng5 @schloerke would you have an idea about how to help on this ? Is this more a leaflet issue ? Here is a reprex with Rmd:
---
title: leaflet missing css
output: html_document
params:
css: FALSE
---
Are we using the css ? `r ifelse(params$css, "yes", "no")`
```{asis, echo = params$css}
We have included this css:
```
```{css, echo = params$css, eval = params$css}
.leaflet-layer {
min-width: 400px;
}
.leaflet-tile-container {
width: 100%;
}
```
# Leaflet output
```{r}
library(leaflet)
leaflet() %>%
addMapPane("right", zIndex = 0) %>%
addTiles(group = "base", layerId = "baseid", options = tileOptions(pane = "right"))
```
|
Thanks for the quick response. No I have not opened an issue in leaflet. I was not sure where the bug was coming from and since I don't really understand the whole markdown process, I thought it would happen there. And thank you for creating nice markdown in here. I was unable to do so as it always rendered the markdown as code. |
You did the right thing, I ping leaflet maintainers to have their thoughts on this because I am not sure what to do inside rmarkdown as it is leaflet specific css. But it is nice to have a workaround.
The trick is explained in our issue guide (https://yihui.org/issue/#please-format-your-issue-correctly) - you can look for it for next time! 😉 |
Re-reading this now with fresh eye, I think this not related to rmarkdown directly. From this comment in original issue r-spatial/mapview#349 (comment), I understand that
whereas this doesn't
By comparing CSS rules between those two calls, the format will have the tile images inside <div class="leaflet-pane leaflet-tile-pane" style="z-index: 0;">
<div class="leaflet-layer " style="z-index: 1; opacity: 1;">
<div class="leaflet-tile-container leaflet-zoom-animated" style="z-index: 18; transform: translate3d(0px, 112px, 0px) scale(1);">
<img alt="" role="presentation" src="http://a.tile.openstreetmap.org/0/0/0.png" class="leaflet-tile leaflet-tile-loaded" style="width: 256px; height: 256px; transform: translate3d(208px, 0px, 0px); opacity: 1;">
<img alt="" role="presentation" src="http://a.tile.openstreetmap.org/0/0/0.png" class="leaflet-tile leaflet-tile-loaded" style="width: 256px; height: 256px; transform: translate3d(-48px, 0px, 0px); opacity: 1;">
<img alt="" role="presentation" src="http://a.tile.openstreetmap.org/0/0/0.png" class="leaflet-tile leaflet-tile-loaded" style="width: 256px; height: 256px; transform: translate3d(464px, 0px, 0px); opacity: 1;"></div>
</div>
</div> whereas the latter will be <div class="leaflet-pane leaflet-right-pane" style="z-index: 0;">
<div class="leaflet-layer " style="z-index: 1; opacity: 1;">
<div class="leaflet-tile-container leaflet-zoom-animated" style="z-index: 18; transform: translate3d(0px, 112px, 0px) scale(1);">
<img alt="" role="presentation" src="http://a.tile.openstreetmap.org/0/0/0.png" class="leaflet-tile leaflet-tile-loaded" style="width: 256px; height: 256px; transform: translate3d(208px, 0px, 0px); opacity: 1;">
<img alt="" role="presentation" src="http://a.tile.openstreetmap.org/0/0/0.png" class="leaflet-tile leaflet-tile-loaded" style="width: 256px; height: 256px; transform: translate3d(-48px, 0px, 0px); opacity: 1;">
<img alt="" role="presentation" src="http://a.tile.openstreetmap.org/0/0/0.png" class="leaflet-tile leaflet-tile-loaded" style="width: 256px; height: 256px; transform: translate3d(464px, 0px, 0px); opacity: 1;"></div>
</div>
</div> Only the class of outer div will change. And in the former we have this rule that applies .leaflet-container .leaflet-overlay-pane svg, .leaflet-container .leaflet-marker-pane img, .leaflet-container .leaflet-shadow-pane img, .leaflet-container .leaflet-tile-pane img, .leaflet-container img.leaflet-image-layer {
max-width: none !important;
max-height: none !important;
} which won't apply on This rules make the tile appears or not. It comes from leaflet itself It is there to be sure that We could patch in one of the layer but I would say this is a bug in leaflet JS. @jcheng5 @schloerke do you already patch leaflet CSS somehow in the R package ? |
@cderv Great diagnostic! Yes, we have patch CSS content put in https://github.com/rstudio/leaflet/blob/main/inst/htmlwidgets/lib/rstudio_leaflet/rstudio_leaflet.css Do you mind submitting a PR? Thank you! |
Perfect that was the hint I needed. Thank you ! I'll submit a PR. |
This has been merged on leaflet's side to this should be fixed in next leaflet version. Thanks for the report. |
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary. |
When a basemap is assigned to a leaflet pane, it will not appear in the final HTML file. See the original issue: r-spatial/mapview#349
I hope that it's a simple CSS-problem, as when I include the following CSS-snippet, the basemap shows up.
By filing an issue to this repo, I promise that
xfun::session_info('rmarkdown')
. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('rstudio/rmarkdown')
.I understand that my issue may be closed if I don't fulfill my promises.
The text was updated successfully, but these errors were encountered: