google_geocoding_api 1.5.1 copy "google_geocoding_api: ^1.5.1" to clipboard
google_geocoding_api: ^1.5.1 copied to clipboard

This Package implement Google Geocoding API with default and reverse geosearch

example/main.dart

import 'package:google_geocoding_api/google_geocoding_api.dart';

Future<void> main() async {
  const String googelApiKey = 'YOUR_API_KEY';
  final bool isDebugMode = true;
  final api = GoogleGeocodingApi(googelApiKey, isLogged: isDebugMode);
  final searchResults = await api.search('Boston', language: 'uk');

  print(searchResults);
  for (var res in searchResults.results) {
    print(res.mapToPretty());
  }

  final reversedSearchResults = await api.reverse(
    '42.360083,-71.05888',
    language: 'en',
  );
  print(reversedSearchResults);
  for (var res in reversedSearchResults.results) {
    print(res.mapToPretty());
  }
  final placeSearchResults = await api.placeGeocoding(
    'ChIJd8BlQ2BZwokRAFUEcm_qrcA',
    language: 'en',
  );
  print(placeSearchResults);
  for (var res in placeSearchResults.results) {
    print(res.mapToPretty());
  }
  final prettyAddress = placeSearchResults.results.firstOrNull?.mapToPretty();

  if (prettyAddress == null) {
    return;
  }

  print(prettyAddress.postalCode);
  print(prettyAddress.streetNumber);
  print(prettyAddress.streetName);
  print(prettyAddress.city);
  print(prettyAddress.state);
  print(prettyAddress.placeId);
  print(prettyAddress.country);
  print(prettyAddress.address);
  print(prettyAddress.countryCode);
  print(prettyAddress.latitude);
  print(prettyAddress.longitude);
}
38
likes
160
points
5.84k
downloads

Publisher

unverified uploader

Weekly Downloads

This Package implement Google Geocoding API with default and reverse geosearch

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

dio

More

Packages that depend on google_geocoding_api