dimfeld / svelte-maplibre

Svelte bindings for the MapLibre mapping library
https://svelte-maplibre.vercel.app
MIT License
284 stars 34 forks source link

Add a way of using maplibre.addprotocol #38

Closed gtnbssn closed 9 months ago

gtnbssn commented 1 year ago

In order to display Cloud Optimized Geotiffs, a little bit of extra legwork is required with maplibre at the moment, as explained here.

In time, maybe maplibre will add this in the library, but this will most likely still require new dependencies (geotiff and fast png), so it could remain optional.

I will admit I am not tooo sure of what I am doing here. But I thought fixing this would involve making maplibregl available in the context, in order to be able to call addProtocol on it in a new COGLayer component (probably in a context="module" script tag to only add the protocol once to maplibregl).

Any opinions on this?

I am happy to try making a PR, but might need some guidance!

dimfeld commented 9 months ago

Check out the new VectorTileSource component for an example of how to do this. Turns out you can just call addProtocol without needing to interact specifically with the svelte components or map instance.

I’m not familiar with COG but hopefully the process is similar enough that it should send you on the right path.

Gonna close this for now but feel free to reopen if you think there’s more to discuss :)