show method
Shows the marker in a map app.
If map is null, uses the best available app from defaultMaps
(Apple Maps on iOS, Google Maps elsewhere, with fallback).
extraAdditional query parameters merged with constructorextra; values from this call take precedence on conflict.
Implementation
Future<void> show({MapApp? map, Map<String, String>? extra}) async {
final targetMap =
map ?? await resolveBestMap(() => getSupportedMaps(defaultMaps));
if (targetMap == null) {
throw UnsupportedError('No map app available for this marker request.');
}
final url = getUrl(map: targetMap);
if (url == null) {
throw UnsupportedError(
'${targetMap.name} does not support this marker type.',
);
}
// Merge constructor extra with show() extra; show() wins on conflict.
final mergedExtra = {...?this.extra, ...?extra};
final finalUrl = appendQueryParams(
url,
mergedExtra.isEmpty ? null : mergedExtra,
);
try {
await MapLauncherPlatform.instance.launch(
finalUrl,
androidPackageName: targetMap.playStoreId,
);
} on Exception {
// Scheme URL may fail if app is not installed. Fall back to universal.
final universalUrl = getUniversalUrl(map: targetMap);
if (universalUrl != null && universalUrl != finalUrl) {
final fallbackUrl = appendQueryParams(
universalUrl,
mergedExtra.isEmpty ? null : mergedExtra,
);
try {
await MapLauncherPlatform.instance.launch(
fallbackUrl,
androidPackageName: targetMap.playStoreId,
);
return;
} on Exception catch (e) {
throw MapLaunchException(
'Failed to launch ${targetMap.name}',
url: fallbackUrl,
cause: e,
);
}
}
rethrow;
}
}