Package com.google.maps
Class PlaceAutocompleteRequest
- java.lang.Object
-
- com.google.maps.PlaceAutocompleteRequest
-
- All Implemented Interfaces:
PendingResult<AutocompletePrediction[]>
public class PlaceAutocompleteRequest extends java.lang.ObjectA Place Autocomplete request.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPlaceAutocompleteRequest.Responsestatic classPlaceAutocompleteRequest.SessionTokenSessionToken represents an Autocomplete session.-
Nested classes/interfaces inherited from interface com.google.maps.PendingResult
PendingResult.Callback<T>
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPlaceAutocompleteRequest(GeoApiContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Tawait()Performs the request synchronously.TawaitIgnoreError()Performs the request synchronously, ignoring exceptions while performing the request and errors returned by the server.voidcancel()Attempts to cancel the request.Achannel(java.lang.String channel)A channel to pass with the request.PlaceAutocompleteRequestcomponents(ComponentFilter... filters)A grouping of places to which you would like to restrict your results.Acustom(java.lang.String parameter, java.lang.String value)Custom parameter.PlaceAutocompleteRequestinput(java.lang.String input)Sets the text string on which to search.Alanguage(java.lang.String language)The language in which to return results.PlaceAutocompleteRequestlocation(LatLng location)The point around which you wish to retrieve place information.PlaceAutocompleteRequestoffset(int offset)The character position in the input term at which the service uses text for predictions.protected Aparam(java.lang.String key, int val)protected Aparam(java.lang.String key, com.google.maps.internal.StringJoin.UrlValue val)protected Aparam(java.lang.String key, java.lang.String val)protected AparamAddToList(java.lang.String key, com.google.maps.internal.StringJoin.UrlValue val)protected AparamAddToList(java.lang.String key, java.lang.String val)protected java.util.Map<java.lang.String,java.util.List<java.lang.String>>params()PlaceAutocompleteRequestradius(int radius)The distance (in meters) within which to return place results.PlaceAutocompleteRequestsessionToken(PlaceAutocompleteRequest.SessionToken sessionToken)Sets the SessionToken for this request.voidsetCallback(PendingResult.Callback<T> callback)PlaceAutocompleteRequeststrictBounds(boolean strictBounds)StrictBounds returns only those places that are strictly within the region defined by location and radius.PlaceAutocompleteRequesttype(PlaceAutocompleteType type)Deprecated.Please usetypesinstead.PlaceAutocompleteRequesttypes(PlaceAutocompleteType types)Restricts the results to places matching the specified type.protected voidvalidateRequest()
-
-
-
Constructor Detail
-
PlaceAutocompleteRequest
protected PlaceAutocompleteRequest(GeoApiContext context)
-
-
Method Detail
-
sessionToken
public PlaceAutocompleteRequest sessionToken(PlaceAutocompleteRequest.SessionToken sessionToken)
Sets the SessionToken for this request. Using session token makes sure the autocomplete is priced per session, instead of per keystroke.- Parameters:
sessionToken- Session Token is the session identifier.- Returns:
- Returns this
PlaceAutocompleteRequestfor call chaining.
-
input
public PlaceAutocompleteRequest input(java.lang.String input)
Sets the text string on which to search. The Places service will return candidate matches based on this string and order results based on their perceived relevance.- Parameters:
input- The input text to autocomplete.- Returns:
- Returns this
PlaceAutocompleteRequestfor call chaining.
-
offset
public PlaceAutocompleteRequest offset(int offset)
The character position in the input term at which the service uses text for predictions. For example, if the input is 'Googl' and the completion point is 3, the service will match on 'Goo'. The offset should generally be set to the position of the text caret. If no offset is supplied, the service will use the entire term.- Parameters:
offset- The character offset position of the user's cursor.- Returns:
- Returns this
PlaceAutocompleteRequestfor call chaining.
-
location
public PlaceAutocompleteRequest location(LatLng location)
The point around which you wish to retrieve place information.- Parameters:
location- TheLatLnglocation to center this autocomplete search.- Returns:
- Returns this
PlaceAutocompleteRequestfor call chaining.
-
radius
public PlaceAutocompleteRequest radius(int radius)
The distance (in meters) within which to return place results. Note that setting a radius biases results to the indicated area, but may not fully restrict results to the specified area.- Parameters:
radius- The radius over which to bias results.- Returns:
- Returns this
PlaceAutocompleteRequestfor call chaining.
-
type
public PlaceAutocompleteRequest type(PlaceAutocompleteType type)
Deprecated.Please usetypesinstead.Restricts the results to places matching the specified type.- Parameters:
type- The type to restrict results to.- Returns:
- Returns this
PlaceAutocompleteRequestfor call chaining.
-
types
public PlaceAutocompleteRequest types(PlaceAutocompleteType types)
Restricts the results to places matching the specified type.- Parameters:
types- The type to restrict results to.- Returns:
- Returns this
PlaceAutocompleteRequestfor call chaining.
-
components
public PlaceAutocompleteRequest components(ComponentFilter... filters)
A grouping of places to which you would like to restrict your results. Currently, you can use components to filter by country.- Parameters:
filters- The component filter to restrict results with.- Returns:
- Returns this
PlaceAutocompleteRequestfor call chaining.
-
strictBounds
public PlaceAutocompleteRequest strictBounds(boolean strictBounds)
StrictBounds returns only those places that are strictly within the region defined by location and radius. This is a restriction, rather than a bias, meaning that results outside this region will not be returned even if they match the user input.- Parameters:
strictBounds- Whether to strictly bound results.- Returns:
- Returns this
PlaceAutocompleteRequestfor call chaining.
-
validateRequest
protected void validateRequest()
-
setCallback
public final void setCallback(PendingResult.Callback<T> callback)
Description copied from interface:PendingResultPerforms the request asynchronously, callingonResultoronFailureafter the request has been completed.- Specified by:
setCallbackin interfacePendingResult<T>- Parameters:
callback- The callback to call on completion.
-
await
public final T await() throws ApiException, java.lang.InterruptedException, java.io.IOExceptionDescription copied from interface:PendingResultPerforms the request synchronously.- Specified by:
awaitin 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:PendingResultPerforms the request synchronously, ignoring exceptions while performing the request and errors returned by the server.- Specified by:
awaitIgnoreErrorin interfacePendingResult<T>- Returns:
- The result, or null if there was any error or exception ignored.
-
cancel
public final void cancel()
Description copied from interface:PendingResultAttempts to cancel the request.- Specified by:
cancelin 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.
-
-