Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: multiple bugs when neither wmsOptions nor urlTemplate were provided #1701

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')),
TesteurManiak marked this conversation as resolved.
Show resolved Hide resolved
coordinates,
options,
);
Expand Down