2017 © Pedro Peláez
 

library php-geocode

A wrapper around the Google Geocoding API to get different details such as latitude, longitude, country, city, district, postcode, town and street number regarding some specific address.

image

rotron/php-geocode

A wrapper around the Google Geocoding API to get different details such as latitude, longitude, country, city, district, postcode, town and street number regarding some specific address.

  • Monday, July 24, 2017
  • by Rotron
  • Repository
  • 1 Watchers
  • 0 Stars
  • 51 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 27 Forks
  • 0 Open issues
  • 4 Versions
  • 200 % Grown

The README.md

Laravel 5.2 Tested.

Add inside config/app.php
'Geocode'   => Rotron\Geocode\Geocode::class

Call from controller with Post or Get request.
 public function location(Request $request)
 {
        $geocode = new Geocode();
        $street = $request->input('street');
        // Get the details for the passed address
        $location = $geocode->get($street);     
        $location = $location->streetAddress;

        return view('store.location', compact('location'));
} 

PHP Geocode

Latest Stable Version, (*1)

A wrapper around the Google Geocoding API to get different details regarding an address such as - Latitude/longitude - Country - City - District - Postcode - Town - Street number, (*2)

Requirement

PHP >= 5.4.0 and curl enabled server., (*3)

Installation

You can install the library using the following ways, (*4)

Composer

The recommended installation method is through Composer, a dependency manager for PHP. Just add rotron/php-geocode to your project's composer.json file:, (*5)

{
    "require": {
        "rotron/php-geocode": "dev-master"
    }
}

and then run composer install. For further details you can find the package at Packagist., (*6)

Getting Started

I'm going to use the following address to explain the use of library i.e., (*7)

1600 Amphitheatre Parkway, Mountain View, CA, (*8)

Instantiate the Geocode class and call the methods as follows, (*9)

// Introduce the class into your scope
use Rotron\Geocode\Geocode;


// Optionally you can pass the API key for Geocoding
$geocode = new Geocode();

// Get the details for the passed address
$location = $geocode->get("1600 Amphitheatre Parkway, Mountain View, CA");

// Note: All the functions below accept a parameter as a default value that will be return if the reuqired value isn't found
$location->getAddress( 'default value' ); 
$location->getLatitude(); // returns the latitude of the address
$location->getLongitude(); // returns the longitude of the address
$location->getCountry(); // returns the country of the address
$location->getLocality(); // returns the locality/city of the address
$location->getDistrict(); // returns the district of the address
$location->getPostcode(); // returns the postal code of the address
$location->getTown(); // returns the town of the address
$location->getStreetNumber(); // returns the street number of the address

Feedback

I'd love to hear what you have to say. Please open an issue for any feature requests that you may want or the bugs that you notice. Also you can contact me at kamranahmed.se@gmail.com or you can also find me at twitter @kamranahmed_se, (*10)

Note

It should be noted that, the Google Geocoding API has the following limits in place and you should keep them in mind before using this wrapper: - 2,500 requests per 24 hour period. - 5 requests per second., (*11)

The Versions

24/07 2017

dev-master

9999999-dev https://github.com/rotron/php-geocode

A wrapper around the Google Geocoding API to get different details such as latitude, longitude, country, city, district, postcode, town and street number regarding some specific address.

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-curl *

 

The Development Requires

geocoding address google maps addresses geocoder map location geocode gmaps gmap

22/01 2016

v2.0

2.0.0.0 https://github.com/kamranahmedse/php-geocode

A wrapper around the Google Geocoding API to get different details such as latitude, longitude, country, city, district, postcode, town and street number regarding some specific address.

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

The Development Requires

geocoding address google maps addresses geocoder map location geocode gmaps gmap

09/10 2014

v1.1

1.1.0.0 https://github.com/kamranahmedse/php-geocode

A wrapper around the Google Geocoding API to get different details such as latitude, longitude, country, city, district, postcode, town and street number regarding some specific address.

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

The Development Requires

geocoding address google maps addresses geocoder map location geocode gmaps gmap

07/10 2014

v1.0

1.0.0.0 https://github.com/kamranahmedse/php-geocode

A wrapper around the Google Geocoding API to get different details such as latitude, longitude, country, city, district, postcode, town and street number regarding some specific address.

  Sources   Download

MIT

The Requires

  • php >=5.2.0

 

geocoding address google maps addresses geocoder map location geocode gmaps gmap