library geocoder
A laravel package that helps you with geocoding addresses and reverse geocoding coordinates using the google maps api. It also helps in calculating the distance between two locations using the Hervasine formula and the coordinates of the locations
bodunde/geocoder
A laravel package that helps you with geocoding addresses and reverse geocoding coordinates using the google maps api. It also helps in calculating the distance between two locations using the Hervasine formula and the coordinates of the locations
- Sunday, October 9, 2016
- by badebiyi
- Repository
- 2 Watchers
- 6 Stars
- 731 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 1 Forks
- 0 Open issues
- 4 Versions
- 4 % Grown
Laravel-Geocoder
A Laravel Package that interfaces with the google maps API to help convert a plain address to longitude and latitude coordinates and vice-versa. It can also calculate the distance (in kilometers or miles) between two locations using their coordinates., (*1)
Installation
- include the package in your
composer.json
file and run composer update
or run composer require bodunde/geocoder
or you can do it oldschool and just clone the repo and include it in your application.
- navigate to your
config
directory in your laravel application and locate the app.php
file
- add this line to your service provide
Bodunde\GoogleGeocoder\GeocoderServiceProvider::class
- publish its config file by running
php artisan vendor:publish
- include your
google_api_key
in geocoder.php
file located in the config directory
Voila!!! You are done
Usage
<?php
namespace Your\Namespace;
use Bodunde\GoogleGeocoder\Geocoder;
...
...
// using dependency injection
public function index(Geocoder $geocoder)
{
// get coordinates
$coordinates = $geocoder->getCoordinates('55 Moleye Street, Yaba');
// get address via reverse geocoding
$addressCoordinates = [
"lat" => 6.5349646,
"lng" => 3.3892894
];
$address = $geocoder->getAddress($addressCoordinates);
// get distance between two locations
$location1 = [
"lat" => 6.5349646,
"lng" => 3.3892894
];
$location2 = [
"lat" => 6.601838,
"lng" => 3.3514863
];
$distance = $geocoder->getDistanceBetween($location1, $location2);
/** geocoder can also be instantiated normally without DI */
//e.g $geocoder = new Geocoder;
}
Tests
In the package root run phpunit
, (*2)
v1.2.1
1.2.1.0
A laravel package that helps you with geocoding addresses and reverse geocoding coordinates using the google maps api. It also helps in calculating the distance between two locations using the Hervasine formula and the coordinates of the locations
Sources
Download
MIT
The Requires
The Development Requires
by
Adebiyi Bodunde
v1.2
1.2.0.0
A laravel package that helps you with geocoding addresses and reverse geocoding coordinates using the google maps api. It also helps in calculating the distance between two locations using the Hervasine formula and the coordinates of the locations
Sources
Download
MIT
The Requires
The Development Requires
by
Adebiyi Bodunde
dev-master
9999999-dev
A laravel package that helps you with geocoding addresses and reverse geocoding coordinates using the google maps api. It also helps in calculating the distance between two locations using the Hervasine formula and the coordinates of the locations
Sources
Download
MIT
The Requires
The Development Requires
by
Adebiyi Bodunde
v1.0
1.0.0.0
A laravel package that helps you with geocoding addresses and reverse geocoding coordinates using the google maps api. It also helps in calculating the distance between two locations using the Hervasine formula and the coordinates of the locations
Sources
Download
MIT
The Requires
The Development Requires
by
Adebiyi Bodunde