New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

rtablada/geocoder

A slim Google Geocoder for PHP and Laravel
156 4
Install
composer require rtablada/geocoder:dev-master
PHP:>=5.3.0
License:MIT
Last Updated:Jul 1, 2013
Links: GitHub  ·  Packagist
Maintainer: rtablada

Build Status

Geocoder

This is a simple geocode provider for PHP. By default, it uses google's geocode API but any compatible API will work.

Installation

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.

Use

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

Other Provided Classes

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.

Related Packages

caouecs/bootstrap3

Bootstrap 3 for Laravel 4

1,859 11
rtablada/laravel-faq

A FAQ Package for Laravel Sites

23 14
laravel-lang/lang

List of 126 languages for Laravel Framework, Laravel Jetstream, Laravel Fortify,...

13,598,897 7,783
caouecs/sirtrevorjs

Sir Trevor JS in Laravel project

21,674 54
rafaelbeckel/sirtrevor

Sir Trevor JS in Laravel 5 project

34 0