tileProvider property

TileProvider tileProvider
latefinal

Provider with which to load map tiles

The default is NetworkNoRetryTileProvider. Alternatively, use NetworkTileProvider for a network provider which will retry requests.

Both network providers will use some form of caching, although not reliable. For better options, see https://docs.fleaflet.dev/usage/layers/tile-layer#caching.

userAgentPackageName is a construction parameter, which should be passed the application's correct package name, such as 'com.example.app'. If no value is passed, it defaults to 'unknown'. This parameter is used to form part of the 'User-Agent' header, which is important to avoid blocking by tile servers. Namely, the header is the following 'flutter_map (

Header rules are as follows, after 'User-Agent' is generated as above:

  • If no provider is specified here, the default will be used with 'User-Agent' header injected (recommended)
  • If a provider is specified here with no 'User-Agent' header, that provider will be used and the 'User-Agent' header will be injected
  • If a provider is specified here with a 'User-Agent' header, that provider will be used and the 'User-Agent' header will not be changed to any created here

AssetTileProvider and FileTileProvider are alternatives to network providers, which use the urlTemplate as a path instead. For example, 'assets/map/{z}/{x}/{y}.png' or '/storage/emulated/0/map_app/tiles/{z}/{x}/{y}.png'.

Custom TileProviders can also be used, but these will not follow the header rules above.

Implementation

late final TileProvider tileProvider;