The most featured Geocoder library written in PHP.

Related tags

Geolocation geocoder
Overview

Geocoder

Build Status Software License

Important: You are browsing the documentation of Geocoder 4.x.

Documentation for version 3.x is available here: Geocoder 3.x documentation.

Documentation for version 2.x is available here: Geocoder 2.x documentation.


Geocoder is a PHP library which helps you build geo-aware applications by providing a powerful abstraction layer for geocoding manipulations.

Installation

To install a Geocoder there are two things you need to know:

  1. What Geocoder provider you want to use
  2. What HTTP client/adapter you want to use.

Geocoder providers

Since 4.0 we do not include providers by default. You need to select a geocoder provider. You will see a list of providers at Packagist

HTTP Clients

In order to talk to geocoding APIs, you need HTTP adapters. While it was part of the library in Geocoder before, Geocoder 4.x and upper now relies on HTTPlug which defines how HTTP message should be sent and received. You can use any library to send HTTP messages that implements php-http/client-implementation.

Here is a list of all officially supported clients and adapters by HTTPlug: http://docs.php-http.org/en/latest/clients.html

Read more about HTTPlug in their docs.

Summary (Just give me the command)

To install Google Maps geocoder with Guzzle 6 you may run the following command:

$ composer require geocoder-php/google-maps-provider php-http/guzzle6-adapter

Or using the curl client (you'll need to provide a PSR7 implementation such as nyholm/psr7 if not using guzzle)

$ composer require geocoder-php/google-maps-provider php-http/curl-client nyholm/psr7

Framework integration

If you are using a framework then you may be interested in our excellent framework integrations.

Framework Package Stats
Laravel geocoder-php/GeocoderLaravel GitHub release Packagist
Symfony geocoder-php/BazingaGeocoderBundle Latest Stable Version Total Downloads

Cookbook

We have a small cookbook where you can find examples on common use cases:

Usage

In the code snippet below we use GoogleMaps and Guzzle6.

use Geocoder\Query\GeocodeQuery;
use Geocoder\Query\ReverseQuery;

$httpClient = new \Http\Adapter\Guzzle6\Client();
$provider = new \Geocoder\Provider\GoogleMaps\GoogleMaps($httpClient, null, 'your-api-key');
$geocoder = new \Geocoder\StatefulGeocoder($provider, 'en');

$result = $geocoder->geocodeQuery(GeocodeQuery::create('Buckingham Palace, London'));
$result = $geocoder->reverseQuery(ReverseQuery::fromCoordinates(...));

The Provider interface has three methods:

  • geocodeQuery(GeocodeQuery $query):AddressCollection
  • reverseQuery(ReverseQuery $query):AddressCollection
  • getName():string

The Geocoder interface extends the Provider interface and exposes two additional methods. They will make migration from 3.x smoother.

  • geocode($streetOrIpAddress)
  • reverse($latitude, $longitude)

Providers

Providers perform the geocoding black magic for you (talking to the APIs, fetching results, dealing with errors, etc.) and are highly configurable.

Special providers

Provider Package Features Stats
Cache geocoder-php/cache-provider Wraps a provider and cached the results Latest Stable Version
Total Downloads
Chain geocoder-php/chain-provider Iterates over multiple providers Latest Stable Version
Total Downloads

Address

World

Provider Package Features Stats
Algolia Places geocoder-php/algolia-places-provider address
Website
Latest Stable Version
Total Downloads
ArcGIS Online geocoder-php/arcgis-online-provider address, reverse
Website
Latest Stable Version
Total Downloads
Azure Maps geocoder-php/azure-maps-provider address, reverse
Website
Latest Stable Version
Total Downloads
Bing Maps geocoder-php/bing-maps-provider address, reverse
Website
Latest Stable Version
Total Downloads
Geocode Earth geocoder-php/geocode-earth-provider address, reverse
Website
Latest Stable Version
Total Downloads
Geonames geocoder-php/geonames-provider address, reverse
Website
Latest Stable Version
Total Downloads
Google Maps
Google Maps for business
geocoder-php/google-maps-provider address, reverse
Website
Latest Stable Version
Total Downloads
Google Maps Places geocoder-php/google-maps-places-provider address, reverse
Website
Latest Stable Version
Total Downloads
GraphHopper geocoder-php/graphhopper-provider address, reverse
Website
Latest Stable Version
Total Downloads
Here geocoder-php/here-provider address, reverse
Website
Latest Stable Version
Total Downloads
LocationIQ geocoder-php/locationiq-provider address, reverse
Website
Latest Stable Version
Total Downloads
Mapbox geocoder-php/mapbox-provider address, reverse
Website
Latest Stable Version
Total Downloads
MapQuest geocoder-php/mapquest-provider address, reverse
Website
Latest Stable Version
Total Downloads
Nominatim
(OpenStreetMap)
geocoder-php/nominatim-provider address, reverse
Website
Latest Stable Version
Total Downloads
OpenCage geocoder-php/open-cage-provider address, reverse
Website
Latest Stable Version
Total Downloads
OpenRouteService geocoder-php/openrouteservice-provider address, reverse
Website
Latest Stable Version
Total Downloads
Pelias geocoder-php/pelias-provider address, reverse
Website
Latest Stable Version
Total Downloads
Photon geocoder-php/photon-provider address, reverse
Website
Latest Stable Version
Total Downloads
PickPoint geocoder-php/pickpoint-provider address, reverse
Website
Latest Stable Version
Total Downloads
TomTom geocoder-php/tomtom-provider address, reverse
Website
Latest Stable Version
Total Downloads
Yandex geocoder-php/yandex-provider address, reverse
Website
Latest Stable Version
Total Downloads

Local

Region Provider Package Features Stats
πŸ‡§πŸ‡ͺ bpost (third-party package*) geo6/geocoder-php-bpost-provider address
Website
Latest Stable Version
Total Downloads
πŸ‡§πŸ‡ͺ GeoPunt (third-party package*) geo6/geocoder-php-geopunt-provider address, reverse
Website
Latest Stable Version
Total Downloads
πŸ‡§πŸ‡ͺ Service Public de Wallonie (third-party package*) geo6/geocoder-php-spw-provider address, reverse
Website
Latest Stable Version
Total Downloads
πŸ‡§πŸ‡ͺ UrbIS (third-party package*) geo6/geocoder-php-urbis-provider address, reverse
Website
Latest Stable Version
Total Downloads
πŸ‡«πŸ‡· Addok (third-party package*) geo6/geocoder-php-addok-provider address, reverse
Website
Latest Stable Version
Total Downloads
πŸ‡±πŸ‡Ί Geoportail.lu (third-party package*) frantzmicccoli/geocoder-php-geoportail-lu address, reverse
Website
Latest Stable Version
Total Downloads
πŸ‡³πŸ‡± Nationaal Georegister (third-party package*) swisnl/geocoder-php-nationaal-georegister-provider address, reverse
Website
Latest Stable Version
Total Downloads

* Third-party package: Those providers are not official, i.e. not from the Geocoder core team.

IP

Provider Package Features Stats
FreeGeoIp geocoder-php/free-geoip-provider IPv4, IPv6
Website
Latest Stable Version
Total Downloads
GeoIP geocoder-php/geoip-provider IPv4, local
Website
Latest Stable Version
Total Downloads
GeoIP2 geocoder-php/geoip2-provider IPv4
Website
Latest Stable Version
Total Downloads
GeoPlugin geocoder-php/geo-plugin-provider IPv4, IPv6
Website
Latest Stable Version
Total Downloads
HostIp geocoder-php/host-ip-provider IPv4
Website
Latest Stable Version
Total Downloads
IP2Location geocoder-php/ip2location-provider IPv4, IPv6
Website
Latest Stable Version
Total Downloads
IP2Location Binary geocoder-php/ip2location-binary-provider IPv4, IPv6
Website
Latest Stable Version
Total Downloads
IpInfo geocoder-php/ip-info-provider IPv4, IPv6
Website
Latest Stable Version
Total Downloads
IpInfoDB geocoder-php/ip-info-db-provider IPv4
Website
Latest Stable Version
Total Downloads
ipstack geocoder-php/ipstack-provider IPv4, IPv6
Website
Latest Stable Version
Total Downloads
MaxMind geocoder-php/maxmind-provider IPv4, IPv6
Website
Latest Stable Version
Total Downloads
MaxMind Binary geocoder-php/maxmind-binary-provider IPv4, IPv6
Website
Latest Stable Version
Total Downloads

Other packages

There are two "abstract" or "base" packages that most providers depend on.

Name Package Features Stats
PHP common willdurand/geocoder Models, interfaces, exceptions etc Latest Stable Version
Total Downloads
HTTP common geocoder-php/common-http AbstractHttpProvider, HTTPlug Latest Stable Version
Total Downloads
Plugin geocoder-php/plugin Plugin provider Latest Stable Version
Total Downloads

Special Geocoders and Providers

The Chain Provider

The Chain provider is a special provider that takes a list of providers and iterates over this list to get information. Note that it stops its iteration when a provider returns a result. The result is returned by GoogleMaps because FreeGeoIp and HostIp cannot geocode street addresses. BingMaps is ignored.

use Geocoder\Query\GeocodeQuery;

$geocoder = new \Geocoder\ProviderAggregator();
$adapter  = new \Http\Adapter\Guzzle6\Client();

$chain = new \Geocoder\Provider\Chain\Chain([
    new \Geocoder\Provider\FreeGeoIp\FreeGeoIp($adapter),
    new \Geocoder\Provider\HostIp\HostIp($adapter),
    new \Geocoder\Provider\GoogleMaps\GoogleMaps($adapter, 'France'),
    new \Geocoder\Provider\BingMaps\BingMaps($adapter, '<API_KEY>'),
    // ...
]);

$geocoder->registerProvider($chain);

$result = $geocoder->geocodeQuery(GeocodeQuery::create('10 rue Gambetta, Paris, France'));
var_export($result);

Everything is ok, enjoy!

The ProviderAggregator

The ProviderAggregator is used to register several providers so that you can decide which provider to use later on.

use Geocoder\Query\GeocodeQuery;
use Geocoder\Query\ReverseQuery;

$adapter  = new \Http\Adapter\Guzzle6\Client();
$geocoder = new \Geocoder\ProviderAggregator();

$geocoder->registerProviders([
    new \Geocoder\Provider\GoogleMaps\GoogleMaps($adapter),
    new \Geocoder\Provider\GoogleMaps\GoogleMapsBusiness($adapter, '<CLIENT_ID>'),
    new \Geocoder\Provider\Yandex\Yandex($adapter),
    new \Geocoder\Provider\MaxMind\MaxMind($adapter, '<MAXMIND_API_KEY>'),
    new \Geocoder\Provider\ArcGISOnline\ArcGISOnline($adapter),
]);

$geocoder->registerProvider(new \Geocoder\Provider\Nominatim\Nominatim($adapter, 'https://your.nominatim.server'));

$geocoder
    ->using('google_maps')
    ->geocodeQuery(GeocodeQuery::create( ... ));

$geocoder
    ->limit(10)
    ->reverseQuery(ReverseQuery::fromCoordinates($lat, $lng));

The ProviderAggregator's API is fluent, meaning you can write:

use Geocoder\Query\GeocodeQuery;

$locations = $geocoder
    ->registerProvider(new \My\Provider\Custom($adapter))
    ->using('custom')
    ->limit(10)
    ->geocodeQuery(GeocodeQuery::create( ... ));

The using() method allows you to choose the provider to use by its name. When you deal with multiple providers, you may want to choose one of them. The default behavior is to use the first one but it can be annoying.

The limit() method allows you to configure the maximum number of results being returned. Depending on the provider you may not get as many results as expected, it is a maximum limit, not the expected number of results.

TimedGeocoder

The TimedGeocoder class profiles each geocode and reverse call. So you can easily figure out how many time/memory was spent for each geocoder/reverse call.

use Geocoder\Query\GeocodeQuery;

// configure your provider
$provider = // ...

$stopwatch = new \Symfony\Component\Stopwatch\Stopwatch();
$geocoder = new \Geocoder\TimedGeocoder($provider, $stopwatch);

$geocoder->geocodeQuery(GeocodeQuery::create('Paris, France'));

// Now you can debug your application

We use the symfony/stopwatch component under the hood. Which means, if you use the Symfony framework the geocoder calls will appear in your timeline section in the Web Profiler.

StatefulGeocoder

The StatefulGeocoder class is great when you want your Geocoder to hold state. Say you want to configure locale, limit or bounds in runtime. The StatefulGeocoder will append these values on each query.

use Geocoder\Query\GeocodeQuery;

// configure your provider
$provider = // ...
$geocoder = new \Geocoder\StatefulGeocoder($provider);

$geocoder->setLocale('en');
$results = $geocoder->geocodeQuery(GeocodeQuery::create('London'));
echo $results->first()->getLocality(); // London

$geocoder->setLocale('es');
$results = $geocoder->geocodeQuery(GeocodeQuery::create('London'));
echo $results->first()->getLocality(); // Londres

Dumpers

Geocoder provides dumpers that aim to transform a Location object in standard formats.

GPS eXchange Format (GPX)

The GPS eXchange format is designed to share geolocated data like point of interests, tracks, ways, but also coordinates. Geocoder provides a dumper to convert a Location object in an GPX compliant format.

Assuming we got a $location object as seen previously:

$dumper = new \Geocoder\Dumper\Gpx();
$strGpx = $dumper->dump($location);

echo $strGpx;

It will display:

<gpx
    version="1.0"
    creator="Geocoder" version="1.0.1-dev"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://www.topografix.com/GPX/1/0"
    xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
    <bounds minlat="2.388911" minlon="48.863151" maxlat="2.388911" maxlon="48.863151"/>
    <wpt lat="48.8631507" lon="2.3889114">
        <name><![CDATA[Paris]]></name>
        <type><![CDATA[Address]]></type>
    </wpt>
</gpx>

GeoJSON

GeoJSON is a format for encoding a variety of geographic data structures.

GeoArray

Simple PHP array format for using with your own encoders.

Keyhole Markup Language (KML)

Keyhole Markup Language is an XML notation for expressing geographic annotation and visualization within Internet-based, two-dimensional maps and three-dimensional Earth browsers.

Well-Known Binary (WKB)

The Well-Known Binary (WKB) representation for geometric values is defined by the OpenGIS specification.

Well-Known Text (WKT)

Well-known text (WKT) is a text markup language for representing vector geometry objects on a map, spatial reference systems of spatial objects and transformations between spatial reference systems.

Formatters

A common use case is to print geocoded data. Thanks to the StringFormatter class, it's simple to format a Location object as a string:

// $location is an instance of Location
$formatter = new \Geocoder\Formatter\StringFormatter();

$formatter->format($location, '%S %n, %z %L');
// 'Badenerstrasse 120, 8001 Zuerich'

$formatter->format($location, '<p>%S %n, %z %L</p>');
// '<p>Badenerstrasse 120, 8001 Zuerich</p>'

Here is the mapping:

  • Street Number: %n
  • Street Name: %S
  • City (Locality): %L
  • City District (Sub-Locality): %D
  • Zipcode (Postal Code): %z
  • Admin Level Name: %A1, %A2, %A3, %A4, %A5
  • Admin Level Code: %a1, %a2, %a3, %a4, %a5
  • Country: %C
  • Country Code: %c
  • Timezone: %T

Versioning

Geocoder follows Semantic Versioning.

End Of Life

1.x

As of December 2014, branch 1.7 is not officially supported anymore, meaning major version 1 reached end of life. Last version is: 1.7.1.

2.x

As of December 2014, version 2.x is in a feature frozen state. All new features should be contributed to version 3.0 and upper. Last version is: 2.8.1.

Major version 2 will reach end of life on December 2015.

3.x

As of January 2017, version 3.x is in a feature frozen state. All new features should be contributed to version 4.0 and upper. Last version is: 3.3.2.

Major version 3 will reach end of life on October 2017.

Stable Version

Version 4.x is the current major stable version of Geocoder.

Next version

There is no new major version planned at this time.

Contributing

See CONTRIBUTING file.

Unit Tests

In order to run the test suite, install the development dependencies:

$ composer install --dev

Then, run the following command:

$ composer test

You'll obtain some skipped unit tests due to the need of API keys.

Rename the phpunit.xml.dist file to phpunit.xml, then uncomment the following lines and add your own API keys:

<php>
    <!-- <server name="IPINFODB_API_KEY" value="YOUR_API_KEY" /> -->
    <!-- <server name="BINGMAPS_API_KEY" value="YOUR_API_KEY" /> -->
    <!-- <server name="GEOIPS_API_KEY" value="YOUR_API_KEY" /> -->
    <!-- <server name="MAXMIND_API_KEY" value="YOUR_API_KEY" /> -->
    <!-- <server name="GEONAMES_USERNAME" value="YOUR_USERNAME" /> -->
    <!-- <server name="TOMTOM_MAP_KEY" value="YOUR_MAP_KEY" /> -->
    <!-- <server name="GOOGLE_GEOCODING_KEY" value="YOUR_GEOCODING_KEY" /> -->
    <!-- <server name="OPENCAGE_API_KEY" value="YOUR_API_KEY" /> -->
    <!-- <server name="PICKPOINT_API_KEY" value="YOUR_API_KEY" /> -->
    <!-- <server name="LOCATIONIQ_API_KEY" value="YOUR_API_KEY" /> -->
    <!-- <server name="IPSTACK_API_KEY" value="YOUR_API_KEY" /> -->
</php>

You're done.

Credits

License

Geocoder is released under the MIT License. See the bundled LICENSE file for details.

Comments
  • Refactor providers to leverage ResultFactories - fix #232

    Refactor providers to leverage ResultFactories - fix #232

    • [x] FreeGeoIpProvider
    • [x] HostIpProvider
    • [x] IpInfoDbProvider
    • [x] YahooProvider (REMOVED)
    • [x] GoogleMapsProvider
    • [x] GoogleMapsBusinessProvider
    • [x] BingMapsProvider
    • [x] OpenStreetMapsProvider
    • [x] CloudMadeProvider
    • [x] GeoipProvider
    • [x] MapQuestProvider
    • [x] OIORestProvider
    • [x] GeocoderCaProvider
    • [x] GeocoderUsProvider
    • [x] IGNOpenLSProvider
    • [x] DataScienceToolkitProvider
    • [x] YandexProvider
    • [x] GeoPluginProvider
    • [x] GeoIPsProvider
    • [x] MaxMindProvider
    • [x] MaxMindBinaryProvider
    • [x] GeonamesProvider
    • [x] IpGeoBaseProvider
    • [x] BaiduProvider
    • [x] TomTomProvider
    • [x] ArcGISOnlineProvider

    @willdurand @Baachi What do you think ?

    improvement 
    opened by toin0u 50
  • Website documentation is out of date

    Website documentation is out of date

    The website is still showing the documentation for the 3.x major version, as well as a very outdated provider list.

    http://geocoder-php.org/Geocoder/

    I think we should either update the site (and have it automatically be re-built/deployed using CI on merge to master) or direct users to the github repo.

    I'll to look into it and create a PR when I have a chance.

    documentation 
    opened by atymic 45
  • Creating interfaces to be more SOLID

    Creating interfaces to be more SOLID

    This PR relates to #523

    To be more SOLID our value objects should have interfaces. This will allow others to write providers that may return more data than we have defined in our models.

    This is WIP because Im not happy with the *Interface suffix. We need to come up with better names. Or, are we happy with names like AddressInterface?

    This PR also removes the toString function in favor for __toString

    TODO

    • [x] Be confident with the interface names
    • [x] Update changelog
    opened by Nyholm 42
  • MapQuest improvement

    MapQuest improvement

    This is an improvment to the MapQuest provider, that we talked about in #839

    I have tried to stay away from the code in the Common directory, but I could not avoid some small minor changes there to make it all fit together. Hope this will be ok.

    opened by TerjeBr 37
  • [provider] MaxMind binary provider.

    [provider] MaxMind binary provider.

    This providers would allow to geolocation info from MaxMind`s .dat files. A developer should install MaxMind's php lib himself and include it.

    I want to know Is it really possiblt to add such provider to a lib? If so we can discuss what should be added (tests\docs for example).

    UPDATED

    tests and doc is updated, The PR is ready to merge.

    opened by makasim 34
  • Use numbered administrative level instead of named one

    Use numbered administrative level instead of named one

    PR for for ticket #392. To sum up: replace every occurrence of region and county (no "r"), with a generic admin level array.

    TODOs:

    • [x] delete Region and County from Model namespace;
    • [x] add Admin to Model namespace;
    • [x] update failing test for Providers;
    • [x] fix all providers code;
    • [x] update string formatter;
    • [x] update documentation;
    • [x] squash all commit :)
    • [x] update all tests (USE_CACHED_RESPONSES=false)

    I'll like to hear you feedback about:

    1. [minor] In AbstractProvider::getDefaults the admins value defaults to [] to simplify a bit the code. Is it ok?
    2. Is Admin a clear class name or it is better to call it AdminLevel (as in #392)?
    3. I'm using a simple array for admin levels, where the index is the "depth" in the hierarchy. Is this enough for you?
    4. string formatter is now using %R and %P for Region and County, but this no longer make sense. What should be used? %A1, %A2,%A3,%A4? %A0, %A1, %A2,%A3 (as the array index, not the admin level)? %X, %Y,%Z,%W (as in math :)? Something else?
    opened by giosh94mhz 33
  • Add support for different MaxMind Services

    Add support for different MaxMind Services

    I'm not sure when MaxMind made the change, but they've split out their web services in to different service offerings, with different credits required for each and different result orders.

    http://dev.maxmind.com/geoip/web-services

    I added an additional parameter to the MaxMindProvider that indicates the service, and then properly parsed and validated the different results.

    I've been able to test the 'City/ISP/Org' API and the 'Omni' API, but I don't have credits for the rest.

    Additionally, they added support for IPv6.

    opened by lox 30
  • Implement first idea of the cache provider

    Implement first idea of the cache provider

    Hey guys,

    PSR6 has been released weeks ago and so we have a standard for caching. The feature has been wished thousand times so i started to work on it. Currently this is only a proof of concept and i will finished it if we all fine with the idea.

    My intention is currently: We provide multple strategies and the user can decide how he wants to cache the response. Currently i wrote the stale-if-error strategy and the expire strategy, because i think these are the most common behaviours.

    Please provide feedback :smile:

    on hold 
    opened by Baachi 25
  • CacheProvider

    CacheProvider

    Hey William,

    The library is really popular (971 Stars on GitHub and 37063 Downloads on Packagist), which is really :cool: . But i think geocoder has a missing feature, caching.

    I created already a CacheProvider in the BazingaGeocoderBundle, so i would suggest to move this provider to the core library.

    What do you think about this change?

    provider improvement on hold 
    opened by Baachi 24
  • NoResultException thrown with supplied example

    NoResultException thrown with supplied example

    Hi,

    This project is just great, I'm looking forward to use the propel behavior. But first, a simple try does not work, i did this:

    <?php
                                                    $geocoder = new \Geocoder\Geocoder();
                                                    $adapter = new \Geocoder\HttpAdapter\SocketHttpAdapter();
    
                                                    $geocoder->registerProviders(array(
                                                        new \Geocoder\Provider\GoogleMapsProvider($adapter, 'API_KEY'),
                                                    )); // yes i changed API_KEY by mine
    
    // IP based
                                                    // Street address based
    $result = $geocoder->geocode('10 rue Gambetta, Paris, France');
                                                    var_dump($result);
                                                    ?>
    

    I have this result:

    Geocoder\Exception\NoResultException
    
    Could not execute query http://maps.googleapis.com/maps/api/geocode/json?address=10%20rue%20Gambetta%2C%20Paris%2C%20France&sensor=false&language=API_KEY
    

    But if, i type this link in my browser, I do have a result. Is that normal?

    bug 
    opened by ghost 20
  • [GoogleMapsBusinessProvider] client id should be client_id

    [GoogleMapsBusinessProvider] client id should be client_id

    I see where there have been previous issues with this. But as it stands with 2.4.1 the current use of "client=" is incorrect.

    For me, if I change it to client_id it works:

    http://maps.googleapis.com/maps/api/geocode/json?address=31.4789%20-97.0926&sensor=false&client_id=<my_client_id>

    bug provider 
    opened by JordanDalton 19
  • [Nominatim] Neighbourhood field

    [Nominatim] Neighbourhood field

    Some addresses have a "neighbourhood" field, for example :

    https://nominatim.openstreetmap.org/reverse?format=xml&lat=35.685939&lon=139.811695&zoom=18&addressdetails=1

    In jsonResultToLocation(), this field is not processed, so we can't get that value through the reverseQuery() method.

    feature request 
    opened by Jeremylepr 1
  • Arcgis Provider

    Arcgis Provider

    Is the doc updated? When i try to use $provider = new \Geocoder\Provider\ArcGISList\ArcGISList($httpClient); says class not found, but if i use $provider = new Geocoder\Provider\ArcGISOnline\ArcGISOnline($httpClient); it works, so im i doing something wrong or ?

    question documentation 
    opened by mrelliot69 3
  • Always get the address id

    Always get the address id

    [...] is it possible to get the address id also when the provider list the results ..

    For example arcgis have an id to identify that address, its possible to get that info also on the result array?

    Originally posted by @mrelliot69 in https://github.com/geocoder-php/Geocoder/issues/1163#issuecomment-1263963499

    feature request question 
    opened by jbelien 3
  • How do I change the OpenRouteService::API_URL for

    How do I change the OpenRouteService::API_URL for "On-Premise" install of software

    I noticed the OpenRouteService::API_URL is being hard-coded into file Geocoder\Provider\OpenRouteService (vendor\geocoder-php\openrouteservice-provide\OpenRouteService.php)

    Could someone please push the following code into the next version of OpenRouteService (updating Pelias would do the trick)

    vendor\geocoder-php\pelias-provider\Pelias.php

    /**
     * @param HttpClient $client  an HTTP adapter
     * @param string     $root    url of Pelias API
     * @param int        $version version of Pelias API
     */
    public function __construct(HttpClient $client, string $root, int $version = 1)
    {
        $this->_setPeliasApiRoot($root, $version);
        parent::__construct($client);
    }
    
    /**
     * Set the API root and version, see "_setPeliasApiRoot"
     * @param string     $root    url of Pelias API
     * @param int        $version version of Pelias API
     */
    public function set_Pelias_ApiRoot(string $root, int $version = 1)
    {
        return $this->_setPeliasApiRoot($root, $version);
    }
    
    /**
     * Set the API root and version
     * @param string     $root    url of Pelias API
     * @param int        $version version of Pelias API
     */
    protected function _setPeliasApiRoot(string $root, int $version = 1)
    {
        $this->root    = sprintf('%s/v%d', rtrim($root, '/'), $version);
        $this->version = $version;
    }
    

    vendor\geocoder-php\openrouteservice-provider

    const API_URL = 'https://api.openrouteservice.org/geocode';
    const API_VERSION = 1;
    
    /**
     * @var string
     */
    private $apiKey;
    
    /**
     * @param HttpClient $client an HTTP adapter
     * @param string     $apiKey an API key
     */
    public function __construct(HttpClient $client, string $apiKey)
    {
        if (empty($apiKey)) {
            throw new InvalidCredentials('No API key provided.');
        }
        
        $this->apiKey = $apiKey;
        parent::__construct($client, self::API_URL, self::API_VERSION);
        $this->_set_ORS_API_Root(self::API_URL, self::API_VERSION, TRUE);
    }
    
    /**
     * Set the Openrouteservice URL
     * @param string $root
     * @param integer $version
     * @param boolean $check_version
     * @return void
     */
    public function set_ORS_API_Root(string $root, $version, $check_version = false)
    {
        return $this->_set_ORS_API_Root($root, $version, $check_version);
    }
    
    /**
     * Set the Openrouteservice URL
     * @param string $root
     * @param integer $version
     * @param boolean $check_version
     * @return void
     */
    protected function _set_ORS_API_Root(string $root, $version, $check_version = false)
    {
        parent::_setPeliasApiRoot($root, $version);
        if (filter_var($check_version, FILTER_VALIDATE_BOOLEAN)) {
            $this->_check_ORS_API_Root_Version($root, $root, $version);
        }
    }
    
    /**
     * Openrouteservice does not use /v1 in first version, but plan to add
     *  /v2 in next version.
     *
     * @see https://ask.openrouteservice.org/t/pelias-version-in-api-url/1021
     * @param string $root
     * @param string $new_root
     * @param string $version
     * @return void
     */
    protected function _check_ORS_API_Root_Version(string &$root, string $new_root, $version)
    {
        $version_ok = true;
        $version_ok = ($version_ok && is_numeric($version));
        $version_ok = ($version_ok && ($version === self::API_VERSION));
        $version_ok = ($version_ok && is_string($new_root));
        $version_ok = ($version_ok && !empty($new_root));
        $version_ok = (bool) $version_ok;
        
        if ($version_ok) {
            $root = $new_root;
        }
    }
    
    provider improvement 
    opened by killrawr 1
  • [Nominatim] Municipality not in list of 'localityFields'

    [Nominatim] Municipality not in list of 'localityFields'

    I came across some reverse geocoding results where Nominatim.php didn't return a 'locality'. In my opinion, this latlng query should have 'Purmerend' as its locality, as it's the municipal boundary:

    https://nominatim.openstreetmap.org/ui/reverse.html?lat=52.50741&lon=4.93279&zoom=18 https://nominatim.openstreetmap.org/ui/details.html?osmtype=W&osmid=6593763&class=highway

    Upon debugging, I noticed that inside jsonResultToLocation(), on line 209, 'municipality' was not considered a 'locality'.

    $localityFields = ['city', 'town', 'village', 'hamlet'];

    Is this a matter of definition?

    Adding 'municipality' fixes my issue:

    $localityFields = ['city', 'town', 'village', 'hamlet', 'municipality'];

    provider question 
    opened by uwbas 2
Releases(4.3.0)
  • 4.3.0(Jul 30, 2022)

  • 4.2.0(Dec 22, 2020)

  • 4.1.0(Jul 4, 2020)

  • 4.0.0(Aug 1, 2017)

  • v3.3.0(Dec 6, 2015)

    This version officially supports PHP 7.0.


    CHANGELOG

    • Added: timezone field for FreeGeoIp provider
    • Added: guess method for street and suburb
    • Added: use city, town village or hamlet as locality
    • Added: return ISO 3166-2 region codes for the US and the rest of the world
    • Fixed: AdminLevelCollection::checkLevel() (#468)
    Source code(tar.gz)
    Source code(zip)
  • v3.2.0(Oct 9, 2015)

    • Added: add __toString() methods in AdminLevel and Country
    • Added: __toString()toStreamInterface` mock
    • Fixed: postal code for GeoIP2 provider
    • Fixed: Make sure we check for an error in the response of the Yandex provider
    • Fixed: emergency message "You need to specify the country and region codes."

    Thank you to all contributors!

    Source code(tar.gz)
    Source code(zip)
  • v3.1.0(Aug 13, 2015)

    • Added: show more API error messages in GoogleMaps
    • Fixed: require http-adapter ~0.8
    • Fixed: use https transport in Yandex provider (#431)
    • Updated: documentation
    Source code(tar.gz)
    Source code(zip)
  • v3.0.0(Apr 20, 2015)

  • v3.0.0-alpha3(Feb 13, 2015)

    This is the new 3.0.0 pre-release, including the following changes:

    • Added: LocaleTrait to reduce code duplication
    • Added: introduce admin levels concept (see PR #398)
    • Fixed: GeoIP2 results use underscore case
    • Merged: branch '2.x' (see releases 2.8.1 and 2.8.2 for more details)
    Source code(tar.gz)
    Source code(zip)
  • 2.8.2(Jan 7, 2015)

  • v3.0.0-alpha2(Dec 22, 2014)

  • v3.0.0-alpha1(Dec 22, 2014)

    Hi!

    I am proud to announce that we are ready to ship the next major version of Geocoder: 3.0.0. This is a pre-release which will help us ensure everything works smoothly. We are currently working hard on making Geocoder related projects compatible with this new version, hence the need for a pre-release version.

    Basically, we changed almost everything in this library but its simplicity and its robustness have been kept. Since 2012, Geocoder provides a powerful API to perform geocoding actions in PHP. However, things in PHP evolved a lot, and we decided to refactor the lib to be more flexible, and even more powerful.

    For instance, providers are now highly configurable and Geocoder leverages a third-party library implementing PSR-7.

    Update: the main idea behind this was to introduce a dependency to PSR-7 interfaces, and to avoid the NIH syndrom. The http-adapter library is a great one, and Geocoder is not about dealing with HTTP, it is about geocoding stuff.

    Geocoder 3.0.0 contains less code than previously, 49 classes, 5 interfaces and less than 5300 lines of code for the code (tests are not included here). As a matter of fact, Geocoder 2.x has 56 classes and 6500 lines of code. Removing code was a challenge as we did not want to remove features from this library. We rather re-organized Geocoder to fit its initial goal: providing a simple yet powerful way to geocode street and IP addresses, with the ability to switch from one provider to another with ease. Geocoder Extra contains alternative providers that are not worldwide and therefore less used. Again, we did not remove anything.

    New features have been added, such as the TimedGeocoder implementation and a better model layer. You will find all details in the CHANGELOG below.

    The documentation, which has been rewritten, also contains a description of Geocoder's versioning strategy, and we are proud to have a Contributor Code of Conduct, because the lack of diversity in Open Source is not acceptable.

    Help us making Geocoder 3.0.0 really stable by giving this very first pre-release a try!

    Last but not the least, THANK YOU to all contributors!!! :yellow_heart: :blue_heart: :heart: :green_heart: :ship: :star: :star2: :blue_heart: :stars: :gift_heart:

    Let's celebrate now!

    Full Changelog

    • Added: using() method now throws an exception if provider not found
    • Added: new Result classes (Address, Bounds, Region, Country, County, Coordinates)
    • Added: new named exceptions
    • Added: better exception messages
    • Added: new HTTP layer thanks to egeloen/http-adapter library
    • Added: TimedGeocoder implementation (works with StopWatch Symfony component)
    • Added: AbstractHttpProvider (extending AbstractProvider)
    • Added: provide a way to use IpInfoDB country precision
    • Added: cached responses for BingMaps provider (tests)
    • Added: cached reponse for GoogleMaps provider (tests)
    • Added: ProviderAggregator (replacing the former Geocoder class)
    • Added: ability to change providers locale at runtime
    • Documentation: almost entirely rewritten
    • Documentation: a note on versioning has been added
    • Documentation: a Contributor Code of Conduct has been added for the entire Geocoder project
    • Fixed: phpdoc, wording
    • Fixed: providers are now highly configurable, even at runtime
    • Fixed: FreeGeoIp property because of an API change
    • Moved: IGN OpenLS provider to geocoder-extra (#339)
    • Moved: OIORest provider to geocoder-extra (#336)
    • Moved: GeoCoder.us provider to geocoder-extra (#338)
    • Moved: GeoCoder.ca provider to geocoder-extra (#337)
    • Moved: DataScienceToolkit provider to geocoder-extra (#340)
    • Moved: Baidu provider to geocoder-extra (#341)
    • Moved: IpGeoBase provider to geocoder-extra (#342)
    • Renamed: properties such as:
      • city => locality
      • cityDistrict => subLocality
      • zipcode => postalCode
    • Refactored: dumpers (remove Interface suffix, define a new method signature)
    • Refactored: class names!
    • Refactored: all providers now implement the Geocoder interface
    • Refactored: exception messages are a bit more verbose
    • Removed: Provider, Dumper, Interface, and Exception suffixes
    • Removed: autoload.php file
    • Removed: OpenStreetMapsProvider class (#335)
    • Removed: HTTP adapters layer
    • Removed: the Geocoder class does not exist anymore and has been replaced by the ProviderAggregator class
    Source code(tar.gz)
    Source code(zip)
  • 2.8.1(Dec 8, 2014)

  • 2.8.0(Oct 3, 2014)

    • Added: Allow for greater flexibility in setting curl parameters by passing in an array.
    • Removed: GeoIP2 Omni support
    • Removed: Cloudmade provider. They discontinued their service Apr/2014

    This is most likely the last minor version of Geocoder 2.x.

    Source code(tar.gz)
    Source code(zip)
  • 2.7.0(Sep 14, 2014)

  • 2.6.0(Sep 2, 2014)

    • Added: region and regionCode to GeoIP2Provider
    • Added: throw InvalidCredentialsException with GoogleMapsBusinessProvider
    • Added: support in MapQuestProvider for licensed endpoints (#318)
    • Added: it is now possible to set the user agent in CurlHttpAdapter
    • Fixed: google maps provider test
    • Fixed: GeoPlugin returns 206 for anonymous proxies
    • Removed: Google's sensor parameter
    • Updated: Travis-CI config, doc, tests

    Thank you to all contributors!

    Source code(tar.gz)
    Source code(zip)
  • 2.5.0(May 16, 2014)

    • Added: ability to set timeouts for CurlHttpAdapter
    • Added: support for a Google Maps API key
    • Added: premium support to GeocoderCaProvider + tests
    • Added: test against hhvm-nightly on Travis-CI
    • Updated: documentation
    Source code(tar.gz)
    Source code(zip)
  • 2.4.2(Jan 5, 2014)

  • 2.4.1(Dec 16, 2013)

  • 2.4.0(Dec 12, 2013)

    • Added: MapQuest API key is now required for open services
    • Removed: unused class constants
    • Removed: deprecated class that is not used anymore since 2.0.0
    Source code(tar.gz)
    Source code(zip)
  • 2.3.2(Nov 6, 2013)

  • 2.3.1(Oct 22, 2013)

  • 1.7.1(Oct 18, 2013)

  • 2.3.0(Oct 17, 2013)

    • Added: Reintroduce OpenStreetMapsProvider for BC purpose
    • Fixed: Rename OpenStreetMaps => OpenStreetMap The OpenStreetMapsProvider is now deprecated, use the OpenStreetMapProvider instead.
    • Fixed: replace extension_exists() by function_exists() for mbstring
    Source code(tar.gz)
    Source code(zip)
  • 2.2.0(Sep 16, 2013)

    • Added: ChainNoResultException for aggregating ChainProvider exceptions.
    • Added: CachedResponseAdapter for the test suite + cached responses
    • Updated: composer installation to the current recommendation from http://getcomposer.org/download/
    Source code(tar.gz)
    Source code(zip)
  • 2.1.0(Aug 27, 2013)

    • Added: Generic NominatimProvider
    • Fixed: GoogleBusinessProvider "client_id" parameter back to just "client". This reverts commit 532345bbd41221d2460591844dfffb04194c66
    Source code(tar.gz)
    Source code(zip)
  • 2.0.1(Aug 8, 2013)

    Fixed: tests due to data changes Fixed: use OpenStreetMap pedestrian tag for street name if road tag is not available Updated: replace zendframework with zend-http

    Source code(tar.gz)
    Source code(zip)
  • 2.0.0(Jul 9, 2013)

    Fixed: tests due to data changes Added: more doc. Fix #242 Added: setMaxResults method Added support for cities in Yandex Provider Fixed: GoogleMapsBusinessProvider provider (client_id) Refactored: providers to leverage ResultFactories - fix #232 - POTENTIAL BC BREAK

    Source code(tar.gz)
    Source code(zip)
ESRI ShapeFile library for PHP

shapefile ShapeFile library for PHP Features Currently the 2D and 3D variants except MultiPatch of the ShapeFile format as defined in https://www.esri

phpMyAdmin 23 Jun 29, 2022
Simple Yet Powerful Geo Library for PHP

phpgeo - A Simple Geo Library for PHP phpgeo provides abstractions to geographical coordinates (including support for different ellipsoids) and allows

Marcus Jaschen 1.4k Dec 27, 2022
PHP library to access the OpenCage geocoding API

OpenCage Geocoding API Library for PHP A PHP library to use the OpenCage geocoding API. Build Status / Code Quality Overview This library attempts to

OpenCage GmbH 29 Nov 15, 2022
PHP library for determining the physical location of binaries

Bin Locator Library for searching binary files in the operating system. Requirements PHP >= 7.4 Installation Library is available as composer reposito

PHP FFI 8 Jul 27, 2022
PHP library to easily get static image from French Cadastral Government map with markers and lines.

PHP French Cadastral Map Static API PHP library to easily get static image from French Cadastral Government map with markers and lines. Map source : c

Franck Alary 6 Nov 29, 2022
PHP library to easily get static image from OpenStreetMap (OSM) with markers and lines.

PHP OpenStreetMap Static API PHP library to easily get static image from OpenStreetMap with markers and lines. ✨ Supporting ⭐ Star this repository to

Franck Alary 34 Jan 2, 2023
Official PHP library for IPinfo (IP geolocation and other types of IP data)

This is the official PHP client library for the IPinfo.io IP address API, allowing you to lookup your own IP address,

IPinfo 171 Jan 2, 2023
PHP extension for geospatial rendering with Mapnik

PHP7 Mapnik Introduction This project is an extension for PHP 7 that enables geospatial rendering with Mapnik. Create tile generation scripts, dynamic

Garrett Johnson 20 Dec 14, 2022
PHP Extension to handle common geospatial functions.

geospatial - PHP Geospatial Extension PHP Extension to handle common geospatial functions. The extension currently has implementations of the Haversin

PHP Geospatial, putting the Elephpant on your globe 56 Dec 29, 2022
GeoJSON implementation for PHP

GeoJson PHP Library This library implements the GeoJSON format specification. The GeoJson namespace includes classes for each data structure defined i

Jeremy Mikola 274 Dec 17, 2022
YCOM Impersonate. Login as selected YCOM user πŸ§™β€β™‚οΈin frontend.

YCOM Impersonate Login as selected YCOM user in frontend. Features: Backend users with admin rights or YCOM[] rights, can be automatically logged in v

Friends Of REDAXO 17 Sep 12, 2022
Geo-related tools PHP 5.4+ library built atop Geocoder and React libraries

Geotools Geotools is a PHP geo-related library, built atop Geocoder and React libraries. Features Batch geocode & reverse geocoding request(s) in seri

The League of Extraordinary Packages 1.3k Dec 27, 2022
Geo-related tools PHP 7.3+ library built atop Geocoder and React libraries

Geotools Geotools is a PHP geo-related library, built atop Geocoder and React libraries. Features Batch geocode & reverse geocoding request(s) in seri

The League of Extraordinary Packages 1.3k Dec 27, 2022
Featured Calendar Maker v1.0 multingual extends the functionalities of the latest version of the FullCalendar (5.3.2), the most popular and completed JavaScript Calendar open source

Featured Calendar Maker v1.0 multingual extends the functionalities of the latest version of the FullCalendar (5.3.2), the most popular and completed JavaScript Calendar open source.

null 21 Oct 5, 2022
This is the Yandex provider from the PHP Geocoder.

Yandex Geocoder provider This is the Yandex provider from the PHP Geocoder. This is a READ ONLY repository. See the main repo for information and docu

Geocoder 5 Jan 7, 2022
A fully featured full text search engine written in PHP

TNTSearch TNTSearch is a full-text search (FTS) engine written entirely in PHP. A simple configuration allows you to add an amazing search experience

TNT Studio 2.9k Jan 8, 2023
A full-featured blog using Laravel 7.* & VueJS. Minimum library used

Blog Using Laravel 8 Let's keep it as simple as possible. Configure anything you want A full-featured blogging system for personal use.

Al Imran Ahmed 187 Sep 25, 2022
The most popular PHP library for use with the Twitter OAuth REST API.

TwitterOAuth The most popular PHP library for Twitter's OAuth REST API. See documentation at https://twitteroauth.com. PHP versions listed as "active

Abraham Williams 4.2k Dec 23, 2022
πŸ’Ž Flexible, compiled and full-featured Dependency Injection Container with perfectly usable autowiring and support for all new PHP 7 features.

Nette Dependency Injection (DI) Introduction Purpose of the Dependecy Injection (DI) is to free classes from the responsibility for obtaining objects

Nette Foundation 781 Dec 15, 2022
Full-featured e-commerce platform with multi-domain and multi-language support for PHP 8

Surikata.io Full-featured e-commerce platform with multi-domain and multi-language support for PHP 8. Free to use for both commercial and personal pro

null 8 Apr 5, 2022