Search categories, packages and repositories

Package detailsv1.5.2

google_geocoding_api

This Package implement Google Geocoding API with default and reverse geosearch

AndroidiOSWebmacOSWindowsLinux
30-day downloads
12.6K
Likes
41
Pub points
160

Install package

flutter pub add google_geocoding_api

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The google_geocoding_api package provides a straightforward way to integrate Google's Geocoding API into Flutter applications, enabling both forward and reverse geolocation searches. It allows users to convert addresses into geographic coordinates and vice versa, supporting multiple platforms including Android, iOS, Web, macOS, Windows, and Linux. The package simplifies API interactions with clean, easy-to-use methods, making it ideal for location-based features in apps. It requires a valid Google Cloud Platform API key for functionality.

Use cases

  • Address to coordinates conversion
  • Reverse geocoding for location details
  • Map-based app location search
  • Location-aware weather apps
  • Delivery and logistics tracking

Key features

  • Supports forward and reverse geocoding
  • Cross-platform compatibility
  • Simple API integration
  • Built-in error handling
  • Requires Google Cloud API key

Suitable for

  • Mobile and web apps needing location services
  • Apps requiring address parsing
  • Developers using Google Maps backend
  • Location-based analytics tools
  • Real-time navigation applications

Considerations

  • Requires a Google Cloud Platform API key
  • May incur usage costs based on queries
  • Rate limits apply
  • Internet connection required
  • API key must be secured in production

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Pub License: MIT

Buy Me A Coffee


Introduction

This package implement Google Geocoding API with only dart dependency(without flutter).
Before working with the package, be sure to read Before you begin and create an API key in Google Developer Console.

USAGE

Geocoding (latitude/longitude lookup)

This is example code how to use Geocoding Search. Before use it please read Geocoding (latitude/longitude lookup)

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: 'en',
  );
}

Reverse geocoding (address lookup)

This is example code how to use Geocoding Reverse Search. Before use it please read Reverse geocoding (address lookup)

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 reversedSearchResults = await api.reverse(
    '42.360083,-71.05888',
    language: 'en',
  );
}

Place geocoding

This is example code how to use Place Geocoding. Before use it please read Place Geocoding

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 placeSearchResults = await api.placeGeocoding(
    'ChIJd8BlQ2BZwokRAFUEcm_qrcA',
    language: 'en',
  );
}

Pretty Address

Now you can use .mapToPretty() to get an instance of GeocodingPrettyAddress instance containing address, city, country, latitude, longitude, postalCode, state, countryCode, streetNumber, streetName, placeId.

Attention: The feature is experimental and may not work exactly as you need. Any suggestions for improvement may be written in the Issue Tracker.

  final placeSearchResults = await api.placeGeocoding(
    'ChIJd8BlQ2BZwokRAFUEcm_qrcA',
    language: 'en',
  );
  
  final prettyAddress = placeSearchResults.results.firstOrNull?.mapToPretty();

  if (prettyAddress == null) {
    return null;
  }

  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);

Contact and bugs

Use Issue Tracker for any questions or bug reports.

Categories

Dependencies

Dependency list 1 items

Source repository

Projects using this package

No data available yet.