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

Using the "|" operator, the basemap is not rendered in knitted markdown #349

Closed
felixhaass opened this issue Nov 1, 2020 · 8 comments
Closed

Comments

@felixhaass
Copy link

First off, thanks for the terrific package! It has helped me a lot.

I've stumbled across the following minor bug. When I run mapview(breweries) | mapview(franconia) in an rmarkdown chunk that I subsequently knit to HTML, the basemaps are missing.

Here's the code I've used:

---
title: "Testing Leaflet Sliders"
output: html_document
---

```{r}
library(mapview)
mapview(breweries) 
```


```{r}
library(mapview)
mapview(breweries) | mapview(franconia)
```

This gives me the following output:

image

When I use mapview(breweries) | mapview(franconia) in RStudio, the Viewer Pane shows the correct basemap.

I'm using mapview version 2.9.4.

I tried to narrow down from where the problem originates, but no success. Any idea?

Thanks,
Felix

@tim-salabim
Copy link
Member

Thanks @felixhaass , this is a tough one. No idea why this doesn't work. Doesn't help that we don't see any errors in the browser console... Not sure how to fix this

@trafficonese
Copy link
Contributor

trafficonese commented Nov 8, 2020

It seems that markdown is having problems with leaflet panes.

The following example will show no basemap in a knitted document, but if you remove options = pathOptions (pane = "right") the basemap appears.
Also, if you give the pane the name tile, it also works, so I guess markdown only looks for basemaps in the leaflet-pane leaflet-tile-pane class.

So I'm not so sure that the problem comes from mapview or leaflet.extras2.

library(leaflet)
leaflet() %>%
  addMapPane("right", zIndex = 0) %>%
  addTiles(group = "base", layerId = "baseid", options = pathOptions(pane = "right"))

@tim-salabim
Copy link
Member

@trafficonese great catch! Any ideas how to resolve this? Sounds like a job for rstudio & leaflet...

@trafficonese
Copy link
Contributor

Unfortunately, I don't really have a lot of experience with markdown and the entire processing pipeline to figure out where this error actually shows up. But I'm going to dig into rmarkdown a bit, maybe I can find out something.

@tim-salabim
Copy link
Member

Well, I'd say that given that you've isolated the problem to be either leaflet or rmarkdown based, we should consider opening an issue with rstudio (probably leaflet).

FWIW, this works

library(leaflet)
leaflet() %>%
  addMapPane("tile", zIndex = 0) %>%
  addTiles(group = "base", layerId = "baseid", options = tileOptions(pane = "tile"))

whereas this doesn't

library(leaflet)
leaflet() %>%
  addMapPane("right", zIndex = 0) %>%
  addTiles(group = "base", layerId = "baseid", options = tileOptions(pane = "right"))

I used tileOptions instead of pathOptions as I think it's better suited for addTiles

@cderv
Copy link

cderv commented Jan 6, 2022

FWIW I looked a bit into that as you opened an issue in rmarkdown. I believe this is something missingin Leaflet JS library.
See rstudio/rmarkdown#1949 (comment)

Not sure what could be done on our side, but if something, I would say it would be in leaflet R package by patching the CSS.

@cderv
Copy link

cderv commented Jan 6, 2022

We've decided to add the missing CSS in leaflet. Hopefully this is enough to help with your issue.

See rstudio/leaflet#770

@tim-salabim
Copy link
Member

Should work now with the dev version of leaflet rstudio/leaflet#770

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

No branches or pull requests

4 participants