buildMapUri static method
Builds a URI for launching a map application or web map.
query - The map query (e.g., "Eiffel Tower", "34.0522,-118.2437").
queryParameters - Optional additional query parameters for the map URI.
Returns a Uri for a map search. Defaults to Google Maps.
Implementation
static Uri buildMapUri(String? query,
{Map<String, dynamic>? queryParameters}) {
final mapQueryParams = {
'api': '1', // Google Maps API version
'query': query,
...?queryParameters,
};
// Ensure all query parameters are String? for Uri.https
final Map<String, String?> stringMapQuery = mapQueryParams.map(
(key, val) => MapEntry(key, val?.toString()),
);
return Uri.https(
'www.google.com',
'/maps/search/',
stringMapQuery,
);
}