Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

flutter flutter logo map

a flutter map implementation of leaflet.

leaflet-based flutter map package
leaflet-based flutter map package

usage

add flutter map (flutter_map) to your pubspec:

dependencies:
  flutter_map: ^0.0.1

configure the map using mapoptions and layer options:

  widget build(buildcontext context) {
    return new fluttermap(
      options: new mapoptions(
        center: new latlng(51.5, -0.09),
        zoom: 13.0,
      ),
      layers: [
        new tilelayeroptions(
          urltemplate: "https://api.tiles.mapbox.com/v4/"
              "{id}/{z}/{x}/{y}@2x.png?access_token={accesstoken}",
          additionaloptions: {
            'accesstoken': '<put_access_token_here>',
            'id': 'mapbox.streets',
          },
        ),
        new markerlayeroptions(
          markers: [
            new marker(
              width: 80.0,
              height: 80.0,
              point: new latlng(51.5, -0.09),
              builder: (ctx) =>
              new container(
                child: new flutterlogo(),
              ),
            ),
          ],
        ),
      ],
    );
  }

see the flutter_map_example/ folder for a working example app.

mapbox tiles

you can use map tiles from a number of free and paid map suppliers, or you can host your own map tiles.

the example uses openstreetmap tiles, which are free but can be slow.

use tilelayeroptions to configure other tile providers, such as mapbox:

new tilelayeroptions(
  urltemplate: "https://api.mapbox.com/v4/"
      "{id}/{z}/{x}/{y}@2x.png?access_token={accesstoken}",
  additionaloptions: {
    'accesstoken': '<put_access_token_here>',
    'id': 'mapbox.streets',
  },
),

to use, you’ll need a mapbox key:

  1. create a mapbox account to get an api key
  2. open leaflet_flutter_example/lib/main.dart and paste the api key into the
    additionaloptions map.

offline maps

follow this guide to grab offline tiles

once you have your map exported to .mbtiles, you can use mbtilestopng to unpack into /{z}/{x}/{y}.png. move this to assets folder and add asset directories to pubspec.yaml. minimum required fields for offline maps are:

new fluttermap(
  options: new mapoptions(
    center: new latlng(56.704173, 11.543808),
    minzoom: <offline map minimum zoom>,
    maxzoom: <offline map maximum zoom>,
    zoom: 13.0,
    swpanboundary: latlng(56.6877, 11.5089),
    nepanboundary: latlng(56.7378, 11.6644),
  ),
  layers: [
    new tilelayeroptions(
      offlinemode: true,
      maxzoom: <offline map maximum zoom>,
      urltemplate: "assets/offlinemap/{z}/{x}/{y}.png",
    ),
  ],
),

make sure panboundaries are within offline map boundary to stop missing asset errors.

see the flutter_map_example/ folder for a working example.

features

this package is under active development. the following roadmap is focused on the features we require at apptree. we welcome any contributions for items both on and off of the roadmap.

  • [x] inline maps
  • [x] pinch to zoom
  • [x] panning
  • [x] markers
  • [ ] package structure cleanup
  • [ ] improve pinch to zoom ( zoom directly to focal point )
  • [x] zooming removes too many tiles from other levels
  • [x] improve image fetching & caching
  • [x] ui settings support ( disable pan/zoom etc.)
  • [ ] current location support
  • [ ] documentation
  • [ ] polylines
  • [x] offline map support

download the full project for this post from the following button

this source is fully free for all time

download as zip


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.