├── .gitignore ├── LICENSE-MIT ├── README.md ├── composer.json ├── phpdoc.dist.xml └── src └── GoogleMapsGeocoder.php /.gitignore: -------------------------------------------------------------------------------- 1 | composer.lock 2 | vendor/ 3 | doc/ 4 | phpdoc.xml 5 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Justin Stayton 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **NOTICE:** _This project is deprecated and no longer maintained. If you'd like 2 | to continue supporting a forked version, please reach out on Twitter 3 | ([@kidjustino](https://twitter.com/kidjustino)) to have it listed here._ 4 | 5 | GoogleMapsGeocoder 6 | ================== 7 | 8 | [![Latest Stable Version](https://poser.pugx.org/jstayton/google-maps-geocoder/v/stable.png)](https://packagist.org/packages/jstayton/google-maps-geocoder) 9 | [![Total Downloads](https://poser.pugx.org/jstayton/google-maps-geocoder/downloads.png)](https://packagist.org/packages/jstayton/google-maps-geocoder) 10 | 11 | A PHP wrapper for the Google Maps Geocoding API v3. 12 | 13 | Developed by [Justin Stayton](http://justinstayton.com) while at 14 | [Monk Development](http://monkdev.com). 15 | 16 | * [Documentation](http://jstayton.github.io/GoogleMapsGeocoder/classes/GoogleMapsGeocoder.html) 17 | * [Release Notes](https://github.com/jstayton/GoogleMapsGeocoder/wiki/Release-Notes) 18 | 19 | Requirements 20 | ------------ 21 | 22 | * PHP >= 5.2.0 23 | 24 | Installation 25 | ------------ 26 | 27 | ### Composer 28 | 29 | The recommended installation method is through 30 | [Composer](http://getcomposer.org/), a dependency manager for PHP. Just add 31 | `jstayton/google-maps-geocoder` to your project's `composer.json` file: 32 | 33 | ```json 34 | { 35 | "require": { 36 | "jstayton/google-maps-geocoder": "*" 37 | } 38 | } 39 | ``` 40 | 41 | [More details](http://packagist.org/packages/jstayton/google-maps-geocoder) can 42 | be found over at [Packagist](http://packagist.org). 43 | 44 | ### Manually 45 | 46 | 1. Copy `src/GoogleMapsGeocoder.php` to your codebase, perhaps to the `vendor` 47 | directory. 48 | 2. Add the `GoogleMapsGeocoder` class to your autoloader or `require` the file 49 | directly. 50 | 51 | Getting Started 52 | --------------- 53 | 54 | We'll use the address of [Monk Development](http://monkdev.com) for this 55 | example: 56 | 57 | ```php 58 | $address = "2707 Congress St., San Diego, CA 92110"; 59 | ``` 60 | 61 | There are two ways to set the address of a `GoogleMapsGeocoder` object. Either 62 | the address can be passed to the constructor: 63 | 64 | ```php 65 | $Geocoder = new GoogleMapsGeocoder($address); 66 | ``` 67 | 68 | Or the address can be set after the object is created: 69 | 70 | ```php 71 | $Geocoder = new GoogleMapsGeocoder(); 72 | $Geocoder->setAddress($address); 73 | ``` 74 | 75 | By default, the `format` is set to `json` and the `sensor` is set to `false`. 76 | These values can be changed either through the constructor or after the object 77 | is created. See the 78 | [documentation](http://jstayton.github.io/GoogleMapsGeocoder/classes/GoogleMapsGeocoder.html) 79 | for the complete list of API parameters that can be changed. 80 | 81 | Once all parameters are set, the final step is to send the request to the 82 | Google Maps Geocoding API: 83 | 84 | ```php 85 | $response = $Geocoder->geocode(); 86 | ``` 87 | 88 | The `geocode` method converts the response into a JSON associative array 89 | (default) or `SimpleXMLElement` object depending on the specified `format`. See 90 | the `geocode` 91 | [documentation](http://jstayton.github.io/GoogleMapsGeocoder/classes/GoogleMapsGeocoder.html#method_geocode) 92 | for making the request over HTTPS or preventing conversion (instead returning 93 | the raw plain text response). 94 | 95 | Feedback 96 | -------- 97 | 98 | Please open an issue to request a feature or submit a bug report. Or even if 99 | you just want to provide some feedback, I'd love to hear. I'm also available on 100 | Twitter as [@kidjustino](https://twitter.com/kidjustino). 101 | 102 | Contributing 103 | ------------ 104 | 105 | 1. Fork it. 106 | 2. Create your feature branch (`git checkout -b my-new-feature`). 107 | 3. Commit your changes (`git commit -am 'Added some feature'`). 108 | 4. Push to the branch (`git push origin my-new-feature`). 109 | 5. Create a new Pull Request. 110 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jstayton/google-maps-geocoder", 3 | "type": "library", 4 | "description": "A PHP wrapper for the Google Maps Geocoding API v3.", 5 | "keywords": ["google", "map", "maps", "gmap", "gmaps", "geocode", "geocoder", "geocoding"], 6 | "homepage": "https://github.com/jstayton/GoogleMapsGeocoder", 7 | "license": "MIT", 8 | "authors": [ 9 | { 10 | "name": "Justin Stayton", 11 | "homepage": "http://justinstayton.com", 12 | "role": "Developer" 13 | } 14 | ], 15 | "autoload": { 16 | "psr-0": { 17 | "GoogleMapsGeocoder": "src/" 18 | } 19 | }, 20 | "require": { 21 | "php": ">=5.2.0" 22 | }, 23 | "require-dev": { 24 | "phpdocumentor/phpdocumentor": "*" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /phpdoc.dist.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | GoogleMapsGeocoder 4 | 5 | doc 6 | public 7 | 8 | 9 | doc 10 | 11 | 12 |