Skip to content

Commit

Permalink
fix: multiple bugs when neither wmsOptions nor urlTemplate were p…
Browse files Browse the repository at this point in the history
…rovided (#1701)
  • Loading branch information
JaffaKetchup authored Oct 23, 2023
1 parent 83d773d commit ea79e2a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/src/layer/tile_layer/tile_layer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ class TileLayer extends StatefulWidget {

// Retina Mode Setup
resolvedRetinaMode = (retinaMode ?? false)
? wmsOptions == null && urlTemplate!.contains('{r}')
? wmsOptions == null && (urlTemplate?.contains('{r}') ?? false)
? RetinaMode.server
: RetinaMode.simulation
: RetinaMode.disabled;
Expand Down
18 changes: 11 additions & 7 deletions lib/src/layer/tile_layer/tile_provider/base_tile_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,20 @@ abstract class TileProvider {
/// 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.
/// {@endtemplate}
String getTileUrl(TileCoordinates coordinates, TileLayer options) =>
populateTemplatePlaceholders(
options.wmsOptions != null
? options.wmsOptions!.getUrl(
coordinates,
options.tileSize.toInt(),
options.resolvedRetinaMode == RetinaMode.simulation,
)
: options.urlTemplate!,
options.wmsOptions?.getUrl(
coordinates,
options.tileSize.toInt(),
options.resolvedRetinaMode == RetinaMode.simulation,
) ??
options.urlTemplate ??
(throw ArgumentError(
'`wmsOptions` or `urlTemplate` must be provided to generate a tile URL')),
coordinates,
options,
);
Expand Down

0 comments on commit ea79e2a

Please sign in to comment.