Skip to content

wowworks-team/geocoder-php-dadata-provider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

geocoder-php-dadata-provider

Geocoder DaData adapter

Geocoder DaData adapter. Integration with Dadata suggestions API.

Latest Stable Version Total Downloads Latest Unstable Version License

Installation

This extension is available at packagist.org and can be installed via composer by following command:

composer require wowworks/geocoder-php-dadata-provider

Configuration

To work, you need to connect the package wowworks/geocoder-php-dadata-provider

Example:

$service = new \DadataSuggestions\DadataSuggestionsService();
$service->setUrl('https://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/');
$service->setToken('...');
$dadataProvider = new \Wowworks\Dadata\Dadata($service);
$collection = $dadataProvider->geocodeQuery(\Geocoder\Query\GeocodeQuery::create('г Москва, улица Академика Королева, дом 15, корп. 2'));
foreach ($collection->all() as $location) {
    $location->getCoordinates()->getLatitude();
    $location->getCoordinates()->getLongitude();

    $location->getCountry();
    foreach ($location->getAdminLevels() as $level) {
        if ($level instanceof AdminLevel) {
            $level->getName();
        }
    }
    $location->getLocality();
    $location->getSubLocality();
    $location->getStreetName();
    $location->getStreetNumber();
    $location->getProvidedBy();
}