mapgl icon indicating copy to clipboard operation
mapgl copied to clipboard

Mapbox won't render in Quarto

Open walkerke opened this issue 1 year ago • 6 comments

At the moment, Quarto can't accommodate JS libraries served over a CDN because it expects a local resource path. Follow up on options for Mapbox GL JS re: licensing and how I can handle this.

walkerke avatar Jun 28 '24 11:06 walkerke

Following this discussion: https://github.com/quarto-dev/quarto-cli/discussions/10325

Also finding out if Mapbox GL JS can be bundled in the package from Mapbox which would solve the problem, so this issue's resolution is TBD.

walkerke avatar Jul 19 '24 16:07 walkerke

Now tracking at https://github.com/quarto-dev/quarto-cli/issues/10339

walkerke avatar Jul 22 '24 16:07 walkerke

so its still valid that we cant render mapgl in quarto, right? The title here suggests that this is true for Mapbox, but can it be done with maplibre? I get the same error when trying to render maplibre

Error in FUN(X[[i]], ...) : 
  Dependency mapbox-gl-draw 1.4.3 is not disk-based
Calls: .main ... dependencies_from_render -> html_dependencies_as_string -> lapply -> FUN
Execution halted

Is there any option to make this possible for maplibre (as I guess the license problem does not apply here)

wiesehahn avatar Sep 27 '24 19:09 wiesehahn

@wiesehahn yes, at the moment.

I was hoping the Quarto team would fix on their end as I prefer to pull in the assets via CDN given the way Mapbox GL JS is licensed. However it doesn't seem like the issue is high-priority.

What I can do for now is set up the MapLibre dependencies locally so it can be used in Quarto docs.

walkerke avatar Oct 01 '24 19:10 walkerke

@wiesehahn I've switched to local dependencies for MapLibre and successfully rendered a Quarto doc with all of those dependencies used. Install from GitHub and try this out:

---
title: "MapLibre Quarto test"
format: html
editor: visual
---

## MapLibre test

Let's try out MapLibre in a Quarto doc with a draw control and a geocoder, using all local dependencies:

```{r}
library(mapgl)

maplibre() |> 
  add_draw_control(freehand = TRUE) |> 
  add_geocoder_control()

image

walkerke avatar Oct 01 '24 19:10 walkerke

Great! thanks

wiesehahn avatar Oct 01 '24 20:10 wiesehahn