posit-dev / positron

Positron, a next-generation data science IDE
Other
1.19k stars 32 forks source link

Unable to render map created with mapBliss #3756

Open benyamindsmith opened 2 days ago

benyamindsmith commented 2 days ago

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:

  1. Install my mapBliss package devtools::install_github("benyamindsmith/mapBliss") (repository here: https://github.com/benyamindsmith/mapBliss)
  2. Run the following code:
mp <- mapBliss::plot_hybrid_route_flex(
  addresses = c("Toronto, ON, Canada",
                "Buffalo, NY, USA"),
  how = c("car")
)

mp

image

What did you expect to happen?

In RStudio I get the following output in the Viewer Pane:

image

Were there any error messages in the output or Developer Tools console?

image

juliasilge commented 2 days ago

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):

Screenshot 2024-06-30 at 3 41 53 PM

Related to #2023

benyamindsmith commented 2 days ago

@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

image

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.

benyamindsmith commented 2 days ago

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)

image

Not sure what the issue could be but it is indeed strange.

ElianHugh commented 1 day ago

is it possible that this is an issue with CSP headers?

benyamindsmith commented 19 hours ago

@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.