TileLayer constructor
TileLayer({
- Key? key,
- String? urlTemplate,
- String? fallbackUrl,
- double tileSize = 256.0,
- double minZoom = 0.0,
- double maxZoom = 18.0,
- double? minNativeZoom,
- double? maxNativeZoom,
- bool zoomReverse = false,
- double zoomOffset = 0.0,
- Map<
String, String> ? additionalOptions, - List<
String> subdomains = const <String>[], - int keepBuffer = 2,
- int panBuffer = 0,
- Color backgroundColor = const Color(0xFFE0E0E0),
- ImageProvider<
Object> ? errorImage, - TileProvider? tileProvider,
- bool tms = false,
- WMSTileLayerOptions? wmsOptions,
- double opacity = 1.0,
- Duration updateInterval = const Duration(milliseconds: 200),
- Duration tileFadeInDuration = const Duration(milliseconds: 100),
- double tileFadeInStart = 0.0,
- double tileFadeInStartWhenOverride = 0.0,
- bool overrideTilesWhenUrlChanges = false,
- bool retinaMode = false,
- ErrorTileCallBack? errorTileCallback,
- TemplateFunction templateFunction = util.template,
- TileBuilder? tileBuilder,
- TilesContainerBuilder? tilesContainerBuilder,
- EvictErrorTileStrategy evictErrorTileStrategy = EvictErrorTileStrategy.none,
- bool fastReplace = false,
- Stream<
void> ? reset, - LatLngBounds? tileBounds,
- String userAgentPackageName = 'unknown',
Implementation
TileLayer({
super.key,
this.urlTemplate,
this.fallbackUrl,
double tileSize = 256.0,
double minZoom = 0.0,
double maxZoom = 18.0,
this.minNativeZoom,
this.maxNativeZoom,
this.zoomReverse = false,
double zoomOffset = 0.0,
Map<String, String>? additionalOptions,
this.subdomains = const <String>[],
this.keepBuffer = 2,
this.panBuffer = 0,
this.backgroundColor = const Color(0xFFE0E0E0),
this.errorImage,
TileProvider? tileProvider,
this.tms = false,
this.wmsOptions,
this.opacity = 1.0,
/// Tiles will not update more than once every `updateInterval` milliseconds
/// (default 200) when panning. It can be 0 (but it will calculating for
/// loading tiles every frame when panning / zooming, flutter is fast) This
/// can save some fps and even bandwidth (ie. when fast panning / animating
/// between long distances in short time)
Duration updateInterval = const Duration(milliseconds: 200),
Duration tileFadeInDuration = const Duration(milliseconds: 100),
this.tileFadeInStart = 0.0,
this.tileFadeInStartWhenOverride = 0.0,
this.overrideTilesWhenUrlChanges = false,
this.retinaMode = false,
this.errorTileCallback,
this.templateFunction = util.template,
this.tileBuilder,
this.tilesContainerBuilder,
this.evictErrorTileStrategy = EvictErrorTileStrategy.none,
this.fastReplace = false,
this.reset,
this.tileBounds,
String userAgentPackageName = 'unknown',
}) : updateInterval =
updateInterval <= Duration.zero ? null : updateInterval,
tileFadeInDuration =
tileFadeInDuration <= Duration.zero ? null : tileFadeInDuration,
assert(tileFadeInStart >= 0.0 && tileFadeInStart <= 1.0),
assert(tileFadeInStartWhenOverride >= 0.0 &&
tileFadeInStartWhenOverride <= 1.0),
maxZoom =
wmsOptions == null && retinaMode && maxZoom > 0.0 && !zoomReverse
? maxZoom - 1.0
: maxZoom,
minZoom =
wmsOptions == null && retinaMode && maxZoom > 0.0 && zoomReverse
? math.max(minZoom + 1.0, 0)
: minZoom,
zoomOffset = wmsOptions == null && retinaMode && maxZoom > 0.0
? (zoomReverse ? zoomOffset - 1.0 : zoomOffset + 1.0)
: zoomOffset,
tileSize = wmsOptions == null && retinaMode && maxZoom > 0.0
? (tileSize / 2.0).floorToDouble()
: tileSize,
additionalOptions = additionalOptions == null
? const <String, String>{}
: Map.from(additionalOptions),
tileProvider = tileProvider == null
? NetworkNoRetryTileProvider(
headers: {'User-Agent': 'flutter_map ($userAgentPackageName)'},
)
: (tileProvider
..headers = <String, String>{
...tileProvider.headers,
if (!tileProvider.headers.containsKey('User-Agent'))
'User-Agent': 'flutter_map ($userAgentPackageName)',
});