jeroendesloovere/geolocation-bundle

This Geolocation Symony2 Bundle uses the geolocation-php-api class which finds latitude/longitude from an address or reverse using Google Maps API.

1.0.0 2015-06-09 08:28 UTC

This package is auto-updated.

Last update: 2024-04-24 03:03:38 UTC


README

This Geolocation Symony2 Bundle uses the geolocation-php-api class using Google Maps API which finds latitude/longitude from an address or reverse.

Usage

Installation

{
    "require": {
        "jeroendesloovere/geolocation-bundle": "1.0.*"
    }
}

Adding this code in your composer.json file will get the [latest :package_name Packagist package](https://packagist.org/packages/jeroendesloovere/geolocation-bundle using Composer.

and in app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...,
        new JeroenDesloovere\Bundle\GeolocationBundle\JeroenDesloovereGeolocationBundle()
    );
}

Example

$geolocation = $this->get('jeroendesloovere.geolocation');

// define result
$result = $geolocation::getCoordinates('Koningin Maria Hendrikaplein', '1', 'Gent', '9000', 'belgië');

// dump result
echo 'Coordinates = ' . $result['latitude'] . ', ' . $result['longitude'] . '<br/>';

// define result: @return array(label, street, streetNumber, city, cityLocal, zip, country, countryLabel)
$result = $geolocation::getAddress(51.0363935, 3.7121008);

// define result
echo 'Address = ' . $result['label'] . '<br/>';