jstayton/google-maps-geocoder
最新稳定版本:v2.4.0
Composer 安装命令:
composer require jstayton/google-maps-geocoder
包简介
A PHP wrapper for the Google Maps Geocoding API v3.
README 文档
README
NOTICE: This project is deprecated and no longer maintained. If you'd like to continue supporting a forked version, please reach out on Twitter (@kidjustino) to have it listed here.
GoogleMapsGeocoder
A PHP wrapper for the Google Maps Geocoding API v3.
Developed by Justin Stayton while at Monk Development.
Requirements
- PHP >= 5.2.0
Installation
Composer
The recommended installation method is through
Composer, a dependency manager for PHP. Just add
jstayton/google-maps-geocoder to your project's composer.json file:
{
"require": {
"jstayton/google-maps-geocoder": "*"
}
}
More details can be found over at Packagist.
Manually
- Copy
src/GoogleMapsGeocoder.phpto your codebase, perhaps to thevendordirectory. - Add the
GoogleMapsGeocoderclass to your autoloader orrequirethe file directly.
Getting Started
We'll use the address of Monk Development for this example:
$address = "2707 Congress St., San Diego, CA 92110";
There are two ways to set the address of a GoogleMapsGeocoder object. Either
the address can be passed to the constructor:
$Geocoder = new GoogleMapsGeocoder($address);
Or the address can be set after the object is created:
$Geocoder = new GoogleMapsGeocoder(); $Geocoder->setAddress($address);
By default, the format is set to json and the sensor is set to false.
These values can be changed either through the constructor or after the object
is created. See the
documentation
for the complete list of API parameters that can be changed.
Once all parameters are set, the final step is to send the request to the Google Maps Geocoding API:
$response = $Geocoder->geocode();
The geocode method converts the response into a JSON associative array
(default) or SimpleXMLElement object depending on the specified format. See
the geocode
documentation
for making the request over HTTPS or preventing conversion (instead returning
the raw plain text response).
Feedback
Please open an issue to request a feature or submit a bug report. Or even if you just want to provide some feedback, I'd love to hear. I'm also available on Twitter as @kidjustino.
Contributing
- Fork it.
- Create your feature branch (
git checkout -b my-new-feature). - Commit your changes (
git commit -am 'Added some feature'). - Push to the branch (
git push origin my-new-feature). - Create a new Pull Request.
统计信息
- 总下载量: 771.88k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 122
- 点击次数: 1
- 依赖项目数: 5
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2012-09-16