processBatch static method
Processes multiple Google Maps URLs in batch.
This method processes a list of URLs and returns a list of results. Each result contains the location information for the corresponding URL, or null if the URL could not be processed.
Example usage:
final urls = [
'https://maps.app.goo.gl/mWtb4a1cUE9zMWya7',
'https://www.google.com/maps/@37.7749,-122.4194,15z',
];
final results = await GoogleMapsUrlExtractor.processBatch(urls);
for (int i = 0; i < results.length; i++) {
if (results[i] != null) {
print('URL ${i + 1}: ${results[i]}');
}
}
Implementation
static Future<List<Map<String, dynamic>?>> processBatch(
List<String> urls) async {
final results = <Map<String, dynamic>?>[];
for (final url in urls) {
try {
final expandedUrl = await processGoogleMapsUrl(url);
if (expandedUrl != null) {
// Re-extract full info from the expanded URL
final fullUrl =
url.contains('goo.gl') || url.contains('maps.app.goo.gl')
? await expandShortUrl(url) ?? url
: url;
results.add(extractLocationInfo(fullUrl));
} else {
results.add(null);
}
} catch (e) {
results.add(null);
}
}
return results;
}