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. int? minNativeZoom,
  8. int? 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. TileDisplay tileDisplay = const TileDisplay.fadeIn(),
  21. bool retinaMode = false,
  22. ErrorTileCallBack? errorTileCallback,
  23. TemplateFunction templateFunction = util.template,
  24. TileBuilder? tileBuilder,
  25. EvictErrorTileStrategy evictErrorTileStrategy = EvictErrorTileStrategy.none,
  26. Stream<void>? reset,
  27. LatLngBounds? tileBounds,
  28. TileUpdateTransformer? tileUpdateTransformer,
  29. 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;