Build 1.0_r1(from source)

android.location
Class Geocoder

java.lang.Object
  extended by android.location.Geocoder

public final class Geocoder
extends Object

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.


Constructor Summary
Geocoder(Context context)
          Constructs a Geocoder whose responses will be localized for the default system Locale.
Geocoder(Context context, Locale locale)
          Constructs a Geocoder whose responses will be localized for the given Locale.
 
Method Summary
 List<Address> 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.
 List<Address> 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..
 List<Address> 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..
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Geocoder

public Geocoder(Context context,
                Locale locale)
Constructs a Geocoder whose responses will be localized for the given Locale.

Parameters:
context - the Context of the calling Activity
locale - the desired Locale for the query results
Throws:
NullPointerException - if Locale is null

Geocoder

public Geocoder(Context context)
Constructs a Geocoder whose responses will be localized for the default system Locale.

Parameters:
context - the Context of the calling Activity
Method Detail

getFromLocation

public List<Address> getFromLocation(double latitude,
                                     double longitude,
                                     int maxResults)
                              throws IOException
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:
latitude - the latitude a point for the search
longitude - the longitude a point for the search
maxResults - max number of addresses to return. Smaller numbers (1 to 5) are recommended
Returns:
a list of Address objects or null if no matches were found.
Throws:
IllegalArgumentException - if latitude is less than -90 or greater than 90
IllegalArgumentException - if longitude is less than -180 or greater than 180
IOException - if the network is unavailable or any other I/O problem occurs

getFromLocationName

public List<Address> getFromLocationName(String locationName,
                                         int maxResults)
                                  throws IOException
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:
locationName - a user-supplied description of a location
maxResults - max number of results to return. Smaller numbers (1 to 5) are recommended
Returns:
a list of Address objects or null if no matches were found.
Throws:
IllegalArgumentException - if locationName is null
IOException - if the network is unavailable or any other I/O problem occurs

getFromLocationName

public List<Address> getFromLocationName(String locationName,
                                         int maxResults,
                                         double lowerLeftLatitude,
                                         double lowerLeftLongitude,
                                         double upperRightLatitude,
                                         double upperRightLongitude)
                                  throws IOException
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:
locationName - a user-supplied description of a location
maxResults - max number of addresses to return. Smaller numbers (1 to 5) are recommended
lowerLeftLatitude - the latitude of the lower left corner of the bounding box
lowerLeftLongitude - the longitude of the lower left corner of the bounding box
upperRightLatitude - the latitude of the upper right corner of the bounding box
upperRightLongitude - the longitude of the upper right corner of the bounding box
Returns:
a list of Address objects or null if no matches were found.
Throws:
IllegalArgumentException - if locationName is null
IllegalArgumentException - if any latitude is less than -90 or greater than 90
IllegalArgumentException - if any longitude is less than -180 or greater than 180
IOException - if the network is unavailable or any other I/O problem occurs

Build 1.0_r1(from source)

Please submit a feedback, bug or feature