A Flutter map widget inspired by Leaflet

Related tags

Map flutter_map
Overview

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

You might also like...

Map Picker for Flutter

Map Picker for Flutter

Map Pin Picker A Vendor-free map Library for Easy and Quick Usage. Follow the steps to integrate Google Maps (https://pub.dev/packages/google_maps_flu

Jul 15, 2022

Flutter Google Map Example - Day 41

Flutter Google Map Example - Day 41

Flutter Google Map Example - Day 41 class Afgprogrammer extends Flutter100DaysOfCode { video() { return { "title": "Flutter Google Map Exa

Jan 3, 2023

Flutter plugin to display a simple flat world map with animated points in real time

Flutter plugin to display a simple flat world map with animated points in real time

Flutter Simple Map Flutter plugin to display a simple flat world map with animated points in real time. Can be used as a presentation of online users,

Dec 8, 2022

🌍 Map location picker component for flutter Based on google_maps_flutter

🌍 Map location picker component for flutter Based on google_maps_flutter

google_map_location_picker Location picker using the official google_maps_flutter. I made This plugin because google deprecated Place Picker. Using Pu

Dec 5, 2022

Flutter Google Map Example

Flutter Google Map Example

Flutter Google Map Example A Flutter application demonstrate google map. Preview Listener and Marker Compass MapTypes Plugin google_maps_flutter from

Sep 14, 2021

A Flutter package for place search using MapBox Api and for Static map image

A Flutter package for place search using MapBox Api and for Static map image

About This package provides easy api calls to MapBox Search API. Also, it contains an static map image generator 😆 . Maki Icons can be used now in ma

Dec 2, 2022

How To Integrate Customized Google Map in Flutter

How To Integrate Customized Google Map in Flutter

How To Integrate Customized Google Map in Flutter Let’s develop a customised Google Maps for the best user experience. Visit : https://medium.com/flut

Dec 6, 2022

Flutter Aris Map Application

 Flutter Aris Map Application

Flutter Aris Map Application Version 1️⃣ . 0️⃣ . 0️⃣ ➕ 1️⃣ 4️⃣ Getting Started $ git clone https://github.com/ariscybertech/aris_map.git $ flutter pac

Dec 22, 2022

A google map example for flutter

A google map example for flutter

Flutter Google Map Example - Day 41 class Afgprogrammer extends Flutter100DaysOf

Nov 24, 2022
Owner
AppTree Software, Inc
AppTree Software, Inc
A Flutter map widget inspired by Leaflet

flutter_map A Dart implementation of Leaflet for Flutter apps. Installation Add flutter_map to your pubspec: dependencies: flutter_map: any # or the

null 2.2k Jan 3, 2023
Provides beautiful animated marker clustering functionality for flutter_map. Inspired by Leaflet.markercluster

Flutter Map Marker Cluster A Dart implementation of Leaflet.markercluster for Flutter apps. This is a plugin for flutter_map package Usage Add flutter

Lorenzo Pongetti 177 Jan 2, 2023
Stateful map controller for Flutter Map

Map controller Stateful map controller for Flutter Map. Manage markers, lines and polygons. View the web demo Usage import 'dart:async'; import 'packa

null 55 Sep 15, 2022
A map tour guide mobile app based on Flutter, an AI travel notes product integrating map tour guide and UGC.

A map tour guide mobile app based on Flutter, an AI travel notes product integrating map tour guide and UGC. Through the combination of 5g + AI, colle

null 24 Jan 14, 2022
Custom map markers - Custom Map Markers Using Flutter

Custom Map Markers Not only "Everything is a widget" also "Everywhere is a widge

null 8 Oct 19, 2022
Customized google map with widget markers. Enables to show markers with widget code.

widget_marker_google_map Google map with widget markers. Set up Follow the steps on google_maps_flutter document. Usage Same as google_maps_flutter ex

Santa Takahashi 8 Dec 4, 2022
A map widget with live position updates for Flutter

Livemap A map widget with live position updates. Based on Flutter map and Geolocator. Provides a controller api to handle map state changes. Example i

null 45 Sep 28, 2022
A new flutter plugin for mapbox. You can use it for your map backgrounds inside flutter applications

A new flutter plugin for mapbox. You can use it for your map backgrounds inside flutter applications

Boris Gautier 5 Sep 14, 2022
A flutter package for select a city from svg map.

City Picker From Map A flutter package for select a city from svg map. Supported countries (+150) are here. Screenshots Getting Started In the pubspec

Ahmet ÇELİK 49 Nov 17, 2022
Flutter Tutorial - Google Map with Live Location Tracking

Flutter Tutorial - Google Map with Live Location Tracking Build Google Map app with Live Location Tracking in Flutter. ✌   App Preview Android Preview

Samuel Adekunle 10 Dec 22, 2022