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(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
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.
paramNonereturnA GeoPoint representing the current location. Throws an error if location services are disabled or permissions are denied. Caches the position for future use.returnA 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.
paramsg1 and g2 are the two GeoPoints to calculate the distance between.returnThe distance in kilometers as an integer. The distance is rounded to the nearest integer. If the GeoPoints are null, an error is returned.returnThe 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 gThe GeoPoint to get the address for.returnThe 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 searchThe search string to look for.returnA 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