Provides an abstraction layer for geocoding services.

v1.1.1 2017-11-02 07:10 UTC


Build Status Total Downloads Latest Stable Version

Provides an abstraction layer for geocoding services. This bundle can be also used to split geocoding's calculation between a set of external geocoding service.

Supported providers

The following services are included to this bundle :

The the complete documentation to add you own provider.


Spatial coordinates and postal address correspondence

Coordinates by Address

$address = $container
    ->setFullAddress('360 rue du thor, 34000 Montpellier')

$coordinates = $container

// output : 43.6190815,3.9162419

The geolocation-bundle only provides library ands services. But you can easily integrate it in your applications.

Address by Coordinates

$coordinates = $container

$address = $container

print $address->getFullAddress();
// output : 640 Rue du Mas de Verchant, 34000 Montpellier

Distance calculation

When you found two location's coordinates you can also calculate their distance with the distance calculator.

$factory = $container

$paris = $factory
$lyon = $factory

$distance_paris_lyon = $container
    ->getDistance($paris, $lyon)

printf('%d km', $distance_paris_lyon); # 391.613 km


Install the package with Composer :

composer require 1001pharmacies/geolocation-bundle

Or update the composer.json file :

"require": {
    "1001pharmacies/geolocation-bundle": "~1.0"

Update app/AppKernel.php :

$bundles = array(
    // ...
    new Meup\Bundle\GeoLocationBundle\MeupGeoLocationBundle(),

Setup your app/config/parameters.yml with your api keys :

    # ...
    geo_location_google_api_key:     your_google_api_key
    geo_location_bing_api_key:       your_bing_api_key
    geo_location_nominatim_api_key:  null
    geo_location_mapquest_api_key:   your_mapquest_api_key
    geo_location_yandex_api_key:     null
    geo_location_heredotcom_api_key: your_heredotcom_api_key

See detailed Google and Bing documentation to know how to retrieve api keys.