Geocoder Pro
A Flutter package for easy forward and reverse geocoding using the Google Maps API.
π Features
- Forward geocoding (address to coordinates)
- Reverse geocoding (coordinates to address)
- Support for multiple languages
- Simple and intuitive API
- Comprehensive address data extraction
- No external dependencies
π Prerequisites
Before using this package, make sure to:
-
Activate the following APIs in your Google Cloud Console:
- Maps SDK for Android
- Maps SDK for iOS
- Geocoding API
-
Generate an API key with the necessary permissions
π¦ Installation
Add the following to your pubspec.yaml:
dependencies:
geocoder_pro: ^latest_version
π» Usage
Import the package
import 'package:geocoder_pro/geocoder_pro.dart';
Get Data From Coordinates (Reverse Geocoding)
GeoData data = await GeocoderPro.getDataFromCoordinates(
latitude: 40.714224,
longitude: -73.961452,
googleMapApiKey: "YOUR_GOOGLE_MAP_API_KEY",
language: "en" // Optional: specify language code
);
// Access the data
print(data.address); // Formatted address
print(data.city); // City name
print(data.country); // Country name
print(data.countryCode); // Country code
print(data.latitude); // Latitude
print(data.longitude); // Longitude
print(data.postalCode); // Postal code
print(data.state); // State/province
print(data.street_number);// Street number
Get Data From Address (Forward Geocoding)
GeoData data = await GeocoderPro.getDataFromAddress(
address: "277 Bedford Ave, Brooklyn, NY 11211, USA",
googleMapApiKey: "YOUR_GOOGLE_MAP_API_KEY",
language: "en" // Optional: specify language code
);
// Access the data
print(data.address); // Formatted address
print(data.city); // City name
print(data.country); // Country name
print(data.countryCode); // Country code
print(data.latitude); // Latitude
print(data.longitude); // Longitude
print(data.postalCode); // Postal code
print(data.state); // State/province
print(data.street_number);// Street number
π Language Support
You can specify the language parameter to get results in different languages. Check the Google Maps supported languages for available language codes.
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π€ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
β Support
If you find this package useful, consider supporting the development: