TileLayer constructor

TileLayer({
  1. Key? key,
  2. String? urlTemplate,
  3. String? fallbackUrl,
  4. double tileSize = 256.0,
  5. double minZoom = 0.0,
  6. double maxZoom = 18.0,
  7. double? minNativeZoom,
  8. double? maxNativeZoom,
  9. bool zoomReverse = false,
  10. double zoomOffset = 0.0,
  11. Map<String, String>? additionalOptions,
  12. List<String> subdomains = const <String>[],
  13. int keepBuffer = 2,
  14. int panBuffer = 0,
  15. Color backgroundColor = const Color(0xFFE0E0E0),
  16. ImageProvider<Object>? errorImage,
  17. TileProvider? tileProvider,
  18. bool tms = false,
  19. WMSTileLayerOptions? wmsOptions,
  20. double opacity = 1.0,
  21. Duration updateInterval = const Duration(milliseconds: 200),
  22. Duration tileFadeInDuration = const Duration(milliseconds: 100),
  23. double tileFadeInStart = 0.0,
  24. double tileFadeInStartWhenOverride = 0.0,
  25. bool overrideTilesWhenUrlChanges = false,
  26. bool retinaMode = false,
  27. ErrorTileCallBack? errorTileCallback,
  28. TemplateFunction templateFunction = util.template,
  29. TileBuilder? tileBuilder,
  30. TilesContainerBuilder? tilesContainerBuilder,
  31. EvictErrorTileStrategy evictErrorTileStrategy = EvictErrorTileStrategy.none,
  32. bool fastReplace = false,
  33. Stream<void>? reset,
  34. LatLngBounds? tileBounds,
  35. 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)',
            });