Unable to render leaflet map created with mapBliss
Positron Version:
Positron Version: 2024.06.1 (system setup) build 2024.06.1-27 Code - OSS Version: 1.90.0 Commit: a893e5b282612ccb2200102957ac38d3c14e5196 Date: 2024-06-26T01:33:58.809Z Electron: 29.4.0 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Windows_NT x64 10.0.22631
Steps to reproduce the issue:
- Install my mapBliss package
devtools::install_github("benyamindsmith/mapBliss")(repository here: https://github.com/benyamindsmith/mapBliss) - Run the following code:
mp <- mapBliss::plot_hybrid_route_flex(
addresses = c("Toronto, ON, Canada",
"Buffalo, NY, USA"),
how = c("car")
)
mp
What did you expect to happen?
In RStudio I get the following output in the Viewer Pane:
Were there any error messages in the output or Developer Tools console?
Using leaflet itself does work, such as with this:
library(leaflet)
leaflet() |>
addTiles() |>
addMarkers(lng = -111.90, lat = 40.76)
But I can confirm problems with the example mapBliss code. I see this in the Plots pane (no background tiles):
Related to #2023
@juliasilge it looks like for the mapBliss tiles to render in positron, they need to be specified as https:// as opposed to //{s}.
mp <- mapBliss::plot_hybrid_route_flex(
addresses = c("Toronto, ON, Canada",
"Buffalo, NY, USA"),
how = c("car"),
mapBoxTemplate = "https://tile.openstreetmap.org/{z}/{x}/{y}.png"
)
mp
The mapBoxTemplate argument simply provides tiles to the addTiles arg in leaflet (line of code here). So it seems strange that the behavior is different.
To refine the issue, the issue would be with the addTiles() argument with leaflet.
i.e.
leaflet() |>
addTiles(urlTemplate = "//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" ) |>
addMarkers(lng = -111.90, lat = 40.76)
Not sure what the issue could be but it is indeed strange.
is it possible that this is an issue with CSP headers?
@ElianHugh that's a good guess. It also lines up with the issues shown in the Developer Tools Console. I wonder if there are other issues with CSPs beyond leaflet rendering.
As noted in #3949, the problem also reproduces with addProviderTiles (another way of loading tiles from an external source; as in https://github.com/posit-dev/positron/issues/3756#issuecomment-2198816489).
Should be addressed in #4151:
Verified Fixed
Positron Version(s) : 2024.07.0-107
OS Version : OSX
Test scenario(s)
mp <- mapBliss::plot_hybrid_route_flex( addresses = c("Toronto, ON, Canada", "Buffalo, NY, USA"), how = c("car") )
mp
Link(s) to TestRail test cases run or created: N/A