flutter_map 0.6.1+2

BuildStatus Pub

flutter_map #

A Dart implementation of Leaflet for Flutter apps.

Usage #

Add flutter_map to your pubspec:

dependencies:
  flutter_map: any # or the latest version on Pub

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(),
              ),
            ),
          ],
        ),
      ],
    );
  }

Run the example #

See the example/ folder for a working example app.

To run it, in a terminal cd into the folder. Then execute ulimit -S -n 2048 (ref). Then execute flutter run with a running emulator.

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:

Widget build(ctx) {
  return 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:

Widget build(ctx) {
  return FlutterMap(
    options: MapOptions(
      center: LatLng(56.704173, 11.543808),
      zoom: 13.0,
      swPanBoundary: LatLng(56.6877, 11.5089),
      nePanBoundary: LatLng(56.7378, 11.6644),
    ),
    layers: [
      TileLayerOptions(
        tileProvider: AssetTileProvider(),
        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.

Note that there is also FileTileProvider(), which you can use to load tiles from the filesystem.

Plugins #

Roadmap #

For the latest roadmap, please see the Issue Tracker

[0.6.1] - 5/28/2019

  • merge 0.5.4 and 0.5.5 into dev branch

[0.6.0] - 5/28/2019

  • Updated to support new error message formats.
  • Updated flutter sdk dependency to v1.5.9

Note: 0.6.x releases are compatible with Flutter's dev channel

Thanks to @slightfoot for this release!

[0.5.4] - 6/7/2019

  • fix markers on edge of screen disappearing (#313)
  • dart analysis fixes (#300)
  • add border circle (#299)
  • add dotted line to polygon (#295)
  • fix example esri page (#292)
  • add flutter_map_marker_cluster package to README (#309)

Note: 0.5.x releases are compatible with Flutter's stable channel, currently v1.5.4-hotfix.2 and 0.6.x releases (also on the flutter_map dev branch) is a version of flutter_map compatible with Flutter's dev channel

Thanks to @lpongetti @FalkF @Victor-emil @lsaudon and @lorenzo for this release!

[0.5.3] - 5/21/2019

  • update dependencies (#288)

[0.5.2] - 5/20/2019

  • fix zooming issue (#281)

[0.5.1] - 5/17/2019

  • add mbtiles
  • add formatting and linter rules
  • Fix null pointer in isOutOfBounds (#274)
  • add isUserGesture (#237)
  • fix emulator pinching error

Thanks to @avbk, @OrKoN, @pintomic, @wmcshane, @manhluong for this release!

[0.5.0] - 2/21/2019

  • add cached network image support (#204)
  • Use PositionedTapDetector only in interactive mode (#207)
  • Allow defining CircleMarkerRadius in meters (#213)
  • support for tms tile coordinates (#214)
  • add moving markers example
  • add long press gesture for markers (#229)
  • add patreon badge to README
  • rename Point to CustomPoint (#187)
  • remove layers property from MapOptions (#193)

Thanks to @SamuelRioTz, @jecoz, @4kssoft, @bugWebDeveloper, @RaimundWege, @vinicentus, and @etzuk for this release!

[0.4.0] - 12/31/2018

  • Zoom to focal point on double tap and scale gestures (#121)
  • Make anchor field public (#172)
  • FitBoundsOptions now uses EdgeInsets padding
  • Add GroupLayer
  • Update README

Thanks to @tomwyr, @csjames, @kengu, @ocularrhythm for this release!

[0.3.0] - 11/1/2018

  • PositionCallback now has hasGesture #139

Thanks to @gimox for this release!

[0.2.0] - 10/25/2018

  • Use NetworkImageWithRetry for tile layers (#145)
  • Add rebuild capability to LayerOptions (#144)
  • Added Circle layer (#137)
  • Prevent Map Layer Excessive Rebuilds (#131)

Thanks to @kengu, @mortenboye, and @tomwyr for this release!

[0.1.4] - 9/24/2018

  • Polygon Support (#118)

Thanks to @JulianBerger for this release!

[0.1.3] - 9/18/2018

  • fix identical map position callbacks (#111)
  • Prune tiles bug fix (#112)

Thanks to @IhorKlimov and @tomwyr for this release!

[0.1.2] - 8/21/2018

  • Added polyline customisation options (#94)
  • Expose map bounds (#99)
  • Added onTap example (#103)
  • route bugfix (#104)
  • options is now required (#105)
  • Project refactor and changes to offline map #85

Thanks to @LJaraCastillo, @ubilabs, @xqwzts, @vinicentus, and @lsaudon for this release!

[0.1.0] - 8/21/2018

  • Set Dart SDK to 2

[0.0.11] - 8/2/2018

  • upgrade to latlong from 0.4.0 to 0.5.3

[0.0.11] - 7/31/2018

  • fix LICENSE spelling error
  • double-tap to zoom (#62)
  • Fix polyline overlap issue (#67)
  • Offline map example (#53)

Thanks to contributors @alfanhui, @avioli, @solid-software, and @vinicentus for this release!

[0.0.10] - 6/7/2018

  • update .gitignore (#40)
  • Applied constraints to zoom on gesture update if min or max options set (#46)
  • Pan Boundary with 2 new MapOptions variables: swPanBoundary and nePanBoundary (#47)
  • OfflineMode bool variable added to TileLayerOptions for AssetImage Widget use (#48)
  • remove quiver dep (#32)

Thanks to contributors @avioli, @bcko, and @alfanhui for this release!

[0.0.9] - 5/31/2018

  • add LatlngBounds.contains, avoid rendering out-of-view markers in MarkerLayer

[0.0.8] - 5/31/2018

  • bug: rendering far-away tiles was causing a GPU crash on the simulator. add tile pruning to TileLayer

[0.0.7] - 5/29/2018

  • bug: TileLayer not listening to onMoved events from MapController

[0.0.6] - 5/11/2018

  • fitBounds, onPositionChanged (#39)

[0.0.5] - 3/11/2018

  • make tile background customizable (#36)
  • use transparent_image as placeholder image (#37)

[0.0.4] - 4/18/2018

  • Add marker anchor support (#27, #30)

[0.0.3] - 4/18/2018

  • fixed Dart 2.0 type errors (#23)
  • add MapController API (#24 + #25)

[0.0.2] - 2/21/2018

  • subdomain support
  • move gesture detection into map widget
  • improved tile layer support
  • improved examples
  • Polyline layers
  • fix marker redraw on map rotation

[0.0.1] - 2/5/2018

  • inital release

example/README.md

leaflet_flutter_example #

A new Flutter project.

Getting Started #

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_map: ^0.6.1+2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_map/flutter_map.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
98
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
69
Overall:
Weighted score of the above. [more]
93
Learn more about scoring.

We analyzed this package on Jul 16, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/src/layer/polygon_layer.dart.

Run flutter format to format lib/src/layer/polygon_layer.dart.

Maintenance issues and suggestions

Support latest dependencies. (-20 points)

The version constraint in pubspec.yaml does not support the latest published versions for 2 dependencies (cached_network_image, path_provider).

The package description is too short. (-11 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
async ^2.1.0 2.2.0
cached_network_image ^0.8.0 0.8.0 1.1.0
flutter 0.0.0
flutter_image ^2.0.0-dev.1 2.0.0
latlong ^0.6.1 0.6.1
path_provider ^0.5.0+1 0.5.0+1 1.1.2
positioned_tap_detector ^1.0.2 1.0.3
sqflite ^1.1.5 1.1.6+1
transparent_image ^1.0.0 1.0.0
tuple ^1.0.2 1.0.2
Transitive dependencies
ansicolor 1.0.2
charcode 1.1.2
collection 1.14.11
console_log_handler 1.1.6
convert 2.1.1
crypto 2.0.6
flutter_cache_manager 0.3.2 1.1.0
http 0.12.0+2
http_parser 3.1.3
intl 0.15.8
logging 0.11.3+2
matcher 0.12.5
meta 1.1.6 1.1.7
path 1.6.2
quiver 2.0.3
sky_engine 0.0.99
source_span 1.5.5
stack_trace 1.9.3
string_scanner 1.0.4
synchronized 2.1.0+1
term_glyph 1.1.0
typed_data 1.1.6
uuid 2.0.2
validate 1.7.0
vector_math 2.0.8
Dev dependencies
flutter_test
pedantic ^1.5.0 1.8.0+1
test ^1.6.0

Admin