Skip to content

MatthiasDeWinter/geocoder

 
 

Repository files navigation

Geocode addresses to coordinates

Software License Build Status Total Downloads

The package can convert any address to GPS coordinates.

Installation

You can install this package through Composer.

composer require spatie/geocoder

When using Laravel there is a service provider that you can make use of.

// app/config/app.php
'providers' => [
    '...',
    'Spatie\Geocoder\GeocoderServiceProvider'
];

Geocoder also comes with a facade, which provides an easy way to call the Geocoder.

// app/config/app.php
'aliases' => [
	'...',
	'Geocoder' => 'Spatie\Geocoder\GeocoderFacade',
];

Usage

Geocoder::getCoordinatesForQuery('Infinite Loop 1, Cupertino');

/* 
  This function returns an array with keys
  "lat" =>  37.331741000000001
  "lng" => -122.0303329
  "accuracy" => "ROOFTOP"
*/

The accuracy key can contain these values:

  • 'ROOFTOP'
  • 'RANGE_INTERPOLATED'
  • 'GEOMETRIC_CENTER'
  • 'APPROXIMATE'

You can read more information about these values on the Google Geocoding API Page

When an address is not found accuracy will contain 'NOT_FOUND'

About

Geocoding addresses to coordinates

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%