Skip to content

Latest commit

 

History

History
78 lines (49 loc) · 1.58 KB

place_autocomplete_default_request.md

File metadata and controls

78 lines (49 loc) · 1.58 KB

Place Autocomplete Request

An autocomplete request allows you to find place predictions based on user input.

Build

First of all, let's build a place autocomplete request:

use Ivory\GoogleMap\Service\Place\Autocomplete\Request\PlaceAutocompleteRequest;

$request = new PlaceAutocompleteRequest('Sydney');

The place autocomplete request constructor requires the user input as first argument.

Configure input

If you want to update the user input, you can use:

$request->setInput('Sydney');

Configure offset

The offset is the position, in the input term, of the last character that the service uses to match predictions:

$request->setOffset(3);

Configure location

The location is the point around which you wish to retrieve place information:

use Ivory\GoogleMap\Base\Coordinate;

$request->setLocation(new Coordinate(48.865475, 2.321118));

Configure radius

The distance (in meters) within which to return place results:

$request->setRadius(200);

Configure types

The types of place results to return:

$request->setTypes([AutocompleteType::GEOCODE]);

Configure components

A grouping of places to which you would like to restrict your results:

use Ivory\GoogleMap\Place\AutocompleteComponentType;

$request->setComponents([
    AutocompleteComponentType::POSTAL_CODE => 59800,
    AutocompleteComponentType::COUNTRY   => 'fr',
]);

Configure language

The language code, indicating in which language the results should be returned, if possible:

$request->setLanguage('fr');