Ateraworld / mapplet

The easiest way to store flutter maps for offline usage
https://pub.dev/packages/mapplet
MIT License
3 stars 2 forks source link

Can you provide an example with flutter_map? #1

Closed mehmetkalayci closed 1 year ago

mehmetkalayci commented 1 year ago

Hi, As I understand this lib saves the maptiles to a db. But I did not understand how to read the maptiles from db to show in flutter_map plugin. Can you provide an example to read the data from db and show it in flutter_map plugin? Thanks

mehmetkalayci commented 1 year ago

Depot object has a method getTileProvider(); which returns MappletTileProvider. Additionally, deport object has variable depot.config.urlTemplate that keeps urlTemplate variable. I just added the following code on top of the existing example.


  ...
  @override
  Widget build(BuildContext context) {

   var tileProvider = _depot.getTileProvider();

    print(tileProvider);

    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        title: Text(widget.title),
      ),
      body: Padding(
        padding: const EdgeInsets.all(16),
        child: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            children: <Widget>[
              _buildStats(),
              ..._buildFirstRegion(),
              Flexible(
                child: FlutterMap(
                  options: MapOptions(
                    center:  LatLng(38.0107,32.5355),
                    minZoom: 12,
                    maxZoom: 16,
                  ),
                  children: [

                    TileLayer(
                      tileProvider: tileProvider.depot.getTileProvider(),
                      urlTemplate: tileProvider.depot.config.urlTemplate,
                      maxZoom: 16,
                    ),

                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }```