Maplibre-gl and deck-gl in Observable framework

What is the recommended way to import maplibre-gl and deck-gl libraries (and associated css) into Observable Framework?

1 Like

Salut Nicolas,

Hereā€™s how I import maplibre-gl, with its css and js locally hosted:

https://observablehq.observablehq.cloud/pangea/party/maplibre-gl

Itā€™s possible that the same pattern works for deck.gl, but I havenā€™t tried yet. Let me know if you get it to work?

Note that if you prefer, you could combine the css and js cells into one like so:

```js
display(html`<link rel="stylesheet" href="${import.meta.resolve("npm:maplibre-gl/dist/maplibre-gl.css")}">`);
import maplibregl from "npm:maplibre-gl";
```
1 Like

Thanks a lot.
What is import.meta.resolve() ?

Actually, I canā€™t import deck-gl with import. The only way is

<script src="https://unpkg.com/deck.gl@latest/dist.min.js"></script>

But I donā€™t know if itā€™s a good way.

Ah, if I try to import

import deck from "npm:deck.gl"

I get this error:

unable to fetch: https://cdn.jsdelivr.net/npm/@loaders.gl/compression@undefined/package.json

We need to investigate a better solution for deck.gl, but for now hot-linking to unpkg seems to be the only thing that works.

1 Like

DeckGL!

```js
import deck from "npm:deck.gl/dist.min.js/+esm";
```

demo:

https://observablehq.observablehq.cloud/pangea/party/deck.gl.html

1 Like

Hello Fil.
Iā€™m interested to have a look to the code source behind this map.
https://observablehq.observablehq.cloud/pangea/party/deck.gl-map
Is it possible?

yep there is a tiny button with a link to the source at the top right (itā€™s normal you didnā€™t see it, as itā€™s hidden by a big O ā€” I have to move it somewhere else)

Iā€™ve seen it. But it links to a 404 error page.

hmmmā€¦ try this one pangea/docs/party/deck.gl-map.md at main Ā· Fil/pangea Ā· GitHub

Note that this is not ā€œofficial documentationā€, itā€™s just a playground where Iā€™m trying things out, and changing everything all the time. Something more serious will definitely come out of this chaos, in the near future.

It works. Yes, I understood it was a playground. But it helps.

1 Like

The documentation page for deck.gl now lives at deck.gl | Observable Framework

1 Like

Well done

1 Like