wowworks / geocoder-php-dadata-provider
与 Dadata 建议 API 集成。
v1.1.4
2020-06-05 12:10 UTC
Requires
- php: >=5.6.0
- glendemon/dadata-suggestions: ^1.0
- willdurand/geocoder: ^4.2
Requires (Dev)
- ext-curl: *
- phpunit/phpunit: *
This package is not auto-updated.
Last update: 2024-09-14 01:17:13 UTC
README
地理编码器 DaData 适配器
地理编码器 DaData 适配器。与 Dadata 建议 API 集成。
安装
此扩展在 packagist.org 上可用,可以通过以下命令使用 composer 安装
composer require wowworks/geocoder-php-dadata-provider
配置
要运行,您需要连接到 wowworks/geocoder-php-dadata-provider
包
示例
$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(); }