geocoder-php/google-maps-places-provider

Geocoder Google Maps Places adapter

1.0.0 2019-08-14 12:58 UTC

README

Build Status Latest Stable Version Total Downloads Monthly Downloads Code Coverage Quality Score Software License

This is the Google Maps Places provider from the PHP Geocoder. This is a READ ONLY repository. See the main repo for information and documentation.

Install

composer require geocoder-php/google-maps-places-provider

API Documentation

https://developers.google.com/places/web-service

Usage

This provider often requires extra data when making queries, due to requirements of the underlying places API.

Geocoding

This provider supports two different modes of geocoding by text.

Find Mode

This is the default mode. It required an exact places name. It's not very forgiving, and generally only returns a single result

Search Mode

This mode will perform a search based on the input text. It's a lot more forgiving that the find mode, but results will contain all fields and thus be billed at the highest rate.

$findResults = $provider->geocodeQuery(GeocodeQuery::create('Museum of Contemporary Art Australia')); // One Result

$searchResults = $provider->geocodeQuery(GeocodeQuery::create('art museum sydney'))
                    ->withData('mode', GoogleMapsPlaces::GEOCODE_MODE_SEARCH); // 20 Results

Reverse Geocoding

When reverse geocoding, you are required to supply either a keyword, type or name. See https://developers.google.com/places/web-service/search#PlaceSearchRequests

$results = $provider->reverseQuery(ReverseQuery::fromCoordinates(-33.892674, 151.200727)->withData('type', 'bar'));

Contribute

Contributions are very welcome! Send a pull request to the main repository or report any issues you find on the issue tracker.