TileLayer constructor
TileLayer({
- Key? key,
- String? urlTemplate,
- String? fallbackUrl,
- double tileSize = 256.0,
- double minZoom = 0.0,
- double maxZoom = 18.0,
- int? minNativeZoom,
- int? 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,
- TileDisplay tileDisplay = const TileDisplay.fadeIn(),
- bool retinaMode = false,
- ErrorTileCallBack? errorTileCallback,
- TemplateFunction templateFunction = util.template,
- TileBuilder? tileBuilder,
- EvictErrorTileStrategy evictErrorTileStrategy = EvictErrorTileStrategy.none,
- Stream<
void> ? reset, - LatLngBounds? tileBounds,
- TileUpdateTransformer? tileUpdateTransformer,
- 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.tileDisplay = const TileDisplay.fadeIn(),
this.retinaMode = false,
this.errorTileCallback,
this.templateFunction = util.template,
this.tileBuilder,
this.evictErrorTileStrategy = EvictErrorTileStrategy.none,
this.reset,
this.tileBounds,
TileUpdateTransformer? tileUpdateTransformer,
String userAgentPackageName = 'unknown',
}) : assert(
tileDisplay.map(
instantaneous: (_) => true,
fadeIn: (fadeIn) => fadeIn.duration > Duration.zero)!,
),
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)',
}),
tileUpdateTransformer =
tileUpdateTransformer ?? TileUpdateTransformers.ignoreTapEvents;