2017 © Pedro Peláez
 

library gmaps-geocode

A PHP5 library to geocode coordinates through The Google Maps Geocoding API

image

dotzero/gmaps-geocode

A PHP5 library to geocode coordinates through The Google Maps Geocoding API

  • Tuesday, April 12, 2016
  • by dotzero
  • Repository
  • 1 Watchers
  • 2 Stars
  • 683 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 2 Versions
  • 17 % Grown

The README.md

PHP Google Maps Geocode

Build Status Latest Stable Version License, (*1)

A PHP5 library implements Geocoding and Reverse geocoding through The Google Maps Geocoding API., (*2)

Geocoding is the process of converting addresses (like "1600 Amphitheatre Parkway, Mountain View, CA") into geographic coordinates (like latitude 37.423021 and longitude -122.083739). Reverse geocoding is the process of converting geographic coordinates into a human-readable address., (*3)

Usage

To use the Google Maps Geocoding API, you need an API key. To acquire an API key follow the instructions., (*4)

Geocoding (Latitude/Longitude Lookup)

try {
    $result = (new GMapsGeocode('YOUR_GOOGLE_API'))
        ->setAddress('Helsinki')
//        ->setRegion('FI')
        ->setComponents(array(
            'route' => 'Annegatan',
            'administrative_area' => 'Helsinki',
            'country' => 'Finland'
        ))
        ->search();

    print_r($result);
} catch (GMapsException $e) {
    printf('Error (%d): %s', $e->getCode(), $e->getMessage());
}

Required method are setAddress or setComponents in a geocoding request and setRegion is optional., (*5)

Official documentation contains more about Component Filtering., (*6)

Reverse Geocoding (Address Lookup)

try {
    $geo = (new GMapsGeocodeReverse('YOUR_GOOGLE_API'))
        ->setLatLng('40.714224', '-73.961452')
//        ->setPlaceId('ChIJd8BlQ2BZwokRAFUEcm_qrcA')
        ->search();

    print_r($result);
} catch (GMapsException $e) {
    printf('Error (%d): %s', $e->getCode(), $e->getMessage());
}

Required method are setLatLng or setPlaceId in a reverse geocoding request., (*7)

Install

Via composer:

$ composer require dotzero/gmaps-geocode

Without composer

Clone the project using:, (*8)

$ git clone https://github.com/dotzero/gmaps-geocode-php/

and include the source files with:, (*9)

    require_once("gmaps-geocode-php/src/GMapsException.php");
    require_once("gmaps-geocode-php/src/GMapsGeocodeBase.php");
    require_once("gmaps-geocode-php/src/GMapsGeocode.php");
    require_once("gmaps-geocode-php/src/GMapsGeocodeReverse.php");

Test

First install the dependencies, and after you can run:, (*10)

GOOGLE_API=YOUR_GOOGLE_API vendor/bin/phpunit

License

Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php, (*11)

The Versions

12/04 2016

dev-master

9999999-dev

A PHP5 library to geocode coordinates through The Google Maps Geocoding API

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Avatar dotzero

api maps googl geocode

12/04 2016

0.6.0

0.6.0.0

A PHP5 library to geocode coordinates through The Google Maps Geocoding API

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Avatar dotzero

api maps googl geocode