State and elaborate the syntax of required class and methods for
Geocoding.
Geocoder:
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.
Syntax
Geocoder (Context context)
Constructs a Geocoder localized for the default locale.
Geocoder(Context context, Locale locale)
Constructs a Geocoder localized for the given locale.
Methods with Syntax
a. getFromLocation
Syntax
public List<Address> getFromLocation (double latitude, double longitude, int
maxResults)
public void getFromLocation (double latitude, double longitude, int maxResults,
Geocoder.GeocodeListener listener)
This method returns an array of Addresses that attempt to describe the area immediately
surrounding the given latitude and longitude. The returned addresses should be localized
for the locale provided to this class's constructor.
b. getFromLocationName
Syntax :
● public List<Address> getFromLocationName (String locationName, int
maxResults, double lowerLeftLatitude, double lowerLeftLongitude, double
upperRightLatitude, double upperRightLongitude)
● public void getFromLocationName (String locationName, int maxResults,
double lowerLeftLatitude, double lowerLeftLongitude, double
upperRightLatitude, double upperRightLongitude, Geocoder.GeocodeListener
listener)
● public void getFromLocationName (String locationName, int maxResults,
Geocoder.GeocodeListener listener)
● public List<Address> getFromLocationName (String locationName, int
maxResults)
Returns an array of Addresses that attempt 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", and so forth. The returned
addresses should be localized for the locale provided to this class's constructor.
c. isPresent
Syntax
public static boolean isPresent ()
Returns true if there is a geocoder implementation present that may return results. If true,
there is still no guarantee that any individual geocoding attempt will succeed.
0 Comments