FMTC Docs
Project Links💝 Support Me
v8
v8
  • flutter_map_tile_caching
  • Is FMTC Right For Me?
  • Get Started
    • Quickstart
    • Installation
    • Additional Setup
    • Example Application
  • Usage
    • Initialisation
    • Using Roots & Stores
      • Management
      • Statistics
      • Metadata
      • Recovery
      • Migrator (v6 -> v7)
    • flutter_map Integration
    • Global Settings
    • Full API Reference
  • Bulk Downloading
    • Introduction
    • 1️⃣Create A Region
    • 2️⃣Prepare For Downloading
    • 3️⃣Start In Foreground
      • Buffering
      • 4️⃣Listen For Progress
    • 3️⃣Start In Background
      • Limitations
    • Cancel Download
  • Import & Export
    • Introduction
    • Importing
    • Exporting
  • Migration
    • v7 -> v8 Migration
    • v6 -> v7 Migration
  • Known Issues
  • Credits
  • flutter_map Docs
Powered by GitBook

© Luka Stillingfleet (JaffaKetchup)

On this page
  • Types Of Region
  • Converting To Drawable Polygons

Was this helpful?

Export as PDF
  1. Bulk Downloading

Create A Region

PreviousIntroductionNextPrepare For Downloading

Last updated 2 years ago

Was this helpful?

Creating regions is designed to be easy for the user and you (the developer).

The Example Application contains a great way you might want to allow your users to choose a region to download, and it shows how to use Provider to share a created region and the number of approximate tiles it has to a download screen.

Types Of Region

All regions (before conversion to DownloadableRegion) implement BaseRegion.

The most basic type of region, defined by two North West and South East coordinates that create a LatLngBounds.

final region = RectangleRegion(
    LatLngBounds(
        LatLng(), // North West
        LatLng(), // South East
    ),
);

Skewed parallelograms (rectangles with a 3rd control point) or rotated rectangles are not currently supported

A more advanced type of region, defined by a center coordinate and radius (in kilometers).

final region = CircleRegion(
    LatLng(), // Center
    0, // KM Radius
);

If you have two coordinates, one center, and one on the edge of the circle you want, you can use method, as below:

final region = CircleRegion(
    LatLng(), // Center
    const Distance(roundResult: false).distance(
        LatLng(), // Center
        LatLng(), // Edge Coord
    ) / 1000; // Convert to KM
);

The most advanced type of region, defined by a list of coordinates and radius (in meters).

final region = LineRegion(
    [LatLng(), LatLng(), ...], // Series of coordinates
    0, // M Radius
);

After you've created your region, you can convert it to a drawable polygon (below), or ready for downloading.

Converting To Drawable Polygons

All BaseRegions can be drawn on a map with minimal effort from you or the user, using toDrawable().

Internally, this uses the toOutline(s) method to generate the points forming the Polygon, then it places this/these polygons into a PolygonLayer.

1️⃣
'latlong2's Distance.distance()
convert it to a DownloadableRegion