flutter_map_pmtiles 1.0.2 flutter_map_pmtiles: ^1.0.2 copied to clipboard
PMTiles tile provider for flutter_map. It uses HTTP Range Requests to request tiles from a single local or hosted file.
flutter_map_pmtiles #
A TileProvider for flutter_map that adds support for PMTiles.
Getting started #
Add the following packages to your pubspec.yaml
file:
dependencies:
flutter_map: ^6.0.0 # in case you don't have it yet
flutter_map_pmtiles: ^1.0.0 # this package
Usage #
- Initiate the TileProvider
// ...from an URL
final Future<PmTilesTileProvider> _futureTileProvider = PmTilesTileProvider
.fromSource('https://example.com/useYourOwnHostedPMTilesFile.pmtiles');
// ...from an local file on the file system
final Future<PmTilesTileProvider> _futureTileProvider = PmTilesTileProvider
.fromSource('some/file/system/path.pmtiles');
// ...or provide a PmTilesArchive directly
// (you'll need to add pmtiles as direct dependency to your project)
final Future<PmTilesTileProvider> _futureTileProvider = PmTilesTileProvider
.fromArchive(somePmTilesArchive);
-
Await the response of the future, e.g. by using a
FutureBuilder
. -
Provide your
PmTilesTileProvider
to yourTileLayer
@override
Widget build(BuildContext context) {
return FlutterMap(
options: MapOptions(),
children: [
TileLayer(
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
// use your awaited PmTilesTileProvider
tileProvider: tileProvider,
),
],
);
}
Additional information #
If you need help you
can open an issue
or join
the flutter_map
discord server.