google_location_extract 1.0.1
google_location_extract: ^1.0.1 copied to clipboard
Extract rich location details from full and shortened Google Maps URLs.
example/google_location_extract_example.dart
// ignore_for_file: avoid_print
import 'package:google_location_extract/google_location_extract.dart';
Future<void> main() async {
const parser = GoogleMapsParser();
final directLocation = parser.parse(
'https://www.google.com/maps/place/Accra+Mall/'
'@5.6224,-0.1731,17z',
);
print(directLocation.toJson());
final extractor = GoogleMapsLocationExtractor();
try {
final sharedLocation = await extractor.extract(
'Meet me here: https://maps.app.goo.gl/example',
);
print(sharedLocation.toJson());
} on LocationExtractFormatException catch (error) {
print('Invalid Google Maps link: ${error.message}');
} on LocationExtractNetworkException catch (error) {
print('Could not resolve the link: ${error.message}');
} finally {
extractor.close();
}
}