↳
android.location.Geocoder
Class Overview
A class for handling geocoding and reverse geocoding. Geocoding is
the process of transforming a street address or other description
of a location into a (latitude, longitude) coordinate. Reverse
geocoding is the process of transforming a (latitude, longitude)
coordinate into a (partial) address. The amount of detail in a
reverse geocoded location description may vary, for example one
might contain the full street address of the closest building, while
another might contain only a city name and postal code.
The Geocoder class requires a backend service that is not included in
the core android framework. The Geocoder query methods will return an
empty list if there no backend service in the platform. Use the
isPresent() method to determine whether a Geocoder implementation
exists.
Summary
Public Constructors
Constructs a Geocoder whose responses will be localized for the
given Locale.
Constructs a Geocoder whose responses will be localized for the
default system Locale.
Public Methods
Returns an array of Addresses that are known to describe the
area immediately surrounding the given latitude and longitude.
String locationName, int maxResults, double lowerLeftLatitude, double lowerLeftLongitude, double upperRightLatitude, double upperRightLongitude)
Returns an array of Addresses that are known to describe the
named location, which may be a place name such as "Dalvik,
Iceland", an address such as "1600 Amphitheatre Parkway,
Mountain View, CA", an airport code such as "SFO", etc..
String locationName, int maxResults)
Returns an array of Addresses that are known to describe the
named location, which may be a place name such as "Dalvik,
Iceland", an address such as "1600 Amphitheatre Parkway,
Mountain View, CA", an airport code such as "SFO", etc..
static
boolean
Returns true if the Geocoder methods getFromLocation and
getFromLocationName are implemented.
[Expand]
Inherited Methods
From class
java.lang.Object
Creates and returns a copy of this Object.
boolean
Compares this instance with the specified object and indicates if they
are equal.
void
Invoked when the garbage collector has detected that this instance is no longer reachable.
final
Class>
Returns the unique instance of
int
Returns an integer hash code for this object.
final
void
Causes a thread which is waiting on this object's monitor (by means of
calling one of the wait() methods) to be woken up.
final
void
Causes all threads which are waiting on this object's monitor (by means
of calling one of the wait() methods) to be woken up.
Returns a string containing a concise, human-readable description of this
object.
final
void
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.
final
void
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
final
void
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
Public Constructors
public
Geocoder
(Context context, Locale locale)
Constructs a Geocoder whose responses will be localized for the
given Locale.
Parameters
contextthe Context of the calling Activity
localethe desired Locale for the query results
Throws
public
Geocoder
(Context context)
Constructs a Geocoder whose responses will be localized for the
default system Locale.
Parameters
contextthe Context of the calling Activity
Public Methods
getFromLocation
(double latitude, double longitude, int maxResults)
Returns an array of Addresses that are known to describe the
area immediately surrounding the given latitude and longitude.
The returned addresses will be localized for the locale
provided to this class's constructor.
The returned values may be obtained by means of a network lookup.
The results are a best guess and are not guaranteed to be meaningful or
correct. It may be useful to call this method from a thread separate from your
primary UI thread.
Parameters
latitudethe latitude a point for the search
longitudethe longitude a point for the search
maxResultsmax number of addresses to return. Smaller numbers (1 to 5) are recommended
Returns
a list of Address objects. Returns null or empty list if no matches were
found or there is no backend service available.
Throws
if latitude is
less than -90 or greater than 90
if longitude is
less than -180 or greater than 180
if the network is unavailable or any other
I/O problem occurs
getFromLocationName
(String locationName, int maxResults, double lowerLeftLatitude, double lowerLeftLongitude, double upperRightLatitude, double upperRightLongitude)
Returns an array of Addresses that are known to describe the
named location, which may be a place name such as "Dalvik,
Iceland", an address such as "1600 Amphitheatre Parkway,
Mountain View, CA", an airport code such as "SFO", etc.. The
returned addresses will be localized for the locale provided to
this class's constructor.
You may specify a bounding box for the search results by including
the Latitude and Longitude of the Lower Left point and Upper Right
point of the box.
The query will block and returned values will be obtained by means of a network lookup.
The results are a best guess and are not guaranteed to be meaningful or
correct. It may be useful to call this method from a thread separate from your
primary UI thread.
Parameters
locationNamea user-supplied description of a location
maxResultsmax number of addresses to return. Smaller numbers (1 to 5) are recommended
lowerLeftLatitudethe latitude of the lower left corner of the bounding box
lowerLeftLongitudethe longitude of the lower left corner of the bounding box
upperRightLatitudethe latitude of the upper right corner of the bounding box
upperRightLongitudethe longitude of the upper right corner of the bounding box
Returns
a list of Address objects. Returns null or empty list if no matches were
found or there is no backend service available.
Throws
if any latitude is
less than -90 or greater than 90
if any longitude is
less than -180 or greater than 180
if the network is unavailable or any other
I/O problem occurs
getFromLocationName
(String locationName, int maxResults)
Returns an array of Addresses that are known to describe the
named location, which may be a place name such as "Dalvik,
Iceland", an address such as "1600 Amphitheatre Parkway,
Mountain View, CA", an airport code such as "SFO", etc.. The
returned addresses will be localized for the locale provided to
this class's constructor.
The query will block and returned values will be obtained by means of a network lookup.
The results are a best guess and are not guaranteed to be meaningful or
correct. It may be useful to call this method from a thread separate from your
primary UI thread.
Parameters
locationNamea user-supplied description of a location
maxResultsmax number of results to return. Smaller numbers (1 to 5) are recommended
Returns
a list of Address objects. Returns null or empty list if no matches were
found or there is no backend service available.
Throws
if the network is unavailable or any other
I/O problem occurs
public
static
boolean
isPresent
()
Returns true if the Geocoder methods getFromLocation and
getFromLocationName are implemented. Lack of network
connectivity may still cause these methods to return null or
empty lists.
Except as noted, this content is licensed under Apache 2.0.
For details and restrictions, see the Content License.
Android 4.4 r1 —