Skip to content

How does PMTiles Viewer load local files? #23

Answered by bdon
larsmaxfield asked this question in Q&A
Discussion options

You must be logged in to vote

The source code is here: https://github.com/protomaps/PMTiles/tree/main/app

It uses react-dropzone to handle local files: https://github.com/protomaps/PMTiles/blob/main/app/src/Start.tsx#L113

It then constructs a FileSource from the drop event https://github.com/protomaps/PMTiles/blob/main/app/src/Start.tsx#L110

And passes it via code to the MapLibre protocol here (since you can only otherwise configure maplibre sources through style strings): https://github.com/protomaps/PMTiles/blob/main/app/src/MaplibreMap.tsx#L397

I am likely going to re-implement that app without React, here is another viewer I wrote that does something similar with more vanilla JS instead of react: https://github.co…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@larsmaxfield
Comment options

Answer selected by bdon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants