2017 © Pedro Peláez
 

library geocode

Google Geocode API for Laravel

image

shumex/geocode

Google Geocode API for Laravel

  • Friday, December 22, 2017
  • by dmytro.shumeyko
  • Repository
  • 0 Watchers
  • 1 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Google Geocoding API for Laravel

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

Installation

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

Run composer require command., (*3)

composer require shumex/geocode

Laravel 5.5

Both the service provider and alias will be automatically installed by Laravel 5.5 package discovery., (*4)

Configuration

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

GEOCODE_GOOGLE_APIKEY=<your_google_api_key>

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

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

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

Usage

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

try {
    $response = Geocode::make()->address('Saporischschja', 'de');
    if ($response) {
        echo $response->latitude();
        echo "<br>";
        echo $response->longitude();
        echo "<br>";
        echo $response->formattedAddress();
        echo "<br>";
    }
} catch (GeoException $exception) {
    echo $exception->getMessage();
}

// Output
// 35.139567
// 47.8388
// Saporischschja, Ukraine, 69061

Or from latitude/longitude:, (*9)

try {
    $response = Geocode::make()->latLng(47.850437, 35.135653, 'en');
    if ($response) {
        echo $response->latitude();
        echo "<br>";
        echo $response->longitude();
        echo "<br>";
        echo $response->formattedAddress();
        echo "<br>";
    }
} catch (GeoException $exception) {
    echo $exception->getMessage();
}

// Output
// 47.850437
// 35.135653
// Volhohrads'ka St, 27, Zaporizhzhia, Zaporiz'ka oblast, Ukraine, 69000

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

try {
    $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'];
    }
} catch (GeoException $exception) {
    echo $exception->getMessage();
}

// Output
// postal_code
// 10153

The Versions

22/12 2017

dev-master

9999999-dev

Google Geocode API for Laravel

  Sources   Download

MIT

The Requires

 

by Dima Shumeyko

laravel api geocoding address latitude longitude google geocode

22/12 2017

1.0

1.0.0.0

Google Geocode API for Laravel

  Sources   Download

MIT

The Requires

 

by Dima Shumeyko

laravel api geocoding address latitude longitude google geocode

22/12 2017

0.4

0.4.0.0

Google Geocode API for Laravel

  Sources   Download

MIT

The Requires

 

by Dima Shumeyko

laravel api geocoding address latitude longitude google geocode

22/12 2017

0.3

0.3.0.0

Google Geocode API for Laravel

  Sources   Download

MIT

The Requires

 

by Dima Shumeyko

laravel api geocoding address latitude longitude google geocode

22/12 2017

0.2

0.2.0.0

Google Geocode API for Laravel

  Sources   Download

MIT

The Requires

 

by Dima Shumeyko

laravel api geocoding address latitude longitude google geocode

22/12 2017

0.1

0.1.0.0

Google Geocode API for Laravel

  Sources   Download

MIT

The Requires

 

by Dima Shumeyko

laravel api geocoding address latitude longitude google geocode