getWeatherLayerUrlTemplate method

  1. @override
String getWeatherLayerUrlTemplate({
  1. required String layer,
  2. double opacity = 0.8,
  3. Map<double, Color> palette = const {},
})
override

Should return the weather layer url template.

The url template should be formatted for use by mapping UI libraries such as flutter_map, Syncfusion maps, leaflet, etc.

Implementation

@override
String getWeatherLayerUrlTemplate({
  required String layer,
  double opacity = 0.8,
  Map<double, Color> palette = const {},
}) {
  final queryParams = {
    'appid': appId,
    'opacity': opacity.toStringAsFixed(1),
    if (palette.isNotEmpty)
      'palette': palette.entries
          .map((e) => '${e.key.toStringAsFixed(6)}:${_encodeColor(e.value)}')
          .join(';'),
  };

  final path = weatherMapUrlPath.replaceAll('{layer}', layer);

  final queryParamString = queryParams.entries
      .map((entry) => '${entry.key}=${entry.value}')
      .join('&');

  // Construct url manually as weather map path is not url encodable
  return 'https://$weatherMapUrlHost/$path?$queryParamString';
}