GeoService class

A service class for geocoding and location services. It provides methods to get addresses from coordinates, search for addresses, determine the current position, and calculate distances between two points.

Constructors

GeoService.new(List<String> apiKeys)
Constructor for GeoService. Takes a list of API keys for geocoding services get your api keys from https://geocode.maps.co

Properties

apiKeys List<String>
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

determinePosition() Future<GeoPoint>
Determines the current position of the device. Returns a GeoPoint representing the current location. If the location services are disabled or permissions are denied, an error is returned. Uses the geolocator package for location services. param None return A GeoPoint representing the current location. Throws an error if location services are disabled or permissions are denied. Caches the position for future use. return A GeoPoint representing the current location.
distance(GeoPoint g1, GeoPoint g2) int
Calculates the distance between two GeoPoints. Uses the geolocator package to calculate the distance in kilometers. params g1 and g2 are the two GeoPoints to calculate the distance between. return The distance in kilometers as an integer. The distance is rounded to the nearest integer. If the GeoPoints are null, an error is returned. return The distance in kilometers as an integer.
getAddress(GeoPoint? g) Future<String>
Returns the address for a given GeoPoint. If the GeoPoint is null, an empty string is returned. Uses the geocode.maps.co API for reverse geocoding. param g The GeoPoint to get the address for. return The address as a string.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
searchAddresses(String search) Future<List<List>>
Searches for addresses based on a given search string. Returns a list of addresses with their corresponding GeoPoints. Uses the geocode.maps.co API for geocoding. param search The search string to look for. return A list of addresses with their corresponding GeoPoints. Each address is represented as a list containing the address string and its GeoPoint.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited