Creating New Tile Providers
One common requirement is a custom TileProvider
, and potentially a custom ImageProvider
inside. This will allow your plugin to intercept all tile requests made by a map, and take your own action(s), before finally returning a tile.
Some useful steps are below, but there are more properties of a TileProvider
that can be overridden.
Extending The Base TileProvider
TileProvider
To create your own usable TileProvider
, the first step is making a class that extends
the abstract class. It is not recommended to implement
the base, as this will require overriding methods unnecessarily for most custom providers.
Overriding getImage
getImage
The majority of custom TileProviders
will want to implement their own method to retrieve tiles. This is done by overriding the getImage
method, and usually specifying your own ImageProvider
, for example:
Notice that the 'User-Agent' header has been changed. This is recommended, as it helps further differentiate your plugin's traffic from vanilla 'flutter_map' traffic.
Overriding getTileUrl
getTileUrl
Some custom TileProviders
may want to change the way URLs for tiles are generated. Note that this is quite advanced usage.
Last updated