Skip to content

Latest commit

 

History

History
95 lines (69 loc) · 2.71 KB

File metadata and controls

95 lines (69 loc) · 2.71 KB

Place Search API

The Place Search API Web Service allows you to query for place information on a variety of categories, such as: establishments, prominent points of interest, geographic locations, and more. You can search for places either by proximity or a text string. A Place Search returns a list of places along with summary information about each place.

Dependencies

The Place Autocomplete API requires an http client and a serializer. The library relies respectively on Httplug which is an http client abstraction library and the Ivory Serializer which is an advanced (de)-serialization library.

To install them, read this documentation.

Configuration

By default, the place search service is disabled. In order to enable the service, you need to configure it.

Http client and message factory

The http client and message factory are mandatory. They define which http client and message factory the place search service will use for issuing http requests.

First, configure the Httplug bundle.

httplug:
    classes:
        client: Http\Adapter\Guzzle7\Client
        message_factory: Http\Message\MessageFactory\GuzzleMessageFactory
    clients:
        acme:
            factory: httplug.factory.guzzle7

Then, configure the Google Map bundle:

ivory_google_map:
    place_search:
        client: httplug.client.default
        message_factory: httplug.message_factory.default

Format

The format allows you to use json/xml format for your http request:

ivory_google_map:
    place_search:
        format: json

Api key

The API key allows you to bypass Google limitation according to your account plan:

ivory_google_map:
    place_search:
        api_key: ~

Business account

The business account allows you to use Google Premium account:

ivory_google_map:
    place_search:
        business_account:
            client_id: ~
            secret: ~
            channel: ~

Usage

Once you have configured your place search service, you can fetch it from the container and use it as explained in the documentation.

use Ivory\GoogleMap\Base\Coordinate;
use Ivory\GoogleMap\Service\Place\Search\Request\NearbyPlaceSearchRequest;
use Ivory\GoogleMap\Service\Place\Search\Request\PlaceSearchRankBy;

$request = new NearbyPlaceSearchRequest(
    new Coordinate(-33.8670522, 151.1957362),
    PlaceSearchRankBy::PROMINENCE,
    1000
);

$iterator = $this->container->get('ivory.google_map.place_search')->process($request);