rtablada/geocoder is a Laravel package for a slim google geocoder for php and laravel.
It currently has 4 GitHub stars and 156 downloads on Packagist.
Install it with composer require rtablada/geocoder.
Discover more Laravel packages by rtablada
or browse all Laravel packages to compare alternatives.
Last updated
This is a simple geocode provider for PHP. By default, it uses google's geocode API but any compatible API will work.
This package can be installed using composer using composer require rtablada/geocoder.
For Laravel 4, this package and its Service Provider can be installed using php artisan package:install rtablada/geocoder.
On both, specify dev-master as the version constraint.
To use this package outside of Laravel you can use
require 'vendor/autoload.php';
$geocoder = new Rtablada\Geocoder\Geocoder;
var_dump($geocoder->getLocationFromQuery('Atlanta'));
The geocoder provides the following functions
| Function | Arguments | Description |
|---|---|---|
| getLocationFromQuery | string Query | Returns a Location Object from the google geocode API |
| getCoordinatesFromQuery | string Query | Returns a Coordinates Object from the google geocode API |
| getSearchSquare | Coordinate center, number radius | Returns an array with the corners of a sqare around the centerpoint with a radius in miles |
The Geocoder Package also provides two helper classes (Location and Coordinate).
The Coordinate is a simple object with lat and lng properties.
The Location object has address and coordinates properties. The coordinates is an instance of the Coordinate class.
The Location class also provides a newInstanceFromObject method to parse Google Geocode Result objects into Location objects.