Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexpechkarev/google-geocoder
Google Geocoder API v3 for Laravel
https://github.com/alexpechkarev/google-geocoder
geocoding-responses google-geocoder laravel php
Last synced: 13 days ago
JSON representation
Google Geocoder API v3 for Laravel
- Host: GitHub
- URL: https://github.com/alexpechkarev/google-geocoder
- Owner: alexpechkarev
- License: mit
- Created: 2014-07-12T18:32:57.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-09-27T12:56:26.000Z (about 7 years ago)
- Last Synced: 2024-10-14T02:25:27.226Z (25 days ago)
- Topics: geocoding-responses, google-geocoder, laravel, php
- Language: PHP
- Homepage:
- Size: 128 KB
- Stars: 74
- Watchers: 6
- Forks: 13
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Google Geocoder API
======================
[![Build Status](https://travis-ci.org/alexpechkarev/google-geocoder.svg?branch=master)](https://travis-ci.org/alexpechkarev/google-geocoder)This package provides simple facility to make [**The Google Geocoding API v3**](https://developers.google.com/maps/documentation/geocoding/) calls with [**Laravel 5**](http://laravel.com/).
See [*Collection of Google Maps API Web Services for Laravel*](https://github.com/alexpechkarev/google-maps) that also includes Google Geocoding API v3.
**Laravel 5**
======================Dependency
------------
[**PHP cURL**](http://php.net/manual/en/curl.installation.php) requiredInstallation
------------To install edit `composer.json` and add following line:
```javascript
"alexpechkarev/google-geocoder": "dev-master"
```Run `composer update`
Configuration
-------------Once installed, register Laravel service provider, in your `config/app.php`:
```php
'providers' => array(
...
'Alexpechkarev\GoogleGeocoder\GoogleGeocoderServiceProvider',
)
```Next, create a `config/google-geocoder.php`, containing:
```php
'my-api-key',/*
|--------------------------------------------------------------------------
| Request URL
|--------------------------------------------------------------------------
|
*/
'requestUrl' => [
'json' => 'https://maps.googleapis.com/maps/api/geocode/json?',
'xml' => 'https://maps.googleapis.com/maps/api/geocode/xml?'
],
];
```**Slim 3**
======================
Settings
-------------
```php
return [
'settings' => [
/* slim settings */
'displayErrorDetails' => true,'determineRouteBeforeAppMiddleware' => true,
'google' => [
'geocoder' => [
'applicationKey' => 'my-api-key',
'requestUrl' => [
'json' => 'https://maps.googleapis.com/maps/api/geocode/json?',
'xml' => 'https://maps.googleapis.com/maps/api/geocode/xml?'
]
]
]
]
];
```Container Dependency
-------------
```php
use GoogleGeocoder\GoogleGeocoder;$container['GeoCoder'] = function ($container) {
return new GoogleGeocoder($container->get('settings')['google']['geocoder']);
};
```
Using
------
```php
$gc = $this->container['GeoCoder'];
```Usage
======================Before making calls please ensure you obtain API Key to identify your application and add this key in the configuration file.
More information on API Key please refer to [**The Google Geocoding API**](https://developers.google.com/maps/documentation/geocoding/#api_key).```php
'applicationKey' => 'your-api-key',
```Create an array with key=>value pairs specifying address you would like to geocode:
```php
$param = array("address"=>"76 Buckingham Palace Road London SW1W 9TQ");
```Use following command to receive Geocoding response in json format, use xml as first parameter for XML response.
```php
$response = \Geocoder::geocode('json', $param);
```To restrict your results to a specific area use component filter [**Component Filtering**](https://developers.google.com/maps/documentation/geocoding/#ComponentFiltering)
by adding it's filters to parameter array.```php
$param = array(
"address"=>"76 Buckingham Palace Road London SW1W 9TQ",
"components"=>"country:GB"
);
```Geocoding API supports translation of map coordinates into human-readable address
by reverse geocoding using latitude and longitude parameters. For more details
refer to [**Reverse Geocoding**](https://developers.google.com/maps/documentation/geocoding/#ReverseGeocoding)
To make reverse geocoding request use following:```php
$param = array("latlng"=>"40.714224,-73.961452");
$response = \Geocoder::geocode('json', $param);
```All requests will return `string` value. For Response example, Status Codes,
Error Messages and Results please refer to [**Geocoding Responses**]
(https://developers.google.com/maps/documentation/geocoding/#GeocodingResponses)Support
-------[Please open an issue on GitHub](https://github.com/alexpechkarev/google-geocoder/issues)
License
-------Google Geocoder for Laravel 5 is released under the MIT License. See the bundled
[LICENSE](https://github.com/alexpechkarev/google-geocoder/blob/master/LICENSE)
file for details.