vector_map_tiles_mbtiles 1.2.0 vector_map_tiles_mbtiles: ^1.2.0 copied to clipboard
Mapbox MBTiles vector tile provider for vector_map_files / flutter_map that can be used for a 100% offline map.
Basic usage #
- Open the MBTiles file:
// initiate your tile provider
final mbtiles = MbTiles(mbtilesPath: mbTilesPath, gzip: false);
// OR: in case your protobuf data is not gzip encoded use:
final mbtiles = MbTiles(mbtilesPath: mbTilesPath, gzip: false);
- Provide mbtiles to the
MbTilesVectorTileProvider
:
@override
Widget build(BuildContext context) {
return FlutterMap(
options: MapOptions(
minZoom: 8,
maxZoom: 18,
initialZoom: 11,
initialCenter:
metadata.defaultCenter ?? const LatLng(0, 0),
),
children: [
VectorTileLayer(
theme: _theme,
tileProviders: TileProviders({
'openmaptiles': MbTilesVectorTileProvider(
mbtiles: mbtiles,
silenceTileNotFound: true,
),
}),
// do not set maximumZoom here to the metadata.maxZoom
// or tiles won't get over-zoomed.
maximumZoom: 18,
),
],
);
}
Need more information? #
- Read the README.md
- Check out the combined example app that showcases this and other flutter_map packages.