getTileUrl method

String getTileUrl(
  1. Coords<num> coords,
  2. TileLayerOptions options
)

Generate a valid URL for a tile, based on it's coordinates and the current TileLayerOptions

Implementation

String getTileUrl(Coords coords, TileLayerOptions options) {
  final urlTemplate = (options.wmsOptions != null)
      ? options.wmsOptions!
          .getUrl(coords, options.tileSize.toInt(), options.retinaMode)
      : options.urlTemplate;

  final z = _getZoomForUrl(coords, options);

  final data = <String, String>{
    'x': coords.x.round().toString(),
    'y': coords.y.round().toString(),
    'z': z.round().toString(),
    's': getSubdomain(coords, options),
    'r': '@2x',
  };
  if (options.tms) {
    data['y'] = invertY(coords.y.round(), z.round()).toString();
  }
  final allOpts = Map<String, String>.from(data)
    ..addAll(options.additionalOptions);
  return options.templateFunction(urlTemplate!, allOpts);
}