maplibre / maplibre-native

MapLibre Native - Interactive vector tile maps for iOS, Android and other platforms.
https://maplibre.org
BSD 2-Clause "Simplified" License
1.07k stars 314 forks source link

PMTiles support #1978

Open dellisd opened 10 months ago

dellisd commented 10 months ago

Is your feature request related to a problem? Please describe. PMTiles are becoming an increasingly popular way of hosting map tile data because of its relative ease in setting up and maintaining it. maplibre-gl-js supports PMTiles sources through its support for adding custom sources/protocols.

Describe the solution you'd like Support for the PMTiles format in maplibre-native, i.e. adding a pmtiles:// source to a map.

Describe alternatives you've considered This feature request focuses on PMTiles, but the approach taken in maplibre-gl-js was to add a way to implement any arbitrary source format which definitely offers more flexibility. It's unclear how feasible that is here though since maplibre-native's source implementations are written in C++ which isn't easily pluggable.

acalcutt commented 10 months ago

In tileserver-gl, which uses the node version of maplibre-native, I recently added pmtiles support using a customized request response
https://github.com/maptiler/tileserver-gl/blob/master/src/serve_rendered.js#L884-L977 . This was based around the pmtiles npm package ( https://github.com/maptiler/tileserver-gl/blob/master/src/pmtiles_adapter.js )

At the time of doing this I had some discussion with @tdcosta100 about the possibility of making it a supported protocol like you are asking here. He was saying

If you are able to code C++, you can make a new provider that can read PMTiles, just like MBTiles File Provider (https://github.com/maplibre/maplibre-native/blob/main/platform/default/src/mbgl/storage/mbtiles_file_source.cpp), then make it available as default file source (https://github.com/maplibre/maplibre-native/blob/main/platform/default/src/mbgl/storage/file_source_manager.cpp), and make the main resource loader use it too (https://github.com/maplibre/maplibre-native/blob/main/platform/default/src/mbgl/storage/main_resource_loader.cpp).

I was thinking if someone had the c++ knowledge, maybe some code from the pmtiles adapter c++ code could be used https://github.com/protomaps/PMTiles/tree/main/cpp

louwers commented 10 months ago

Some earlier discussion: https://github.com/maplibre/maplibre/discussions/318#discussioncomment-6908123