positron icon indicating copy to clipboard operation
positron copied to clipboard

Unable to render leaflet map created with mapBliss

Open benyamindsmith opened this issue 1 year ago • 7 comments

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

benyamindsmith avatar Jun 30 '24 15:06 benyamindsmith

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

juliasilge avatar Jun 30 '24 21:06 juliasilge

@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 avatar Jul 01 '24 00:07 benyamindsmith

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.

benyamindsmith avatar Jul 01 '24 00:07 benyamindsmith

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

ElianHugh avatar Jul 02 '24 04:07 ElianHugh

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

benyamindsmith avatar Jul 02 '24 14:07 benyamindsmith

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

jmcphers avatar Jul 10 '24 18:07 jmcphers

Should be addressed in #4151:

image

jmcphers avatar Jul 25 '24 22:07 jmcphers

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

testlabauto avatar Jul 29 '24 17:07 testlabauto