Closed as not planned
Description
Package
other
Bug Description
i have download a file From Maptiler
Region of alaska
while i am fetchinf data from file its retrived Mbbtile data

Steps to Reproduce
Download file from Map Tiler
Store in assets file
fetch file data and show in mbbtile
Future getData() async {
// Load asset as byte data
final byteData = await rootBundle.load('assets/osm.mbtiles');
// Get temp or document directory
final tempDir = await getTemporaryDirectory();
final filePath = p.join(tempDir.path, 'alaska-lates.osm.pbf');
// Write to a real file
final file = File(filePath);
await file.writeAsBytes(byteData.buffer.asUint8List());
print("File copied to: $filePath");
print("${file.lengthSync()}");
// Use this file path now
final mbtiles = MbTiles(mbtilesPath: filePath, gzip: false);
tiles = mbtiles;
log("meta Data ${tiles!.getMetadata()}");
setState(() {
});
}
Expected Results
Its need to render the map.
Actual Results
Blank map appear
Code Sample
class _TileLayersViewState extends State<TileLayersView> {
MbTiles? tiles;
Future<void> getData() async {
final byteData = await rootBundle.load('assets/osm.mbtiles');
final tempDir = await getTemporaryDirectory();
final filePath = p.join(tempDir.path, 'osm.mbtiles');
final file = File(filePath);
await file.writeAsBytes(byteData.buffer.asUint8List());
print("File copied to: $filePath");
final mbtiles = MbTiles(mbtilesPath: filePath, gzip: false);
await mbtiles.ready; // Ensure it's initialized
// Optional: print metadata
final metadata = await mbtiles.getMetadata();
print("Metadata: $metadata");
setState(() {
tiles = mbtiles;
});
}
@override
void initState() {
super.initState();
getData();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('MBTiles Viewer')),
body: tiles == null
? const Center(child: CircularProgressIndicator())
: FlutterMap(
options: MapOptions(
minZoom: 4,
maxZoom: 14,
initialZoom: 5,
initialCenter: const LatLng(61.398675, -154.8751),
),
children: [
TileLayer(
tileProvider: MbTilesTileProvider(mbtiles: tiles!),
urlTemplate: '', // Unused, but required
),
],
),
);
}
}
Platforms
all