geo6/geocoder-php-bpost-provider

bpost 地理编码适配器

v1.4.0 2022-07-31 09:06 UTC

This package is auto-updated.

Last update: 2024-08-30 01:28:52 UTC


README

PHP CI Latest Stable Version Total Downloads Monthly Downloads Code Coverage Scrutinizer Code Quality Software License

Geocoder PHP 是一个PHP库,它通过提供地理编码操作的强大抽象层,帮助您构建具有地理感知的应用程序。

这是 Geocoder PHP 的 "bpost" 提供程序。

覆盖范围: 比利时
API: https://www.bpost.be/site/en/webservice-address

安装

composer require geo6/geocoder-php-bpost-provider

使用方法

参见 Geocoder PHP README 文件

use Geocoder\Query\GeocodeQuery;

$httpClient = new \Http\Adapter\Guzzle6\Client();
$provider = new \Geocoder\Provider\bpost\bpost($httpClient);
$geocoder = new \Geocoder\StatefulGeocoder($provider, 'en');

// Query with unstructured address
$result = $geocoder->geocodeQuery(GeocodeQuery::create('5 Place des Palais 1000 Bruxelles'));

// Query with structured address
$query = GeocodeQuery::create('5 Place des Palais 1000 Bruxelles')
    ->withData('streetNumber', '5')
    ->withData('streetName', 'Place des Palais')
    ->withData('postalCode', '1000')
    ->withData('locality', 'Bruxelles');
$results = $geocoder->geocodeQuery($query);