2017 © Pedro Peláez
 

library zend-google-geocoder

A Zend-Framework-Module providing a small service-class to query the Google Geocoder API. Results can optionally be cached to avoid running into the API's query limitations.

image

alexsawallich/zend-google-geocoder

A Zend-Framework-Module providing a small service-class to query the Google Geocoder API. Results can optionally be cached to avoid running into the API's query limitations.

  • Tuesday, November 17, 2015
  • by alexsawallich
  • Repository
  • 1 Watchers
  • 1 Stars
  • 267 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 6 % Grown

The README.md

What is ZendGoogleGeocoder?

ZendGoogleGeocoder is a Zend Framework 2-Module which provides a service to query the Google Geocoding API. The module allows you to retrieve the service from your ServiceLocator and use a method to retrieve the geocoordinates for the provided address/location., (*1)

The module ships with an API-Client which uses either file_get_contents or cURL to request data from Google's API., (*2)

Each step in the workflow of querying the API is documented by using Zend\Log. However by default logging is disabled by using the Zend\Log\Writer\Noop-Writer, which you can change by overriding a certrain config key (see Wiki for more details)., (*3)

To avoid running into quota-limits the responses from Google's API are being cached [INCOMPLETE]., (*4)

Usage Example

More examples can be found in the Wiki., (*5)

// For example in an action-method
$address = $this->getRequest()->getPost('address');
$geocoderService = $this->getServiceLocator()->get('ZendGoogleGeocoderService');
$response = $geocoderService->geocodeAddress($address, $format = 'xml');

// Do something with the response here...

Installation

Step 1: Getting the files

As usual you have the typical three options to install the module., (*6)

Step 1a: Composer The preferred way is to use composer. The modules' name is alexsawallich/zend-google-geocoder. So you can either put it in the require-section of your composer.json like this:, (*7)

"require": {
    // ... more here
    "alexsawallich/zend-google-geocoder": "dev-master",
    // ... more here
}

or you can add it in commandline like so:, (*8)

$ php composer.phar require "alexsawallich/zend-google-geocoder"

When you're done with that run the composer update command:, (*9)

$ php composer.phar update

Step 1b: Git clone, (*10)

In commandline head to your vendor-directory of your application and run the git clone command:, (*11)

$ cd /path/to/my/project/vendor
$ git clone https://github.com/alexsawallich/ZendGoogleGeocoder.git

% If you have an UI-based client (like GitHub for Windows) you will probably know which buttons you have to click., (*12)

Step 1c: Manual download, (*13)

Even though it's a bit old-fashioned and you won't be able to update the module through composer you can of course manually download a ZIP-file from this GitHub-page and put the extracted folder into your vendor or modules-directory., (*14)

Step 2: Configuration

After you've got the files you need to enable the module in your application.config.php-file., (*15)

// application.config.php
return array(
    'modules' => array(
        'ZendGoogleGeocoder'
// ...

Now head into the ZendGoogleGeocoder-directory and copy config/geocoder.global.php.dist to root-of-your-project/config/geocoder.global.php. Open the file and configure the available options to your needs., (*16)

Now you should be able to use the module., (*17)

Features / Todo / Roadmap

  • Possibility to query the Google Geocoder API [DONE]
  • Option to provide an API-Key for usage in the API requests [DONE]
  • Query API by providing an address [DONE]
  • Query API by providing components (defined by Google's API) [INCOMPLETE]
  • Possibility for detailed logging [DONE]
  • Possibility to cache the requests to avoid running into quota limits [INCOMPLETE]

Notice concerning Google's TOS

If you read the docs of the Google Geocoding API you will find the following (Source):, (*18)

The Google Maps Geocoding API may only be used in conjunction with a Google map; geocoding results without displaying them on a map is prohibited. For complete details on allowed usage, consult the Maps API Terms of Service License Restrictions., (*19)

Please keep that in mind!, (*20)

The Versions

17/11 2015

dev-master

9999999-dev http://www.alex-sawallich.com

A Zend-Framework-Module providing a small service-class to query the Google Geocoder API. Results can optionally be cached to avoid running into the API's query limitations.

  Sources   Download

The Requires

  • php >=5.5

 

api zend module google zf geocoder

17/11 2015

dev-develop

dev-develop http://www.alex-sawallich.com

A Zend-Framework-Module providing a small service-class to query the Google Geocoder API. Results can optionally be cached to avoid running into the API's query limitations.

  Sources   Download

The Requires

  • php >=5.5

 

api zend module google zf geocoder