populateTemplatePlaceholders method

  1. @visibleForOverriding
String populateTemplatePlaceholders(
  1. String urlTemplate,
  2. TileCoordinates coordinates,
  3. TileLayer options
)

Replaces placeholders in the form templatePlaceholderElement with their corresponding values

Avoid using this externally, instead use getTileUrl (which uses this) to automatically handle WMS usage.


When creating a specialized TileProvider, prefer overriding URL generation related methods in the following order:

  1. populateTemplatePlaceholders
  2. generateReplacementMap
  3. getTileUrl and/or getTileFallbackUrl

Note to implementors: it is not safe to assume that at least one of wmsOptions or urlTemplate will be non-null.

Implementation

@visibleForOverriding
String populateTemplatePlaceholders(
  String urlTemplate,
  TileCoordinates coordinates,
  TileLayer options,
) {
  final replacementMap =
      generateReplacementMap(urlTemplate, coordinates, options);

  return urlTemplate.replaceAllMapped(
    templatePlaceholderElement,
    (match) {
      final value = replacementMap[match.group(1)!];
      if (value != null) return value;
      throw ArgumentError(
        'Missing value for placeholder: {${match.group(1)}}',
      );
    },
  );
}