flutter_map_mbtiles 1.0.0 copy "flutter_map_mbtiles: ^1.0.0" to clipboard
flutter_map_mbtiles: ^1.0.0 copied to clipboard

Mapbox MBTiles tile provider for flutter_map that can be used for a map that is 100% offline.

flutter_map_mbtiles #

Raster and Vector MBTiles TileProvider for flutter_map.

  • Supported raster tiles: jpg, png, webp
  • If you want to use pbf vector tiles you can use vector_map_tiles_mbtiles.
  • Web is not supported because of it's lacking SQLite support.

Pub Version likes Pub Points Pub Popularity

GitHub last commit stars GitHub issues codecov

Getting started #

pubspec.yaml

dependencies:
  flutter_map: ^6.0.0         # in case you don't have it yet 
  flutter_map_mbtiles: ^1.0.0 # this package

Usage #

late final MBTiles mbtiles;

@override
void initState() {
  // open mbtiles
  mbtiles = MBTiles(
    mbtilesPath: 'assets/mbtiles/countries-raster.mbtiles',
  );
  super.initState();
}

@override
Widget build(BuildContext context) {
  return FlutterMap(
    options: MapOptions(
      initialZoom: zoom,
      initialCenter: center,
      onPositionChanged: (position, hasGesture) {
        if (position.center == null || position.zoom == null) return;
        setState(() {
          center = position.center!;
          zoom = position.zoom!;
        });
      },
      minZoom: 0,
      maxZoom: 6,
    ),
    children: [
      TileLayer(
        tileProvider: MBTilesTileProvider(
          mbtiles: mbtiles,
        ),
      ),
    ],
  );
}

@override
void dispose() {
  // close mbtiles
  mbtiles.dispose();
  super.dispose();
}

6
likes
0
pub points
84%
popularity

Publisher

verified publisherjoscha-eckert.de

Mapbox MBTiles tile provider for flutter_map that can be used for a map that is 100% offline.

Repository (GitHub)
View/report issues

Topics

#flutter-map #mbtiles #map

License

unknown (license)

Dependencies

flutter, flutter_map, mbtiles, sqlite3_flutter_libs

More

Packages that depend on flutter_map_mbtiles