littie/geolocation

Work with geolocation google API


Keywords
laravel
License
MIT

Documentation

Geolocation package

1) Install package

  • Add "littie/geolocation": "~0.0" in your require-dev section of main composer.json progect file
  • Execute **composer update**

2) Config package

  • In your config/app.php file in provider array add GeolocationServiceProvider
    Littie\Geolocation\GeolocationServiceProvider::class
  • In your config/app.php file in aliases array add Geolocation facade
    'Geolocation' => Littie\Geolocation\Facade\Geolocation::class
  • In command line type php artisan vendor:publish .
    Its command add in your config folder geolocation.php file

Use package

Get geolocation:
Route::get('geolocation', function() {
$geolocation = new Geolocation('1600 Amphitheatre Parkway, Mountain View, CA', 'geolocation');
dd($geolocation->getGeolocationCoordinates()); });

Get reverse geolocation:
Route::get('reverse', function() {
$geolocation = new Geolocation('40.714224,-73.961452', 'reverse');
dd($geolocation->getReverseCoordinates());

Object geolocation receive two parameters, coordinates and type
coordinates are coordinates which you want find type is type of query, can be 'geolocation' for get coordinates and 'reverse' for get address

Geolocation config file

'method' => 'GET' - query method
'key' => '' - google API programm key
'verify' => false - ssl sertificate
'language' => 'ru' - results language
'format' => 'json' - receive data format json or xml