2017 © Pedro PelĆ”ez
 

library geocode

Google Geocoding API for Laravel

image

jcf/geocode

Google Geocoding API for Laravel

  • Monday, January 15, 2018
  • by jotafurtado
  • Repository
  • 3 Watchers
  • 37 Stars
  • 36,298 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 18 Forks
  • 2 Open issues
  • 8 Versions
  • 15 % Grown

The README.md

Google Geocoding API for Laravel

Latest Stable Version Total Downloads License, (*1)

A simple Laravel service provider for Google Geocoding API., (*2)

Installation

This package can be installed via Composer., (*3)

Run composer require command., (*4)

composer require "jcf/geocode":"~1.3"

Laravel 5.5

Both the service provider and alias will be automatically installed by Laravel 5.5 package discovery. If you don't use auto discovery, follow the instructions for Laravel 5.0-5.4 below:, (*5)

Laravel 5.0-5.4

After updating composer, add the service provider to the providers array in app/config/app.php, (*6)

Jcf\Geocode\GeocodeServiceProvider::class,

Add then alias Geocode adding its facade to the aliases array in the same file :, (*7)

'Geocode' => Jcf\Geocode\Facades\Geocode::class,

Laravel 4

After updating composer, add the service provider to the providers array in app/config/app.php, (*8)

'Jcf\Geocode\GeocodeServiceProvider',

Add then alias Geocode adding its facade to the aliases array in the same file :, (*9)

'Geocode' => 'Jcf\Geocode\Facades\Geocode'

Lumen 5

After updating composer, register the service provider in bootstrap/app.php, (*10)

$app->register(Jcf\Geocode\GeocodeServiceProvider::class);

Since facade are not enabled by default on Lumen, don't forget to add this., (*11)

use Jcf\Geocode\Geocode;

Configuration

Add the following line to the .env file:, (*12)

GEOCODE_GOOGLE_APIKEY=<your_google_api_key>

You can optionally set the response language., (*13)

GEOCODE_GOOGLE_LANGUAGE=en # pt-BR, es, de, it, fr, en-GB

Supported Languages for Google Maps Geocoding API., (*14)

Usage

You can find data from addresses:, (*15)

$response = Geocode::make()->address('1 Infinite Loop');

if ($response) {
    echo $response->latitude();
    echo $response->longitude();
    echo $response->formattedAddress();
    echo $response->locationType();
}

// Output
// 37.331741
// -122.0303329
// 1 Infinite Loop, Cupertino, CA 95014, USA
// ROOFTOP

Or from latitude/longitude:, (*16)

$response = Geocode::make()->latLng(40.7637931,-73.9722014);
if ($response) {
    echo $response->latitude();
    echo $response->longitude();
    echo $response->formattedAddress();
    echo $response->locationType();
}

// Output
// 40.7637931
// -73.9722014
// 767 5th Avenue, New York, NY 10153, USA
// ROOFTOP

If you need other data rather than formatted address, latitude, longitude or location type, you can use the raw() method:, (*17)

$response = Geocode::make()->latLng(40.7637931,-73.9722014);
if ($response) {
    echo $response->raw()->address_components[8]['types'][0];
    echo $response->raw()->address_components[8]['long_name'];
}

// Output
// postal_code
// 10153

That's it. Pull requests are welcome., (*18)

The Versions

15/01 2018

dev-master

9999999-dev

Google Geocoding API for Laravel

  Sources   Download

MIT

The Requires

 

by João Carlos

laravel api geocoding address latitude longitude google geocode

15/01 2018

1.4.0

1.4.0.0

Google Geocoding API for Laravel

  Sources   Download

MIT

The Requires

 

by João Carlos

laravel api geocoding address latitude longitude google geocode

20/09 2017

1.3.0

1.3.0.0

Google Geocoding API for Laravel

  Sources   Download

MIT

The Requires

 

by João Carlos

laravel api geocoding address latitude longitude google geocode

01/02 2017

1.2.0

1.2.0.0

Google Geocoding API for Laravel

  Sources   Download

MIT

The Requires

 

by João Carlos

laravel api geocoding address latitude longitude google geocode

15/12 2016

1.1.1

1.1.1.0

Google Geocoding API for Laravel

  Sources   Download

MIT

The Requires

 

by João Carlos

laravel api geocoding address latitude longitude google geocode

14/10 2016

1.1.0

1.1.0.0

Google Geocoding API for Laravel

  Sources   Download

MIT

The Requires

 

by João Carlos

laravel api geocoding address latitude longitude google geocode

19/07 2014

1.0.0

1.0.0.0

A simple Laravel 4 service provider for Google Geocode API.

  Sources   Download

MIT

The Requires

 

by João Carlos

23/05 2014

0.0.1

0.0.1.0

A simple Laravel 4 service provider for Google Geocode API.

  Sources   Download

MIT

The Requires

 

by João Carlos