tileProvider property

TileProvider tileProvider
final

Provider with which to load map tiles

The default is NetworkTileProvider which supports both IO and web platforms. It uses a RetryClient to retry failed requests, but that can be overriden by specifying NetworkTileProvider.httpClient.

Does not automatically cache (past Flutter's ImageCache). For options to add offline mapping, see https://docs.fleaflet.dev/tile-servers/offline-mapping.

userAgentPackageName is a TileLayer parameter, which should be passed the application's correct package name, such as 'com.example.app'. This is important to avoid blocking by tile servers due to high-levels of unidentified traffic. This is passed through to the NetworkTileProvider in a suitably formatted string, where it forms the 'User-Agent' header, overriding any custom user agent specified in the HTTP client. To override this behaviour, specify a 'User-Agent' key in the NetworkTileProvider.headers property. If no value is passed, it defaults to 'unknown'. This is all ignored on the web, where the 'User-Agent' header cannot be changed due to a limitation of Dart/browsers.

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 necessarily follow the header rules above.

Implementation

final TileProvider tileProvider;