定制 alexsawallich/zend-google-geocoder 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

alexsawallich/zend-google-geocoder

Composer 安装命令:

composer require 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.

README 文档

README

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.

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

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).

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

Usage Example

More examples can be found in the Wiki.

// 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.

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:

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

or you can add it in commandline like so:

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

When you're done with that run the composer update command:

$ php composer.phar update

Step 1b: Git clone

In commandline head to your vendor-directory of your application and run the git clone command:

$ 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.

Step 1c: Manual download

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.

Step 2: Configuration

After you've got the files you need to enable the module in your application.config.php-file.

// 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.

Now you should be able to use the module.

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):

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.

Please keep that in mind!

统计信息

  • 总下载量: 454
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-11-07