-
-
Notifications
You must be signed in to change notification settings - Fork 872
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 map is cut off when rendering qmd to PDF, wrong view of snapshot is taken. #2276
Comments
It's a matter of the figure size. When you call
Please read and follow the issue guide, and you'll know how to write |
Hi, YiHui, thanks for your reply.
I 'v updated the packages related to knitr:
|
I have no idea... I was testing on macOS, and don't have a CentOS machine to test with. |
Not worked on Windows too.
|
@cderv Are you able to reproduce the problem on Windows? |
Yes I can reproduce. I don't get the same pdf as you using your code @yihui
It seems to be related to Quarto only though, as in Rmd file I get the correct behavior... @yihui did you try inside Quarto on Mac too ? |
I noticed that DPI for PDF is set to 300 in format pdf in Quarto I tried setting It seems to work well for Rmd as far as I tested, so something is off in Qmd. I don't understand yet what can be different in Quarto for this. |
Ok in fact, So this is indeed a sizing matter. PDF is 300 dpi by default on Quarto, and the screenshot size in px is calculated as
So either adapting DPI or
I suspect though something with |
It was not that. I believe the issue is that
If I do as in first example (#2276 (comment)), and open the html saved with Current webshot has no way to pass dimension to What happens is that This brings us back to initial example: if you set the ---
title: "test"
format: pdf
---
```{r}
#| dev: png
#| fig-alt: Leaflet map of Maungawhau / Mount Eden.
library(leaflet)
map<-leaflet(width="90%") |>
setView(lng = 116.3125774825, lat = 39.9707249401, zoom = 16) |>
addTiles(urlTemplate = # Tencent tile map provider URL
"http://rt0.map.gtimg.com/realtimerender?z={z}&x={x}&y={-y}&type=vector&style=0") |>
addMarkers(lng=116.3125774825, lat=39.9707249401, popup="The birthplace of COS")
map
``` @yihui it seems using I wonder if we should tweak the feature in knitr when extension if PDF or just rely on webshot2 to improve over time. I think I went to the bottom of this. If something is not clear, please do not hesitate to ask |
Thanks a lot! So the solution is either set
Since simple solutions exist, I don't think we need to do anything in knitr's codebase. We can wait for improvements in webshot2 (rstudio/webshot2#11). |
Great, it works!
Thanks to everybody, have a good day! |
Not completely. If setting ---
title: "test"
format: pdf
---
```{r}
#| dev: png
#| fig-alt: Leaflet map of Maungawhau / Mount Eden.
library(leaflet)
map <- leaflet(width="90%") |>
setView(lng = 116.3125774825, lat = 39.9707249401, zoom = 16) |>
addTiles(urlTemplate = # Tencent tile map provider URL
"http://rt0.map.gtimg.com/realtimerender?z={z}&x={x}&y={-y}&type=vector&style=0") |>
addMarkers(lng=116.3125774825, lat=39.9707249401, popup="The birthplace of COS")
map
``` If This would be the current situation from all my tests.
@yihui as screenshot does not work really well with webshot2, pdf and quarto I was wondering if we could do :
Or maybe just throw a warning for high dpi and dev pdf with webshot2. Idea is just to help users. |
Okay, thanks for the clarification!
Yes, we could. It may be a better idea to set |
Thanks @yihui ! A thoughts related to warnings: I wonder if we should find a system to allow to customization of error by Quarto for example. Thinking about that because Anyhow, not urgent, but I thought of that because I believe this will throw a warning for any quarto user as |
Yes, good idea. I just tweaked the message to show |
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. |
The problem may be reproduced by the following qmd code, please delete the '\' in the '`\``' mark inside for running the code, , it seems that a wrong view of the map is set when it's rendered to PDF.
Here's the rendered PDF output:
test.pdf
The text was updated successfully, but these errors were encountered: