Package com.google.maps
Class GeocodingApiRequest
- java.lang.Object
-
- com.google.maps.GeocodingApiRequest
-
- All Implemented Interfaces:
PendingResult<GeocodingResult[]>
public class GeocodingApiRequest extends java.lang.Object
A request for the Geocoding API.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.maps.PendingResult
PendingResult.Callback<T>
-
-
Constructor Summary
Constructors Constructor Description GeocodingApiRequest(GeoApiContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GeocodingApiRequest
address(java.lang.String address)
Creates a forward geocode foraddress
.T
await()
Performs the request synchronously.T
awaitIgnoreError()
Performs the request synchronously, ignoring exceptions while performing the request and errors returned by the server.GeocodingApiRequest
bounds(LatLng southWestBound, LatLng northEastBound)
Sets the bounding box of the viewport within which to bias geocode results more prominently.void
cancel()
Attempts to cancel the request.A
channel(java.lang.String channel)
A channel to pass with the request.GeocodingApiRequest
components(ComponentFilter... filters)
Sets the component filters.A
custom(java.lang.String parameter, java.lang.String value)
Custom parameter.A
language(java.lang.String language)
The language in which to return results.GeocodingApiRequest
latlng(LatLng latlng)
Creates a reverse geocode forlatlng
.GeocodingApiRequest
locationType(LocationType... locationTypes)
Sets the location type.protected A
param(java.lang.String key, int val)
protected A
param(java.lang.String key, com.google.maps.internal.StringJoin.UrlValue val)
protected A
param(java.lang.String key, java.lang.String val)
protected A
paramAddToList(java.lang.String key, com.google.maps.internal.StringJoin.UrlValue val)
protected A
paramAddToList(java.lang.String key, java.lang.String val)
protected java.util.Map<java.lang.String,java.util.List<java.lang.String>>
params()
GeocodingApiRequest
place(java.lang.String placeId)
Creates a forward geocode forplaceId
.GeocodingApiRequest
region(java.lang.String region)
Sets the region code, specified as a ccTLD ("top-level domain") two-character value.GeocodingApiRequest
resultType(AddressType... resultTypes)
Sets the result type.void
setCallback(PendingResult.Callback<T> callback)
protected void
validateRequest()
-
-
-
Constructor Detail
-
GeocodingApiRequest
public GeocodingApiRequest(GeoApiContext context)
-
-
Method Detail
-
validateRequest
protected void validateRequest()
-
address
public GeocodingApiRequest address(java.lang.String address)
Creates a forward geocode foraddress
.- Parameters:
address
- The address to geocode.- Returns:
- Returns this
GeocodingApiRequest
for call chaining.
-
place
public GeocodingApiRequest place(java.lang.String placeId)
Creates a forward geocode forplaceId
.- Parameters:
placeId
- The Place ID to geocode.- Returns:
- Returns this
GeocodingApiRequest
for call chaining.
-
latlng
public GeocodingApiRequest latlng(LatLng latlng)
Creates a reverse geocode forlatlng
.- Parameters:
latlng
- The location to reverse geocode.- Returns:
- Returns this
GeocodingApiRequest
for call chaining.
-
bounds
public GeocodingApiRequest bounds(LatLng southWestBound, LatLng northEastBound)
Sets the bounding box of the viewport within which to bias geocode results more prominently. This parameter will only influence, not fully restrict, results from the geocoder.For more information see Viewport Biasing.
- Parameters:
southWestBound
- The South West bound of the bounding box.northEastBound
- The North East bound of the bounding box.- Returns:
- Returns this
GeocodingApiRequest
for call chaining.
-
region
public GeocodingApiRequest region(java.lang.String region)
Sets the region code, specified as a ccTLD ("top-level domain") two-character value. This parameter will only influence, not fully restrict, results from the geocoder.For more information see Region Biasing.
- Parameters:
region
- The region code to influence results.- Returns:
- Returns this
GeocodingApiRequest
for call chaining.
-
components
public GeocodingApiRequest components(ComponentFilter... filters)
Sets the component filters. Each component filter consists of a component:value pair and will fully restrict the results from the geocoder.For more information see Component Filtering.
- Parameters:
filters
- Component filters to apply to the request.- Returns:
- Returns this
GeocodingApiRequest
for call chaining.
-
resultType
public GeocodingApiRequest resultType(AddressType... resultTypes)
Sets the result type. Specifying a type will restrict the results to this type. If multiple types are specified, the API will return all addresses that match any of the types.- Parameters:
resultTypes
- The result types to restrict to.- Returns:
- Returns this
GeocodingApiRequest
for call chaining.
-
locationType
public GeocodingApiRequest locationType(LocationType... locationTypes)
Sets the location type. Specifying a type will restrict the results to this type. If multiple types are specified, the API will return all addresses that match any of the types.- Parameters:
locationTypes
- The location types to restrict to.- Returns:
- Returns this
GeocodingApiRequest
for call chaining.
-
setCallback
public final void setCallback(PendingResult.Callback<T> callback)
Description copied from interface:PendingResult
Performs the request asynchronously, callingonResult
oronFailure
after the request has been completed.- Specified by:
setCallback
in interfacePendingResult<T>
- Parameters:
callback
- The callback to call on completion.
-
await
public final T await() throws ApiException, java.lang.InterruptedException, java.io.IOException
Description copied from interface:PendingResult
Performs the request synchronously.- Specified by:
await
in interfacePendingResult<T>
- Returns:
- The result.
- Throws:
ApiException
- Thrown if the API Returned result is an error.java.lang.InterruptedException
- Thrown when a thread is waiting, sleeping, or otherwise occupied, and the thread is interrupted.java.io.IOException
- Thrown when an I/O exception of some sort has occurred.
-
awaitIgnoreError
public final T awaitIgnoreError()
Description copied from interface:PendingResult
Performs the request synchronously, ignoring exceptions while performing the request and errors returned by the server.- Specified by:
awaitIgnoreError
in interfacePendingResult<T>
- Returns:
- The result, or null if there was any error or exception ignored.
-
cancel
public final void cancel()
Description copied from interface:PendingResult
Attempts to cancel the request.- Specified by:
cancel
in interfacePendingResult<T>
-
param
protected A param(java.lang.String key, java.lang.String val)
-
param
protected A param(java.lang.String key, int val)
-
param
protected A param(java.lang.String key, com.google.maps.internal.StringJoin.UrlValue val)
-
paramAddToList
protected A paramAddToList(java.lang.String key, java.lang.String val)
-
paramAddToList
protected A paramAddToList(java.lang.String key, com.google.maps.internal.StringJoin.UrlValue val)
-
params
protected java.util.Map<java.lang.String,java.util.List<java.lang.String>> params()
-
language
public final A language(java.lang.String language)
The language in which to return results. Note that we often update supported languages so this list may not be exhaustive.- Parameters:
language
- The language code, e.g. "en-AU" or "es".- Returns:
- Returns the request for call chaining.
- See Also:
- List of supported domain languages
-
channel
public A channel(java.lang.String channel)
A channel to pass with the request. channel is used by Google Maps API for Work users to be able to track usage across different applications with the same clientID. See Premium Plan Usage Rates and Limits.- Parameters:
channel
- String to pass with the request for analytics.- Returns:
- Returns the request for call chaining.
-
custom
public A custom(java.lang.String parameter, java.lang.String value)
Custom parameter. For advanced usage only.- Parameters:
parameter
- The name of the custom parameter.value
- The value of the custom parameter.- Returns:
- Returns the request for call chaining.
-
-