flutter_map Docs
Project Links💝 Support Us
v3
v3
  • flutter_map
  • Getting Started
    • Installation
    • Additional Setup
    • Examples
    • How Does It Work?
      • Raster vs Vector Tiles
  • Usage
    • Base Widget
    • Options
      • Recommended Options
      • Other Options
    • Layers
      • Tile Layer
        • Recommended Options
        • Tile Providers
        • Other Options
      • Marker Layer
      • Polygon Layer
      • Polyline Layer
      • Circle Layer
      • Attribution Layer
      • WMS Usage
    • Controller
    • Full API Reference
  • Plugins
    • Plugins List
    • Making A Plugin
      • Creating New Tile Providers
      • Creating New Layers
  • Tile Servers
    • Using Mapbox
    • Using Stadia Maps
    • Using Thunderforest
    • Offline Mapping
    • Other Options
  • FAQs
    • Frequently Asked Questions
    • Map Controller Issues
  • Migration
    • To v3.0.0
    • To v2.0.0
    • Older Versions
      • To v1.1.0
      • To v1.0.0
      • To v0.15.0
  • Contributing
  • Credits
Powered by GitBook

© flutter_map Authors & Maintainers

On this page
  • Center (center)
  • Zooms (zoom, minZoom, maxZoom)
  • Boundaries (bounds, maxBounds)
  • Rotation (rotation)
  • Keep Alive (keepAlive)

Was this helpful?

Export as PDF
  1. Usage
  2. Options

Recommended Options

PreviousOptionsNextOther Options

Last updated 2 years ago

Was this helpful?

Center (center)

Takes a LatLng object, specifying the latitude and longitude of the center of the map when it is first built. For example:

        center: LatLng(0.0, 0.0),

will put the map at '' on first build, where the Prime Meridian and Equator intersect at 0 deg Latitude and 0 deg Longitude.

Defaults to LatLng(50.5, 30.51).

Zooms (zoom, minZoom, maxZoom)

Takes doubles, but should usually be set initially to integers (in double format).

For an explanation of zoom levels, see the page.

zoom specifies what the zoom level of the map should be when it is first built, defaulting to level 13. maxZoom specifies what the maximum zoom level can be, and should depend on your use case and/or tile server. minZoom specifies what the minimum zoom level can be, and should usually be set to 0/null default.

        zoom: 13.0,
        maxZoom: 19.0,

Note that many tile servers will not support past a zoom level of 18. Always specify the maxZoom below the maximum zoom level of the server, to avoid your users seeing a void of grey tiles.

The OpenStreetMap Tile Server supports up to level 19, and a small amount of other servers support up to level 22.

Boundaries (bounds, maxBounds)

Takes LatLngBounds to restrict the map view within a rectangular area.

bounds is only effective on first build, and is an alternative to using center and zoom to initialise the map. maxBounds is persistent and prevents the view moving outside of the area. For example:

        bounds: LatLngBounds(
            LatLng(51.74920, -0.56741),
            LatLng(51.25709, 0.34018),
        ),
        maxBounds: LatLngBounds(
            LatLng(-90, -180.0),
            LatLng(90.0, 180.0),
        ),

will make the map center on London at first, and ensure that the gray void around the world cannot appear on screen (in the default projection).

Always specify your center within your boundaries to avoid errors. Boundaries will take preference over center.

Rotation (rotation)

Takes a double specifying the bearing of the map when it is first built. For example:

        rotation: 180.0,

will put the South of the map at the top of the device.

Defaults to 0(°).

Keep Alive (keepAlive)

If you are using a more complex layout in your application - such as using the map inside a ListView, a PageView, or a tabbed layout - you may find that the map resets when it appears/scrolls back into view. This option is designed to prevent that.

Takes a bool flag, toggling whether the internal map state should wantKeepAlive.

        keepAlive: true,

Defaults to false.

Overuse of this option may lead to performance issues.

It prevents the Flutter VM from freeing up as much memory, and it must remain processing any events that may happen to it.

Null Island
How Does It Work?