vdmkbu / geocoder
There is no license information available for the latest version (v1.0.1) of this package.
v1.0.1
2020-02-15 15:34 UTC
Requires
- laminas/laminas-diactoros: ^2.2
- psr/http-client: ^1.0
Requires (Dev)
- guzzlehttp/guzzle: ^6.5
- php-http/guzzle6-adapter: ^2.0
- phpunit/phpunit: ^5.7
- vlucas/phpdotenv: ^4.1
This package is auto-updated.
Last update: 2024-04-25 01:01:27 UTC
README
Получаем координаты по переданному адресу или адрес по переданным координатам
https://tech.yandex.ru/maps/geocoder/doc/desc/concepts/about-docpage/
install
composer require vdmkbu/geocoder
usage
require 'vendor/autoload.php'; // используем библиотеку GuzzleHttp и PSR-совместимый адаптер use GuzzleHttp\Client as GuzzleClient; use Http\Adapter\Guzzle6\Client as GuzzleAdapter; use Vdmkbu\Geocoder\Types\Address; use Vdmkbu\Geocoder\Types\Point; use Vdmkbu\Geocoder\YandexGeocoder; // готовим http-клиент $config = []; $guzzle = new GuzzleClient($config); $client = new GuzzleAdapter($guzzle); $api_key = 'YANDEX_API_KEY'; $geocoder = new YandexGeocoder($client, $api_key); $address = $geocoder->geocode(new Point('37.611347,55.760241')); $address->getCountry(); $address->getStreet(); $address->getHouse(); $point = $geocoder->geocode(new Address('Челябинск проспект Ленина 54')); $point->getLng(); $point->getLat();